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

[Libguestfs] Patch that implements support to create UFS1 partitions with mkfs-opts



In attach.
Usage:
> mkfs-opts ufs /dev/vda1 features:1
Creates UFS1 partition
> mkfs-opts ufs /dev/vda1 features:2
Creates UFS2 partition.
-- 
Nikita A Menkovich
JID: menkovich gmail com
Tel: +7 (921) 423-96-48
0223a16a734e589568d685075f0bccfa30d Mon Sep 17 00:00:00 2001
From: Nikita Menkovich <menkovich gmail com>
Date: Wed, 26 Jan 2011 14:50:12 +0000
Subject: mkfs-opts: Allows to set UFS partition type.

---
diff --git a/daemon/mkfs.c b/daemon/mkfs.c
index cc0ead1..46eb13e 100644
--- a/daemon/mkfs.c
+++ b/daemon/mkfs.c
@@ -33,7 +33,7 @@
 
 /* Takes optional arguments, consult optargs_bitmask. */
 int
-do_mkfs_opts (const char *fstype, const char *device, int blocksize)
+do_mkfs_opts (const char *fstype, const char *device, int blocksize, const char *features)
 {
   const char *argv[MAX_ARGS];
   size_t i = 0;
@@ -115,6 +115,13 @@ do_mkfs_opts (const char *fstype, const char *device, int blocksize)
     }
   }
 
+  if (optargs_bitmask & GUESTFS_MKFS_OPTS_FEATURES_BITMASK) {
+     if (STREQ (fstype, "ufs")) {
+       argv[i++] = "-O";
+       argv[i++] = features;
+     }
+  }
+
   argv[i++] = device;
   argv[i++] = NULL;
 
@@ -136,12 +143,12 @@ int
 do_mkfs (const char *fstype, const char *device)
 {
   optargs_bitmask = 0;
-  return do_mkfs_opts (fstype, device, 0);
+  return do_mkfs_opts (fstype, device, 0, 0);
 }
 
 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);
+  return do_mkfs_opts (fstype, device, blocksize, 0);
 }
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 7cb8c1e..cec30cc 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -5683,10 +5683,10 @@ not refer to a logical volume.
 
 See also C<guestfs_is_lv>.");
 
-  ("mkfs_opts", (RErr, [String "fstype"; Device "device"], [Int "blocksize"]), 278, [],
+  ("mkfs_opts", (RErr, [String "fstype"; Device "device"], [Int "blocksize"; String "features"]), 278, [],
    [InitEmpty, Always, TestOutput (
       [["part_disk"; "/dev/sda"; "mbr"];
-       ["mkfs_opts"; "ext2"; "/dev/sda1"; "4096"];
+       ["mkfs_opts"; "ext2"; "/dev/sda1"; "4096"; ""];
        ["mount_options"; ""; "/dev/sda1"; "/"];
        ["write"; "/new"; "new file contents"];
        ["cat"; "/new"]], "new file contents")],
@@ -5705,9 +5705,16 @@ The filesystem block size.  Supported block sizes depend on the
 filesystem type, but typically they are C<1024>, C<2048> or C<4096>
 for Linux ext2/3 filesystems.
 
+For UFS the C<blocksize> parameter by default is C<16384>, minimal is C<4096>. 
+
 For VFAT and NTFS the C<blocksize> parameter is treated as
 the requested cluster size.
 
+=item C<features>
+
+For UFS specififying C<features> parameter allows to change default type of UFS 
+for example: features:1 creates UFS1 partition
+
 =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]