mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 10:10:00 +00:00
f2fs-tools: build binaries in Mac
This patch modifies f2fs-tools to be built in mac. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
191a60fb4b
commit
43bb7b6c99
101
configure.ac
101
configure.ac
@ -35,16 +35,6 @@ AC_CONFIG_MACRO_DIR([m4])
|
|||||||
AC_CONFIG_AUX_DIR([build-aux])
|
AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AM_INIT_AUTOMAKE([foreign tar-pax dist-xz])
|
AM_INIT_AUTOMAKE([foreign tar-pax dist-xz])
|
||||||
|
|
||||||
AC_CHECK_HEADERS_ONCE([
|
|
||||||
fcntl.h
|
|
||||||
mntent.h
|
|
||||||
stdlib.h
|
|
||||||
string.h
|
|
||||||
unistd.h
|
|
||||||
sys/ioctl.h
|
|
||||||
sys/mount.h
|
|
||||||
])
|
|
||||||
|
|
||||||
# Test configure options.
|
# Test configure options.
|
||||||
AC_ARG_WITH([selinux],
|
AC_ARG_WITH([selinux],
|
||||||
AS_HELP_STRING([--without-selinux],
|
AS_HELP_STRING([--without-selinux],
|
||||||
@ -91,9 +81,30 @@ AS_IF([test "x$have_blkid" = "xyes"],
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_CHECK_HEADERS([linux/fs.h linux/blkzoned.h fcntl.h mntent.h stdlib.h string.h \
|
AC_CHECK_HEADERS(m4_flatten([
|
||||||
sys/ioctl.h sys/mount.h unistd.h linux/falloc.h byteswap.h \
|
attr/xattr.h
|
||||||
attr/xattr.h linux/xattr.h linux/posix_acl.h sys/acl.h])
|
byteswap.h
|
||||||
|
fcntl.h
|
||||||
|
linux/blkzoned.h
|
||||||
|
linux/falloc.h
|
||||||
|
linux/fs.h
|
||||||
|
linux/hdreg.h
|
||||||
|
linux/limits.h
|
||||||
|
linux/posix_acl.h
|
||||||
|
linux/types.h
|
||||||
|
linux/xattr.h
|
||||||
|
mntent.h
|
||||||
|
scsi/sg.h
|
||||||
|
stdlib.h
|
||||||
|
string.h
|
||||||
|
sys/acl.h
|
||||||
|
sys/ioctl.h
|
||||||
|
sys/syscall.h
|
||||||
|
sys/mount.h
|
||||||
|
sys/sysmacros.h
|
||||||
|
sys/xattr.h
|
||||||
|
unistd.h
|
||||||
|
]))
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_INLINE
|
AC_C_INLINE
|
||||||
@ -104,15 +115,75 @@ AC_TYPE_SIZE_T
|
|||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_GETMNTENT
|
AC_FUNC_GETMNTENT
|
||||||
AC_CHECK_FUNCS_ONCE([
|
AC_CHECK_FUNCS_ONCE([
|
||||||
|
add_key
|
||||||
fallocate
|
fallocate
|
||||||
getmntent
|
|
||||||
memset
|
|
||||||
fsetxattr
|
fsetxattr
|
||||||
|
fstat
|
||||||
|
fstat64
|
||||||
|
getmntent
|
||||||
|
keyctl
|
||||||
|
llseek
|
||||||
|
lseek64
|
||||||
|
memset
|
||||||
|
setmntent
|
||||||
])
|
])
|
||||||
|
|
||||||
AS_IF([test "$ac_cv_header_byteswap_h" = "yes"],
|
AS_IF([test "$ac_cv_header_byteswap_h" = "yes"],
|
||||||
[AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])])
|
[AC_CHECK_DECLS([bswap_64],,,[#include <byteswap.h>])])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Check to see if llseek() is declared in unistd.h. On some libc's
|
||||||
|
dnl it is, and on others it isn't..... Thank you glibc developers....
|
||||||
|
dnl
|
||||||
|
AC_CHECK_DECL(llseek,[AC_DEFINE(HAVE_LLSEEK_PROTOTYPE, 1,
|
||||||
|
[Define to 1 if llseek declared in unistd.h])],,
|
||||||
|
[#include <unistd.h>])
|
||||||
|
dnl
|
||||||
|
dnl Check to see if lseek64() is declared in unistd.h. Glibc's header files
|
||||||
|
dnl are so convoluted that I can't tell whether it will always be defined,
|
||||||
|
dnl and if it isn't defined while lseek64 is defined in the library,
|
||||||
|
dnl disaster will strike.
|
||||||
|
dnl
|
||||||
|
dnl Warning! Use of --enable-gcc-wall may throw off this test.
|
||||||
|
dnl
|
||||||
|
dnl
|
||||||
|
AC_CHECK_DECL(lseek64,[AC_DEFINE(HAVE_LSEEK64_PROTOTYPE, 1,
|
||||||
|
[Define to 1 if lseek64 declared in unistd.h])],,
|
||||||
|
[#define _LARGEFILE_SOURCE
|
||||||
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#include <unistd.h>])
|
||||||
|
dnl
|
||||||
|
dnl Word sizes...
|
||||||
|
dnl
|
||||||
|
|
||||||
|
# AC_CANONICAL_HOST is needed to access the 'host_os' variable
|
||||||
|
AC_CANONICAL_HOST
|
||||||
|
|
||||||
|
build_linux=no
|
||||||
|
build_windows=no
|
||||||
|
build_mac=no
|
||||||
|
|
||||||
|
# Detect the target system
|
||||||
|
case "${host_os}" in
|
||||||
|
linux*)
|
||||||
|
build_linux=yes
|
||||||
|
;;
|
||||||
|
cygwin*|mingw*)
|
||||||
|
build_windows=yes
|
||||||
|
;;
|
||||||
|
darwin*)
|
||||||
|
build_mac=yes
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR(["OS $host_os is not supported"])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Pass the conditionals to automake
|
||||||
|
AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
|
||||||
|
AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
|
||||||
|
AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"])
|
||||||
|
|
||||||
# Install directories
|
# Install directories
|
||||||
#AC_PREFIX_DEFAULT([/usr])
|
#AC_PREFIX_DEFAULT([/usr])
|
||||||
#AC_SUBST([sbindir], [/sbin])
|
#AC_SUBST([sbindir], [/sbin])
|
||||||
|
@ -360,8 +360,14 @@ static void dump_xattr(struct f2fs_sb_info *sbi, struct f2fs_node *node_blk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBG(1, "fd %d xattr_name %s\n", c.dump_fd, xattr_name);
|
DBG(1, "fd %d xattr_name %s\n", c.dump_fd, xattr_name);
|
||||||
|
#if defined(__linux__)
|
||||||
ret = fsetxattr(c.dump_fd, xattr_name, value,
|
ret = fsetxattr(c.dump_fd, xattr_name, value,
|
||||||
le16_to_cpu(ent->e_value_size), 0);
|
le16_to_cpu(ent->e_value_size), 0);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
ret = fsetxattr(c.dump_fd, xattr_name, value,
|
||||||
|
le16_to_cpu(ent->e_value_size), 0,
|
||||||
|
XATTR_CREATE);
|
||||||
|
#endif
|
||||||
if (ret)
|
if (ret)
|
||||||
MSG(0, "XATTR index 0x%x set xattr failed error %d\n",
|
MSG(0, "XATTR index 0x%x set xattr failed error %d\n",
|
||||||
ent->e_name_index, errno);
|
ent->e_name_index, errno);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef _F2FS_H_
|
#ifndef _F2FS_H_
|
||||||
#define _F2FS_H_
|
#define _F2FS_H_
|
||||||
|
|
||||||
|
#include <f2fs_fs.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -18,14 +19,14 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#ifdef HAVE_MNTENT_H
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <f2fs_fs.h>
|
|
||||||
|
|
||||||
#define EXIT_ERR_CODE (-1)
|
#define EXIT_ERR_CODE (-1)
|
||||||
#define ver_after(a, b) (typecheck(unsigned long long, a) && \
|
#define ver_after(a, b) (typecheck(unsigned long long, a) && \
|
||||||
typecheck(unsigned long long, b) && \
|
typecheck(unsigned long long, b) && \
|
||||||
|
@ -881,14 +881,14 @@ skip_blkcnt_fix:
|
|||||||
}
|
}
|
||||||
if (ftype == F2FS_FT_SYMLINK && i_blocks && i_size == 0) {
|
if (ftype == F2FS_FT_SYMLINK && i_blocks && i_size == 0) {
|
||||||
DBG(1, "ino: 0x%x i_blocks: %lu with zero i_size",
|
DBG(1, "ino: 0x%x i_blocks: %lu with zero i_size",
|
||||||
nid, i_blocks);
|
nid, (unsigned long)i_blocks);
|
||||||
if (c.fix_on) {
|
if (c.fix_on) {
|
||||||
u64 i_size = i_blocks * F2FS_BLKSIZE;
|
u64 i_size = i_blocks * F2FS_BLKSIZE;
|
||||||
|
|
||||||
node_blk->i.i_size = cpu_to_le64(i_size);
|
node_blk->i.i_size = cpu_to_le64(i_size);
|
||||||
need_fix = 1;
|
need_fix = 1;
|
||||||
FIX_MSG("Symlink: recover 0x%x with i_size=%lu",
|
FIX_MSG("Symlink: recover 0x%x with i_size=%lu",
|
||||||
nid, i_size);
|
nid, (unsigned long)i_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
fsck/mount.c
10
fsck/mount.c
@ -18,6 +18,16 @@
|
|||||||
#include <sys/acl.h>
|
#include <sys/acl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ACL_UNDEFINED_TAG
|
||||||
|
#define ACL_UNDEFINED_TAG (0x00)
|
||||||
|
#define ACL_USER_OBJ (0x01)
|
||||||
|
#define ACL_USER (0x02)
|
||||||
|
#define ACL_GROUP_OBJ (0x04)
|
||||||
|
#define ACL_GROUP (0x08)
|
||||||
|
#define ACL_MASK (0x10)
|
||||||
|
#define ACL_OTHER (0x20)
|
||||||
|
#endif
|
||||||
|
|
||||||
u32 get_free_segments(struct f2fs_sb_info *sbi)
|
u32 get_free_segments(struct f2fs_sb_info *sbi)
|
||||||
{
|
{
|
||||||
u32 i, free_segs = 0;
|
u32 i, free_segs = 0;
|
||||||
|
@ -6,9 +6,13 @@
|
|||||||
#define _LINUX_QUOTA_TREE_H
|
#define _LINUX_QUOTA_TREE_H
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#ifdef HAVE_LINUX_TYPES_H
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
#endif
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <f2fs_fs.h>
|
||||||
|
|
||||||
typedef __u32 qid_t; /* Type in which we store ids in memory */
|
typedef __u32 qid_t; /* Type in which we store ids in memory */
|
||||||
|
|
||||||
#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
|
#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
|
||||||
|
@ -36,7 +36,7 @@ static int get_new_sb(struct f2fs_super_block *sb)
|
|||||||
zone_align_start_offset) / segment_size_bytes /
|
zone_align_start_offset) / segment_size_bytes /
|
||||||
c.segs_per_sec * c.segs_per_sec);
|
c.segs_per_sec * c.segs_per_sec);
|
||||||
|
|
||||||
blocks_for_sit = ALIGN(get_sb(segment_count), SIT_ENTRY_PER_BLOCK);
|
blocks_for_sit = SIZE_ALIGN(get_sb(segment_count), SIT_ENTRY_PER_BLOCK);
|
||||||
sit_segments = SEG_ALIGN(blocks_for_sit);
|
sit_segments = SEG_ALIGN(blocks_for_sit);
|
||||||
set_sb(segment_count_sit, sit_segments * 2);
|
set_sb(segment_count_sit, sit_segments * 2);
|
||||||
set_sb(nat_blkaddr, get_sb(sit_blkaddr) +
|
set_sb(nat_blkaddr, get_sb(sit_blkaddr) +
|
||||||
@ -45,7 +45,8 @@ static int get_new_sb(struct f2fs_super_block *sb)
|
|||||||
total_valid_blks_available = (get_sb(segment_count) -
|
total_valid_blks_available = (get_sb(segment_count) -
|
||||||
(get_sb(segment_count_ckpt) +
|
(get_sb(segment_count_ckpt) +
|
||||||
get_sb(segment_count_sit))) * blks_per_seg;
|
get_sb(segment_count_sit))) * blks_per_seg;
|
||||||
blocks_for_nat = ALIGN(total_valid_blks_available, NAT_ENTRY_PER_BLOCK);
|
blocks_for_nat = SIZE_ALIGN(total_valid_blks_available,
|
||||||
|
NAT_ENTRY_PER_BLOCK);
|
||||||
set_sb(segment_count_nat, SEG_ALIGN(blocks_for_nat));
|
set_sb(segment_count_nat, SEG_ALIGN(blocks_for_nat));
|
||||||
|
|
||||||
sit_bitmap_size = ((get_sb(segment_count_sit) / 2) <<
|
sit_bitmap_size = ((get_sb(segment_count_sit) / 2) <<
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
#include "fsck.h"
|
#include "fsck.h"
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#ifdef HAVE_MNTENT_H
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBSELINUX
|
#ifdef HAVE_LIBSELINUX
|
||||||
#include <selinux/selinux.h>
|
#include <selinux/selinux.h>
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "xattr.h"
|
#include "xattr.h"
|
||||||
|
|
||||||
#define XATTR_CREATE 0x1
|
|
||||||
#define XATTR_REPLACE 0x2
|
|
||||||
|
|
||||||
void *read_all_xattrs(struct f2fs_sb_info *sbi, struct f2fs_node *inode)
|
void *read_all_xattrs(struct f2fs_sb_info *sbi, struct f2fs_node *inode)
|
||||||
{
|
{
|
||||||
struct f2fs_xattr_header *header;
|
struct f2fs_xattr_header *header;
|
||||||
|
20
fsck/xattr.h
20
fsck/xattr.h
@ -17,6 +17,9 @@
|
|||||||
#define _XATTR_H_
|
#define _XATTR_H_
|
||||||
|
|
||||||
#include "f2fs.h"
|
#include "f2fs.h"
|
||||||
|
#ifdef HAVE_SYS_XATTR_H
|
||||||
|
#include <sys/xattr.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct f2fs_xattr_header {
|
struct f2fs_xattr_header {
|
||||||
__le32 h_magic; /* magic number for identification */
|
__le32 h_magic; /* magic number for identification */
|
||||||
@ -76,6 +79,23 @@ static inline int f2fs_acl_count(int size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef XATTR_USER_PREFIX
|
||||||
|
#define XATTR_USER_PREFIX "user."
|
||||||
|
#endif
|
||||||
|
#ifndef XATTR_SECURITY_PREFIX
|
||||||
|
#define XATTR_SECURITY_PREFIX "security."
|
||||||
|
#endif
|
||||||
|
#ifndef XATTR_TRUSTED_PREFIX
|
||||||
|
#define XATTR_TRUSTED_PREFIX "trusted."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XATTR_CREATE
|
||||||
|
#define XATTR_CREATE 0x1
|
||||||
|
#endif
|
||||||
|
#ifndef XATTR_REPLACE
|
||||||
|
#define XATTR_REPLACE 0x2
|
||||||
|
#endif
|
||||||
|
|
||||||
#define XATTR_ROUND (3)
|
#define XATTR_ROUND (3)
|
||||||
|
|
||||||
#define XATTR_SELINUX_SUFFIX "selinux"
|
#define XATTR_SELINUX_SUFFIX "selinux"
|
||||||
|
54
include/android_config.h
Normal file
54
include/android_config.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#if defined(__linux__)
|
||||||
|
#define HAVE_BYTESWAP_H 1
|
||||||
|
#define HAVE_FCNTL_H 1
|
||||||
|
#define HAVE_FALLOC_H 1
|
||||||
|
#define HAVE_LINUX_HDREG_H 1
|
||||||
|
#define HAVE_LINUX_LIMITS_H 1
|
||||||
|
#define HAVE_POSIX_ACL_H 1
|
||||||
|
#define HAVE_LINUX_TYPES_H 1
|
||||||
|
#define HAVE_LINUX_XATTR_H 1
|
||||||
|
#define HAVE_MNTENT_H 1
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
#define HAVE_SYS_IOCTL_H 1
|
||||||
|
#define HAVE_SYS_SYSCALL_H 1
|
||||||
|
#define HAVE_SYS_MOUNT_H 1
|
||||||
|
#define HAVE_SYS_SYSMACROS_H 1
|
||||||
|
#define HAVE_SYS_XATTR_H 1
|
||||||
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
#define HAVE_ADD_KEY 1
|
||||||
|
#define HAVE_FALLOCATE 1
|
||||||
|
#define HAVE_FSETXATTR 1
|
||||||
|
#define HAVE_FSTAT 1
|
||||||
|
#define HAVE_FSTAT64 1
|
||||||
|
#define HAVE_GETMNTENT 1
|
||||||
|
#define HAVE_KEYCTL 1
|
||||||
|
#define HAVE_LLSEEK 1
|
||||||
|
#define HAVE_LSEEK64 1
|
||||||
|
#define HAVE_MEMSET 1
|
||||||
|
#define HAVE_SETMNTENT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#define HAVE_FCNTL_H 1
|
||||||
|
#define HAVE_FALLOC_H 1
|
||||||
|
#define HAVE_POSIX_ACL_H 1
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
#define HAVE_SYS_IOCTL_H 1
|
||||||
|
#define HAVE_SYS_SYSCALL_H 1
|
||||||
|
#define HAVE_SYS_MOUNT_H 1
|
||||||
|
#define HAVE_SYS_XATTR_H 1
|
||||||
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
#define HAVE_ADD_KEY 1
|
||||||
|
#define HAVE_FALLOCATE 1
|
||||||
|
#define HAVE_FSETXATTR 1
|
||||||
|
#define HAVE_FSTAT 1
|
||||||
|
#define HAVE_FSTAT64 1
|
||||||
|
#define HAVE_GETMNTENT 1
|
||||||
|
#define HAVE_KEYCTL 1
|
||||||
|
#define HAVE_LLSEEK 1
|
||||||
|
#define HAVE_MEMSET 1
|
||||||
|
#endif
|
@ -12,14 +12,20 @@
|
|||||||
#ifndef __F2FS_FS_H__
|
#ifndef __F2FS_FS_H__
|
||||||
#define __F2FS_FS_H__
|
#define __F2FS_FS_H__
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <linux/types.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WITH_ANDROID
|
||||||
|
#include <android_config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#ifdef HAVE_LINUX_TYPES_H
|
||||||
|
#include <linux/types.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_BLKZONED_H
|
#ifdef HAVE_LINUX_BLKZONED_H
|
||||||
#include <linux/blkzoned.h>
|
#include <linux/blkzoned.h>
|
||||||
#endif
|
#endif
|
||||||
@ -39,10 +45,25 @@ typedef u_int16_t u16;
|
|||||||
typedef u_int8_t u8;
|
typedef u_int8_t u8;
|
||||||
typedef u32 block_t;
|
typedef u32 block_t;
|
||||||
typedef u32 nid_t;
|
typedef u32 nid_t;
|
||||||
|
#ifndef bool
|
||||||
typedef u8 bool;
|
typedef u8 bool;
|
||||||
|
#endif
|
||||||
typedef unsigned long pgoff_t;
|
typedef unsigned long pgoff_t;
|
||||||
typedef unsigned short umode_t;
|
typedef unsigned short umode_t;
|
||||||
|
|
||||||
|
#ifndef HAVE_LINUX_TYPES_H
|
||||||
|
typedef u8 __u8;
|
||||||
|
typedef u16 __u16;
|
||||||
|
typedef u32 __u32;
|
||||||
|
typedef u64 __u64;
|
||||||
|
typedef u16 __le16;
|
||||||
|
typedef u32 __le32;
|
||||||
|
typedef u64 __le64;
|
||||||
|
typedef u16 __be16;
|
||||||
|
typedef u32 __be32;
|
||||||
|
typedef u64 __be64;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_BYTESWAP_H
|
#if HAVE_BYTESWAP_H
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
#else
|
#else
|
||||||
@ -226,7 +247,9 @@ static inline uint64_t bswap_64(uint64_t val)
|
|||||||
snprintf(buf, len, #member)
|
snprintf(buf, len, #member)
|
||||||
|
|
||||||
/* these are defined in kernel */
|
/* these are defined in kernel */
|
||||||
|
#ifndef PAGE_SIZE
|
||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
|
#endif
|
||||||
#define PAGE_CACHE_SIZE 4096
|
#define PAGE_CACHE_SIZE 4096
|
||||||
#define BITS_PER_BYTE 8
|
#define BITS_PER_BYTE 8
|
||||||
#define F2FS_SUPER_MAGIC 0xF2F52010 /* F2FS Magic Number */
|
#define F2FS_SUPER_MAGIC 0xF2F52010 /* F2FS Magic Number */
|
||||||
@ -784,7 +807,7 @@ struct f2fs_nat_block {
|
|||||||
* disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments.
|
* disk is 16 TB and it equals to 16 * 1024 * 1024 / 2 segments.
|
||||||
*/
|
*/
|
||||||
#define F2FS_MAX_SEGMENT ((16 * 1024 * 1024) / 2)
|
#define F2FS_MAX_SEGMENT ((16 * 1024 * 1024) / 2)
|
||||||
#define MAX_SIT_BITMAP_SIZE (SEG_ALIGN(ALIGN(F2FS_MAX_SEGMENT, \
|
#define MAX_SIT_BITMAP_SIZE (SEG_ALIGN(SIZE_ALIGN(F2FS_MAX_SEGMENT, \
|
||||||
SIT_ENTRY_PER_BLOCK)) * \
|
SIT_ENTRY_PER_BLOCK)) * \
|
||||||
c.blks_per_seg / 8)
|
c.blks_per_seg / 8)
|
||||||
|
|
||||||
@ -1146,9 +1169,9 @@ extern int f2fs_reset_zones(int);
|
|||||||
|
|
||||||
extern struct f2fs_configuration c;
|
extern struct f2fs_configuration c;
|
||||||
|
|
||||||
#define ALIGN(val, size) ((val) + (size) - 1) / (size)
|
#define SIZE_ALIGN(val, size) ((val) + (size) - 1) / (size)
|
||||||
#define SEG_ALIGN(blks) ALIGN(blks, c.blks_per_seg)
|
#define SEG_ALIGN(blks) SIZE_ALIGN(blks, c.blks_per_seg)
|
||||||
#define ZONE_ALIGN(blks) ALIGN(blks, c.blks_per_seg * \
|
#define ZONE_ALIGN(blks) SIZE_ALIGN(blks, c.blks_per_seg * \
|
||||||
c.segs_per_zone)
|
c.segs_per_zone)
|
||||||
|
|
||||||
static inline double get_best_overprovision(struct f2fs_super_block *sb)
|
static inline double get_best_overprovision(struct f2fs_super_block *sb)
|
||||||
|
@ -8,25 +8,34 @@
|
|||||||
*/
|
*/
|
||||||
#define _LARGEFILE64_SOURCE
|
#define _LARGEFILE64_SOURCE
|
||||||
|
|
||||||
|
#include <f2fs_fs.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#ifdef HAVE_MNTENT_H
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#ifdef HAVE_SYS_SYSMACROS_H
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
|
#endif
|
||||||
#ifndef WITH_ANDROID
|
#ifndef WITH_ANDROID
|
||||||
|
#ifdef HAVE_SCSI_SG_H
|
||||||
#include <scsi/sg.h>
|
#include <scsi/sg.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LINUX_HDREG_H
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LINUX_LIMITS_H
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
#endif
|
||||||
#include <f2fs_fs.h>
|
|
||||||
|
|
||||||
#ifndef WITH_ANDROID
|
#ifndef WITH_ANDROID
|
||||||
/* SCSI command for standard inquiry*/
|
/* SCSI command for standard inquiry*/
|
||||||
@ -607,6 +616,7 @@ void f2fs_init_configuration(void)
|
|||||||
c.dry_run = 0;
|
c.dry_run = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SETMNTENT
|
||||||
static int is_mounted(const char *mpt, const char *device)
|
static int is_mounted(const char *mpt, const char *device)
|
||||||
{
|
{
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
@ -628,6 +638,7 @@ static int is_mounted(const char *mpt, const char *device)
|
|||||||
endmntent(file);
|
endmntent(file);
|
||||||
return mnt ? 1 : 0;
|
return mnt ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int f2fs_dev_is_umounted(char *path)
|
int f2fs_dev_is_umounted(char *path)
|
||||||
{
|
{
|
||||||
@ -642,29 +653,36 @@ int f2fs_dev_is_umounted(char *path)
|
|||||||
* try with /proc/mounts fist to detect RDONLY.
|
* try with /proc/mounts fist to detect RDONLY.
|
||||||
* f2fs_stop_checkpoint makes RO in /proc/mounts while RW in /etc/mtab.
|
* f2fs_stop_checkpoint makes RO in /proc/mounts while RW in /etc/mtab.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __linux__
|
||||||
ret = is_mounted("/proc/mounts", path);
|
ret = is_mounted("/proc/mounts", path);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
MSG(0, "Info: Mounted device!\n");
|
MSG(0, "Info: Mounted device!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(MOUNTED) || defined(_PATH_MOUNTED)
|
||||||
|
#ifndef MOUNTED
|
||||||
|
#define MOUNTED _PATH_MOUNTED
|
||||||
|
#endif
|
||||||
ret = is_mounted(MOUNTED, path);
|
ret = is_mounted(MOUNTED, path);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
MSG(0, "Info: Mounted device!\n");
|
MSG(0, "Info: Mounted device!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* If we are supposed to operate on the root device, then
|
* If we are supposed to operate on the root device, then
|
||||||
* also check the mounts for '/dev/root', which sometimes
|
* also check the mounts for '/dev/root', which sometimes
|
||||||
* functions as an alias for the root device.
|
* functions as an alias for the root device.
|
||||||
*/
|
*/
|
||||||
if (is_rootdev) {
|
if (is_rootdev) {
|
||||||
|
#ifdef __linux__
|
||||||
ret = is_mounted("/proc/mounts", "/dev/root");
|
ret = is_mounted("/proc/mounts", "/dev/root");
|
||||||
if (ret) {
|
if (ret) {
|
||||||
MSG(0, "Info: Mounted device!\n");
|
MSG(0, "Info: Mounted device!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -681,7 +699,7 @@ int f2fs_dev_is_umounted(char *path)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int f2fs_devs_are_umounted(void)
|
int f2fs_devs_are_umounted(void)
|
||||||
@ -704,6 +722,25 @@ void get_kernel_version(__u8 *version)
|
|||||||
memset(version + i, 0, VERSION_LEN + 1 - i);
|
memset(version + i, 0, VERSION_LEN + 1 - i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__linux__) && defined(_IO) && !defined(BLKGETSIZE)
|
||||||
|
#define BLKGETSIZE _IO(0x12,96)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__) && defined(_IOR) && !defined(BLKGETSIZE64)
|
||||||
|
#define BLKGETSIZE64 _IOR(0x12,114, size_t)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__) && defined(_IO) && !defined(BLKSSZGET)
|
||||||
|
#define BLKSSZGET _IO(0x12,104)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <sys/disk.h>
|
||||||
|
#define BLKGETSIZE DKIOCGETBLOCKCOUNT
|
||||||
|
#define BLKSSZGET DKIOCGETBLOCKCOUNT
|
||||||
|
#endif /* APPLE_DARWIN */
|
||||||
|
|
||||||
int get_device_info(int i)
|
int get_device_info(int i)
|
||||||
{
|
{
|
||||||
int32_t fd = 0;
|
int32_t fd = 0;
|
||||||
@ -712,8 +749,10 @@ int get_device_info(int i)
|
|||||||
uint32_t total_sectors;
|
uint32_t total_sectors;
|
||||||
#endif
|
#endif
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
|
#ifdef HDIO_GETGIO
|
||||||
struct hd_geometry geom;
|
struct hd_geometry geom;
|
||||||
#ifndef WITH_ANDROID
|
#endif
|
||||||
|
#if !defined(WITH_ANDROID) && defined(__linux__)
|
||||||
sg_io_hdr_t io_hdr;
|
sg_io_hdr_t io_hdr;
|
||||||
unsigned char reply_buffer[96] = {0};
|
unsigned char reply_buffer[96] = {0};
|
||||||
unsigned char model_inq[6] = {MODELINQUIRY};
|
unsigned char model_inq[6] = {MODELINQUIRY};
|
||||||
@ -750,10 +789,12 @@ int get_device_info(int i)
|
|||||||
} else if (S_ISREG(stat_buf.st_mode)) {
|
} else if (S_ISREG(stat_buf.st_mode)) {
|
||||||
dev->total_sectors = stat_buf.st_size / dev->sector_size;
|
dev->total_sectors = stat_buf.st_size / dev->sector_size;
|
||||||
} else if (S_ISBLK(stat_buf.st_mode)) {
|
} else if (S_ISBLK(stat_buf.st_mode)) {
|
||||||
|
#ifdef BLKSSZGET
|
||||||
if (ioctl(fd, BLKSSZGET, §or_size) < 0)
|
if (ioctl(fd, BLKSSZGET, §or_size) < 0)
|
||||||
MSG(0, "\tError: Using the default sector size\n");
|
MSG(0, "\tError: Using the default sector size\n");
|
||||||
else if (dev->sector_size < sector_size)
|
else if (dev->sector_size < sector_size)
|
||||||
dev->sector_size = sector_size;
|
dev->sector_size = sector_size;
|
||||||
|
#endif
|
||||||
#ifdef BLKGETSIZE64
|
#ifdef BLKGETSIZE64
|
||||||
if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {
|
if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) {
|
||||||
MSG(0, "\tError: Cannot get the device size\n");
|
MSG(0, "\tError: Cannot get the device size\n");
|
||||||
@ -769,13 +810,17 @@ int get_device_info(int i)
|
|||||||
dev->total_sectors /= dev->sector_size;
|
dev->total_sectors /= dev->sector_size;
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
|
#ifdef HDIO_GETGIO
|
||||||
if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
|
if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
|
||||||
c.start_sector = 0;
|
c.start_sector = 0;
|
||||||
else
|
else
|
||||||
c.start_sector = geom.start;
|
c.start_sector = geom.start;
|
||||||
|
#else
|
||||||
|
c.start_sector = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WITH_ANDROID
|
#if !defined(WITH_ANDROID) && defined(__linux__)
|
||||||
/* Send INQUIRY command */
|
/* Send INQUIRY command */
|
||||||
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
|
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
|
||||||
io_hdr.interface_id = 'S';
|
io_hdr.interface_id = 'S';
|
||||||
@ -809,7 +854,7 @@ int get_device_info(int i)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WITH_ANDROID
|
#if !defined(WITH_ANDROID) && defined(__linux__)
|
||||||
if (S_ISBLK(stat_buf.st_mode))
|
if (S_ISBLK(stat_buf.st_mode))
|
||||||
f2fs_get_zoned_model(i);
|
f2fs_get_zoned_model(i);
|
||||||
|
|
||||||
|
@ -14,12 +14,16 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#ifdef HAVE_MNTENT_H
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#ifdef HAVE_LINUX_HDREG_H
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <f2fs_fs.h>
|
#include <f2fs_fs.h>
|
||||||
|
|
||||||
@ -54,6 +58,15 @@ static int __get_device_fd(__u64 *offset)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_LSEEK64
|
||||||
|
typedef off_t off64_t;
|
||||||
|
|
||||||
|
static inline off64_t lseek64(int fd, __u64 offset, int set)
|
||||||
|
{
|
||||||
|
return lseek(fd, offset, set);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IO interfaces
|
* IO interfaces
|
||||||
*/
|
*/
|
||||||
@ -86,7 +99,11 @@ int dev_read(void *buf, __u64 offset, size_t len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POSIX_FADV_WILLNEED
|
||||||
int dev_readahead(__u64 offset, size_t len)
|
int dev_readahead(__u64 offset, size_t len)
|
||||||
|
#else
|
||||||
|
int dev_readahead(__u64 offset, size_t UNUSED(len))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
int fd = __get_device_fd(&offset);
|
int fd = __get_device_fd(&offset);
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ static int f2fs_prepare_super_block(void)
|
|||||||
set_sb(sit_blkaddr, get_sb(segment0_blkaddr) +
|
set_sb(sit_blkaddr, get_sb(segment0_blkaddr) +
|
||||||
get_sb(segment_count_ckpt) * c.blks_per_seg);
|
get_sb(segment_count_ckpt) * c.blks_per_seg);
|
||||||
|
|
||||||
blocks_for_sit = ALIGN(get_sb(segment_count), SIT_ENTRY_PER_BLOCK);
|
blocks_for_sit = SIZE_ALIGN(get_sb(segment_count), SIT_ENTRY_PER_BLOCK);
|
||||||
|
|
||||||
sit_segments = SEG_ALIGN(blocks_for_sit);
|
sit_segments = SEG_ALIGN(blocks_for_sit);
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ static int f2fs_prepare_super_block(void)
|
|||||||
(get_sb(segment_count_ckpt) +
|
(get_sb(segment_count_ckpt) +
|
||||||
get_sb(segment_count_sit))) * c.blks_per_seg;
|
get_sb(segment_count_sit))) * c.blks_per_seg;
|
||||||
|
|
||||||
blocks_for_nat = ALIGN(total_valid_blks_available,
|
blocks_for_nat = SIZE_ALIGN(total_valid_blks_available,
|
||||||
NAT_ENTRY_PER_BLOCK);
|
NAT_ENTRY_PER_BLOCK);
|
||||||
|
|
||||||
set_sb(segment_count_nat, SEG_ALIGN(blocks_for_nat));
|
set_sb(segment_count_nat, SEG_ALIGN(blocks_for_nat));
|
||||||
|
@ -6,20 +6,24 @@
|
|||||||
*
|
*
|
||||||
* Dual licensed under the GPL or LGPL version 2 licenses.
|
* Dual licensed under the GPL or LGPL version 2 licenses.
|
||||||
*/
|
*/
|
||||||
|
#ifndef _LARGEFILE_SOURCE
|
||||||
#define _LARGEFILE_SOURCE
|
#define _LARGEFILE_SOURCE
|
||||||
|
#endif
|
||||||
|
#ifndef _LARGEFILE64_SOURCE
|
||||||
#define _LARGEFILE64_SOURCE
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <f2fs_fs.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "f2fs_fs.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_FS_H
|
#ifdef HAVE_LINUX_FS_H
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#endif
|
#endif
|
||||||
@ -68,7 +72,7 @@ static int trim_device(int i)
|
|||||||
MSG(0, "Info: This device doesn't support BLKSECDISCARD\n");
|
MSG(0, "Info: This device doesn't support BLKSECDISCARD\n");
|
||||||
} else {
|
} else {
|
||||||
MSG(0, "Info: Secure Discarded %lu MB\n",
|
MSG(0, "Info: Secure Discarded %lu MB\n",
|
||||||
stat_buf.st_size >> 20);
|
(unsigned long)stat_buf.st_size >> 20);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include
|
AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include
|
||||||
AM_CFLAGS = -Wall
|
AM_CFLAGS = -Wall
|
||||||
sbin_PROGRAMS = f2fstat fibmap.f2fs parse.f2fs f2fscrypt
|
sbin_PROGRAMS = f2fstat fibmap.f2fs parse.f2fs
|
||||||
f2fstat_SOURCES = f2fstat.c
|
f2fstat_SOURCES = f2fstat.c
|
||||||
fibmap_f2fs_SOURCES = fibmap.c
|
fibmap_f2fs_SOURCES = fibmap.c
|
||||||
parse_f2fs_SOURCES = f2fs_io_parse.c
|
parse_f2fs_SOURCES = f2fs_io_parse.c
|
||||||
|
|
||||||
|
if LINUX
|
||||||
|
sbin_PROGRAMS += f2fscrypt
|
||||||
f2fscrypt_SOURCES = f2fscrypt.c sha512.c
|
f2fscrypt_SOURCES = f2fscrypt.c sha512.c
|
||||||
f2fscrypt_LDFLAGS = -luuid
|
f2fscrypt_LDFLAGS = -luuid
|
||||||
dist_man_MANS = f2fscrypt.8
|
dist_man_MANS = f2fscrypt.8
|
||||||
|
endif
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_MNTENT_H
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#endif
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -38,7 +40,9 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#ifdef __KERNEL__
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
#endif
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
|
|
||||||
#if !defined(HAVE_ADD_KEY) || !defined(HAVE_KEYCTL)
|
#if !defined(HAVE_ADD_KEY) || !defined(HAVE_KEYCTL)
|
||||||
@ -47,6 +51,7 @@
|
|||||||
#ifdef HAVE_SYS_KEY_H
|
#ifdef HAVE_SYS_KEY_H
|
||||||
#include <sys/key.h>
|
#include <sys/key.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <f2fs_fs.h>
|
||||||
|
|
||||||
#define F2FS_MAX_KEY_SIZE 64
|
#define F2FS_MAX_KEY_SIZE 64
|
||||||
#define F2FS_MAX_PASSPHRASE_SIZE 1024
|
#define F2FS_MAX_PASSPHRASE_SIZE 1024
|
||||||
@ -121,7 +126,7 @@ int options;
|
|||||||
extern void f2fs_sha512(const unsigned char *in, unsigned long in_size,
|
extern void f2fs_sha512(const unsigned char *in, unsigned long in_size,
|
||||||
unsigned char *out);
|
unsigned char *out);
|
||||||
|
|
||||||
#ifndef HAVE_KEYCTL
|
#if !defined(HAVE_KEYCTL)
|
||||||
static long keyctl(int cmd, ...)
|
static long keyctl(int cmd, ...)
|
||||||
{
|
{
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -137,7 +142,7 @@ static long keyctl(int cmd, ...)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_ADD_KEY
|
#if !defined(HAVE_ADD_KEY)
|
||||||
static key_serial_t add_key(const char *type, const char *description,
|
static key_serial_t add_key(const char *type, const char *description,
|
||||||
const void *payload, size_t plen,
|
const void *payload, size_t plen,
|
||||||
key_serial_t keyring)
|
key_serial_t keyring)
|
||||||
|
@ -1,4 +1,20 @@
|
|||||||
|
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||||
|
#define _XOPEN_SOURCE 600
|
||||||
|
#define _DARWIN_C_SOURCE
|
||||||
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
#ifndef _LARGEFILE_SOURCE
|
||||||
|
#define _LARGEFILE_SOURCE
|
||||||
|
#endif
|
||||||
|
#ifndef _LARGEFILE64_SOURCE
|
||||||
#define _LARGEFILE64_SOURCE
|
#define _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef O_LARGEFILE
|
||||||
|
#define O_LARGEFILE 0
|
||||||
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -8,12 +24,25 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#ifdef HAVE_SYS_SYSMACROS_H
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
|
#endif
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#ifdef HAVE_LINUX_HDREG_H
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LINUX_TYPES_H
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef __KERNEL__
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
#endif
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <f2fs_fs.h>
|
||||||
|
|
||||||
|
#ifndef FIBMAP
|
||||||
|
#define FIBMAP _IO(0x00, 1) /* bmap access */
|
||||||
|
#endif
|
||||||
|
|
||||||
struct file_ext {
|
struct file_ext {
|
||||||
__u32 f_pos;
|
__u32 f_pos;
|
||||||
@ -31,28 +60,42 @@ void print_ext(struct file_ext *ext)
|
|||||||
ext->end_blk, ext->blk_count);
|
ext->end_blk, ext->blk_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||||
void print_stat(struct stat64 *st)
|
void print_stat(struct stat64 *st)
|
||||||
|
#else
|
||||||
|
void print_stat(struct stat *st)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
printf("--------------------------------------------\n");
|
printf("--------------------------------------------\n");
|
||||||
printf("dev [%d:%d]\n", major(st->st_dev), minor(st->st_dev));
|
printf("dev [%d:%d]\n", major(st->st_dev), minor(st->st_dev));
|
||||||
printf("ino [0x%8"PRIx64" : %"PRIu64"]\n",
|
printf("ino [0x%8"PRIx64" : %"PRIu64"]\n",
|
||||||
st->st_ino, st->st_ino);
|
st->st_ino, st->st_ino);
|
||||||
printf("mode [0x%8x : %d]\n", st->st_mode, st->st_mode);
|
printf("mode [0x%8x : %d]\n", st->st_mode, st->st_mode);
|
||||||
printf("nlink [0x%8lx : %ld]\n", st->st_nlink, st->st_nlink);
|
printf("nlink [0x%8lx : %ld]\n",
|
||||||
|
(unsigned long)st->st_nlink,
|
||||||
|
(long)st->st_nlink);
|
||||||
printf("uid [0x%8x : %d]\n", st->st_uid, st->st_uid);
|
printf("uid [0x%8x : %d]\n", st->st_uid, st->st_uid);
|
||||||
printf("gid [0x%8x : %d]\n", st->st_gid, st->st_gid);
|
printf("gid [0x%8x : %d]\n", st->st_gid, st->st_gid);
|
||||||
printf("size [0x%8"PRIx64" : %"PRIu64"]\n",
|
printf("size [0x%8"PRIx64" : %"PRIu64"]\n",
|
||||||
st->st_size, st->st_size);
|
(u64)st->st_size, (u64)st->st_size);
|
||||||
printf("blksize [0x%8lx : %ld]\n", st->st_blksize, st->st_blksize);
|
printf("blksize [0x%8lx : %ld]\n",
|
||||||
|
(unsigned long)st->st_blksize,
|
||||||
|
(long)st->st_blksize);
|
||||||
printf("blocks [0x%8"PRIx64" : %"PRIu64"]\n",
|
printf("blocks [0x%8"PRIx64" : %"PRIu64"]\n",
|
||||||
st->st_blocks, st->st_blocks);
|
(u64)st->st_blocks, (u64)st->st_blocks);
|
||||||
printf("--------------------------------------------\n\n");
|
printf("--------------------------------------------\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void stat_bdev(struct stat64 *st, unsigned int *start_lba)
|
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||||
|
static void stat_bdev(struct stat64 *st, unsigned int *start_lba)
|
||||||
|
#else
|
||||||
|
static void stat_bdev(struct stat *st, unsigned int *start_lba)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
struct stat bdev_stat;
|
struct stat bdev_stat;
|
||||||
|
#ifdef HDIO_GETGIO
|
||||||
struct hd_geometry geom;
|
struct hd_geometry geom;
|
||||||
|
#endif
|
||||||
char devname[32] = { 0, };
|
char devname[32] = { 0, };
|
||||||
char linkname[32] = { 0, };
|
char linkname[32] = { 0, };
|
||||||
int fd;
|
int fd;
|
||||||
@ -67,10 +110,14 @@ void stat_bdev(struct stat64 *st, unsigned int *start_lba)
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (S_ISBLK(bdev_stat.st_mode)) {
|
if (S_ISBLK(bdev_stat.st_mode)) {
|
||||||
|
#ifdef HDIO_GETGIO
|
||||||
if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
|
if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
|
||||||
*start_lba = 0;
|
*start_lba = 0;
|
||||||
else
|
else
|
||||||
*start_lba = geom.start;
|
*start_lba = geom.start;
|
||||||
|
#else
|
||||||
|
*start_lba = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readlink(devname, linkname, sizeof(linkname)) < 0)
|
if (readlink(devname, linkname, sizeof(linkname)) < 0)
|
||||||
@ -90,7 +137,11 @@ int main(int argc, char *argv[])
|
|||||||
int fd;
|
int fd;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||||
struct stat64 st;
|
struct stat64 st;
|
||||||
|
#else
|
||||||
|
struct stat st;
|
||||||
|
#endif
|
||||||
int total_blks;
|
int total_blks;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct file_ext ext;
|
struct file_ext ext;
|
||||||
@ -112,7 +163,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
fsync(fd);
|
fsync(fd);
|
||||||
|
|
||||||
|
#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
|
||||||
if (fstat64(fd, &st) < 0) {
|
if (fstat64(fd, &st) < 0) {
|
||||||
|
#else
|
||||||
|
if (fstat(fd, &st) < 0) {
|
||||||
|
#endif
|
||||||
ret = errno;
|
ret = errno;
|
||||||
perror(filename);
|
perror(filename);
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user