aboutsummaryrefslogtreecommitdiffstats
path: root/libinstaller
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-06-16 11:44:27 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-06-16 11:44:27 -0700
commit51735fc532ba1ed079a30ba9734936bf2670c87b (patch)
tree67ef80d1c9dc632266bff968b2120b11c96ca14e /libinstaller
parent76d5e47c0ddec4f5d792d8753056ab46e5fc9e8c (diff)
downloadsyslinux-51735fc532ba1ed079a30ba9734936bf2670c87b.tar.gz
syslinux-51735fc532ba1ed079a30ba9734936bf2670c87b.tar.xz
syslinux-51735fc532ba1ed079a30ba9734936bf2670c87b.zip
Move Linux ioctl header magic into a single file
Put all the Linux ioctl header magic into a single shared file, and try to make it as generally useful as possible. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'libinstaller')
-rw-r--r--libinstaller/linux/fiemap.h68
-rw-r--r--libinstaller/linuxioctl.h40
-rw-r--r--libinstaller/syslxcom.c15
3 files changed, 109 insertions, 14 deletions
diff --git a/libinstaller/linux/fiemap.h b/libinstaller/linux/fiemap.h
new file mode 100644
index 00000000..d830747f
--- /dev/null
+++ b/libinstaller/linux/fiemap.h
@@ -0,0 +1,68 @@
+/*
+ * FS_IOC_FIEMAP ioctl infrastructure.
+ *
+ * Some portions copyright (C) 2007 Cluster File Systems, Inc
+ *
+ * Authors: Mark Fasheh <mfasheh@suse.com>
+ * Kalpak Shah <kalpak.shah@sun.com>
+ * Andreas Dilger <adilger@sun.com>
+ */
+
+#ifndef _LINUX_FIEMAP_H
+#define _LINUX_FIEMAP_H
+
+#include <linux/types.h>
+
+struct fiemap_extent {
+ __u64 fe_logical; /* logical offset in bytes for the start of
+ * the extent from the beginning of the file */
+ __u64 fe_physical; /* physical offset in bytes for the start
+ * of the extent from the beginning of the disk */
+ __u64 fe_length; /* length in bytes for this extent */
+ __u64 fe_reserved64[2];
+ __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */
+ __u32 fe_reserved[3];
+};
+
+struct fiemap {
+ __u64 fm_start; /* logical offset (inclusive) at
+ * which to start mapping (in) */
+ __u64 fm_length; /* logical length of mapping which
+ * userspace wants (in) */
+ __u32 fm_flags; /* FIEMAP_FLAG_* flags for request (in/out) */
+ __u32 fm_mapped_extents;/* number of extents that were mapped (out) */
+ __u32 fm_extent_count; /* size of fm_extents array (in) */
+ __u32 fm_reserved;
+ struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
+};
+
+#define FIEMAP_MAX_OFFSET (~0ULL)
+
+#define FIEMAP_FLAG_SYNC 0x00000001 /* sync file data before map */
+#define FIEMAP_FLAG_XATTR 0x00000002 /* map extended attribute tree */
+
+#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
+
+#define FIEMAP_EXTENT_LAST 0x00000001 /* Last extent in file. */
+#define FIEMAP_EXTENT_UNKNOWN 0x00000002 /* Data location unknown. */
+#define FIEMAP_EXTENT_DELALLOC 0x00000004 /* Location still pending.
+ * Sets EXTENT_UNKNOWN. */
+#define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read
+ * while fs is unmounted */
+#define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs.
+ * Sets EXTENT_NO_BYPASS. */
+#define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be
+ * block aligned. */
+#define FIEMAP_EXTENT_DATA_INLINE 0x00000200 /* Data mixed with metadata.
+ * Sets EXTENT_NOT_ALIGNED.*/
+#define FIEMAP_EXTENT_DATA_TAIL 0x00000400 /* Multiple files in block.
+ * Sets EXTENT_NOT_ALIGNED.*/
+#define FIEMAP_EXTENT_UNWRITTEN 0x00000800 /* Space allocated, but
+ * no data (i.e. zero). */
+#define FIEMAP_EXTENT_MERGED 0x00001000 /* File does not natively
+ * support extents. Result
+ * merged for efficiency. */
+#define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other
+ * files. */
+
+#endif /* _LINUX_FIEMAP_H */
diff --git a/libinstaller/linuxioctl.h b/libinstaller/linuxioctl.h
new file mode 100644
index 00000000..e4284df7
--- /dev/null
+++ b/libinstaller/linuxioctl.h
@@ -0,0 +1,40 @@
+/*
+ * linuxioctl.h
+ *
+ * Wrapper for Linux ioctl definitions, including workarounds
+ */
+
+#ifndef LIBINSTALLER_LINUXIOCTL_H
+#define LIBINSTALLER_LINUXIOCTL_H
+
+#include <sys/ioctl.h>
+
+#define statfs _kernel_statfs /* HACK to deal with broken 2.4 distros */
+
+#include <linux/fd.h> /* Floppy geometry */
+#include <linux/hdreg.h> /* Hard disk geometry */
+
+#include <linux/fs.h> /* FIGETBSZ, FIBMAP, FS_IOC_FIEMAP */
+#include <linux/msdos_fs.h> /* FAT_IOCTL_SET_ATTRIBUTES */
+
+#undef SECTOR_SIZE /* Defined in msdos_fs.h for no good reason */
+#undef SECTOR_BITS
+#include <linux/ext2_fs.h> /* EXT2_IOC_* */
+
+#ifndef FAT_IOCTL_GET_ATTRIBUTES
+# define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
+#endif
+
+#ifndef FAT_IOCTL_SET_ATTRIBUTES
+# define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
+#endif
+
+#include <linux/fiemap.h> /* FIEMAP definitions */
+
+#ifndef FS_IOC_FIEMAP
+# define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
+#endif
+
+#undef statfs
+
+#endif /* LIBINSTALLER_LINUXIOCTL_H */
diff --git a/libinstaller/syslxcom.c b/libinstaller/syslxcom.c
index 85b3f6ea..b176f6d7 100644
--- a/libinstaller/syslxcom.c
+++ b/libinstaller/syslxcom.c
@@ -26,15 +26,11 @@
#include <getopt.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <sys/vfs.h>
-#include <linux/fs.h> /* FIGETBSZ, FIBMAP */
-#include <linux/msdos_fs.h> /* FAT_IOCTL_SET_ATTRIBUTES */
-#undef SECTOR_SIZE /* Defined in msdos_fs.h for no good reason */
-#include <linux/fiemap.h> /* FIEMAP definitions */
+#include "linuxioctl.h"
#include "syslxcom.h"
const char *program;
@@ -48,15 +44,6 @@ int fs_type;
#endif
#define SECTOR_SHIFT 9
-#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
-
-/*
- * ioctl commands
- */
-#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
-#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
-#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
-#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
static void die(const char *msg)
{