[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] PATCH: daemon mkfs.c Add option "inode" for setting -I flag on mkfs_opts command



Hello,

Patch implements inode option to mkfs_opts command.
This is needed because older versions of grub(for example in centos)
do not understand filesystems created with newer version of e2fsprogs.
By default in e2fsprogs 1.4+ creates partitions with 256 bit inode
size, and grub expect 128 bit size.
Usage:
$ guestfish
><fs> add-drive test.img 1G #for small images by default used 128 bit
><fs> run
><fs> part-disk /dev/vda mbr
><fs> mkfs ext3 /dev/vda1
><fs> tune2fs-l /dev/vda1 | grep "Inode size"
Inode size: 256
><fs> mkfs-opts ext3 /dev/vda1 inode:128
><fs> tune2fs-l /dev/vda1 | grep "Inode size"
Inode size: 128


-- 
Nikita A Menkovich
http://libc6.org/
JID: menkovich gmail com
--- /home/sh/projects/libguestfs-1.10.3/daemon/mkfs.c   2011-03-25 14:39:45.000000000 +0000
+++ daemon/mkfs.c   2011-07-04 08:15:23.000000000 +0000
@@ -33,7 +33,7 @@
 
 /* Takes optional arguments, consult optargs_bitmask. */
 int
-do_mkfs_opts (const char *fstype, const char *device, int blocksize, const char *features)
+do_mkfs_opts (const char *fstype, const char *device, int blocksize, const char *features, const char *inode)
 {
   const char *argv[MAX_ARGS];
   size_t i = 0;
@@ -140,6 +140,15 @@
      argv[i++] = features;
   }
 
+  if (optargs_bitmask & GUESTFS_MKFS_OPTS_INODE_BITMASK) {
+    if (STREQ (fstype, "ext2") || STREQ (fstype, "ext3") || STREQ (fstype, "ext4")) {
+     argv[i++] = "-I";
+     argv[i++] = inode;
+    } else {
+      reply_with_error ("inode flag -I could be set only on ext filesystems");
+      return -1;
+    }
+  }
   argv[i++] = device;
   argv[i++] = NULL;
 
@@ -161,12 +170,12 @@
 do_mkfs (const char *fstype, const char *device)
 {
   optargs_bitmask = 0;
-  return do_mkfs_opts (fstype, device, 0, 0);
+  return do_mkfs_opts (fstype, device, 0, 0, 256);
 }
 
 int
 do_mkfs_b (const char *fstype, int blocksize, const char *device)
 {
   optargs_bitmask = GUESTFS_MKFS_OPTS_BLOCKSIZE_BITMASK;
-  return do_mkfs_opts (fstype, device, blocksize, 0);
+  return do_mkfs_opts (fstype, device, blocksize, 0, 256);
 }
--- /home/sh/projects/libguestfs-1.10.3/generator/generator_actions.ml  2011-05-18 10:40:31.000000000 +0000
+++ generator/generator_actions.ml  2011-07-04 07:44:51.000000000 +0000
@@ -5831,10 +5831,10 @@
 
 See also C<guestfs_is_lv>.");
 
-  ("mkfs_opts", (RErr, [String "fstype"; Device "device"], [Int "blocksize"; String "features"]), 278, [],
+  ("mkfs_opts", (RErr, [String "fstype"; Device "device"], [Int "blocksize"; String "features"; String "inode"]), 278, [],
    [InitEmpty, Always, TestOutput (
       [["part_disk"; "/dev/sda"; "mbr"];
-       ["mkfs_opts"; "ext2"; "/dev/sda1"; "4096"; ""];
+       ["mkfs_opts"; "ext2"; "/dev/sda1"; "4096"; ""; "256"];
        ["mount_options"; ""; "/dev/sda1"; "/"];
        ["write"; "/new"; "new file contents"];
        ["cat"; "/new"]], "new file contents")],
@@ -5869,6 +5869,14 @@
 You cannot use this optional parameter with the C<gfs> or
 C<gfs2> filesystem type.
 
+=item C<inode>
+
+
+This passes the I<-I> parameter to the external mkfs program.
+
+For certain filesystem types, this allows to set up inode
+size.  See L<mke2fs(8)> for more details.
+
 =back");
 
   ("getxattr", (RBufferOut "xattr", [Pathname "path"; String "name"], []), 279, [Optional "linuxxattrs"],

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]