Rename "hammer expand" to "hammer volume-add"
authorMichael Neumann <mneumann@ntecs.de>
Wed, 9 Dec 2009 22:34:18 +0000 (23:34 +0100)
committerMichael Neumann <mneumann@ntecs.de>
Wed, 9 Dec 2009 22:34:18 +0000 (23:34 +0100)
Also rename the ioctl interface function accordingly.

NOTE:

  hammer expand fs device

changed to:

  hammer volume-add device fs

12 files changed:
sbin/hammer/Makefile
sbin/hammer/cmd_volume.c [moved from sbin/hammer/cmd_expand.c with 77% similarity]
sbin/hammer/hammer.8
sbin/hammer/hammer.c
sbin/hammer/hammer.h
sys/conf/files
sys/sys/priv.h
sys/vfs/hammer/Makefile
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_ioctl.c
sys/vfs/hammer/hammer_ioctl.h
sys/vfs/hammer/hammer_volume.c [moved from sys/vfs/hammer/hammer_expand.c with 96% similarity]

index ee17982..098349a 100644 (file)
@@ -7,7 +7,7 @@ SRCS=   hammer.c ondisk.c blockmap.c cache.c misc.c cycle.c \
        cmd_blockmap.c cmd_reblock.c cmd_rebalance.c \
        cmd_synctid.c cmd_stats.c \
        cmd_pseudofs.c cmd_snapshot.c cmd_mirror.c cmd_status.c \
-       cmd_cleanup.c cmd_info.c cmd_version.c cmd_expand.c \
+       cmd_cleanup.c cmd_info.c cmd_version.c cmd_volume.c \
        cmd_config.c
 MAN=   hammer.8
 
similarity index 77%
rename from sbin/hammer/cmd_expand.c
rename to sbin/hammer/cmd_volume.c
index c093449..1dbe2c4 100644 (file)
  *
  */
 /*
- * Expand a HAMMER filesystem.
+ * Volume operations:
+ *
+ *   - volume-add: Add new volume to HAMMER filesystem
  */
 
 #include "hammer.h"
 #include <string.h>
 
 static uint64_t check_volume(const char *vol_name);
-static void expand_usage(int exit_code);
+static void volume_add_usage(int exit_code);
 
 /*
- * expand <filesystem> <device>
+ * volume-add <device> <filesystem>
  */
 void
-hammer_cmd_expand(char **av, int ac)
+hammer_cmd_volume_add(char **av, int ac)
 {
-       struct hammer_ioc_expand expand;
+       struct hammer_ioc_volume_add ioc;
        int fd;
 
+       char *device = av[0];
+       char *filesystem = av[1];
+
        if (ac != 2)
-               expand_usage(1);
-        fd = open(av[0], O_RDONLY);
+               volume_add_usage(1);
+        fd = open(filesystem, O_RDONLY);
        if (fd < 0) {
-               fprintf(stderr, "hammer expand: unable to access %s: %s\n",
-                       av[0], strerror(errno));
+               fprintf(stderr, "hammer volume-add: unable to access %s: %s\n",
+                       filesystem, strerror(errno));
                exit(1);
        }
 
        /*
-        * Expansion ioctl
+        * volume-add ioctl
         */
-       bzero(&expand, sizeof(expand));
-       strncpy(expand.device_name, av[1], MAXPATHLEN);
-       expand.vol_size = check_volume(av[1]);
-       expand.boot_area_size = HAMMER_BOOT_NOMBYTES;
-       expand.mem_area_size = HAMMER_MEM_NOMBYTES;
+       bzero(&ioc, sizeof(ioc));
+       strncpy(ioc.device_name, device, MAXPATHLEN);
+       ioc.vol_size = check_volume(device);
+       ioc.boot_area_size = HAMMER_BOOT_NOMBYTES;
+       ioc.mem_area_size = HAMMER_MEM_NOMBYTES;
 
-       if (ioctl(fd, HAMMERIOC_EXPAND, &expand) < 0) {
-               fprintf(stderr, "hammer expand ioctl: %s\n", strerror(errno));
+       if (ioctl(fd, HAMMERIOC_ADD_VOLUME, &ioc) < 0) {
+               fprintf(stderr, "hammer volume-add ioctl: %s\n",
+                       strerror(errno));
                exit(1);
        }
 
@@ -80,9 +86,9 @@ hammer_cmd_expand(char **av, int ac)
 
 static
 void
-expand_usage(int exit_code)
+volume_add_usage(int exit_code)
 {
-       fprintf(stderr, "hammer expand <filesystem> <device>\n");
+       fprintf(stderr, "hammer volume-add <device> <filesystem>\n");
        exit(exit_code);
 }
 
index 7aaa0b8..43edbb1 100644 (file)
@@ -478,8 +478,8 @@ meta-data.
 VERSION 3+)
 Edit the configuration file and reinstall into file system meta-data when done.
 Zero arguments specifies the PFS containing the current directory.
-.\" ==== expand ====
-.It Cm expand Ar filesystem Ar device
+.\" ==== volume-add ====
+.It Cm volume-add Ar device Ar filesystem
 This command will format
 .Ar device
 and add all of its space to
index fd1c1ed..994957b 100644 (file)
@@ -397,8 +397,8 @@ main(int ac, char **av)
                hammer_cmd_set_version(av + 1, ac - 1);
                exit(0);
        }
-       if (strcmp(av[0], "expand") == 0) {
-               hammer_cmd_expand(av + 1, ac - 1);
+       if (strcmp(av[0], "volume-add") == 0) {
+               hammer_cmd_volume_add(av + 1, ac - 1);
                exit(0);
        }
 
@@ -525,7 +525,7 @@ usage(int exit_code)
                                    " [[user@]host:]<filesystem>\n"
                "hammer version <filesystem>\n"
                "hammer version-upgrade <filesystem> <version> [force]\n"
-               "hammer expand <filesystem> <device>\n"
+               "hammer volume-add <device> <filesystem>\n"
        );
 
        fprintf(stderr, "\nHAMMER utility version 3+ commands:\n");
index 2bfb4c2..6a486a7 100644 (file)
@@ -110,7 +110,7 @@ void hammer_cmd_viconfig(char **av, int ac);
 void hammer_cmd_info(void);
 void hammer_cmd_get_version(char **av, int ac);
 void hammer_cmd_set_version(char **av, int ac);
-void hammer_cmd_expand(char **av, int ac);
+void hammer_cmd_volume_add(char **av, int ac);
 
 void hammer_get_cycle(hammer_base_elm_t base, hammer_tid_t *tidp);
 void hammer_set_cycle(hammer_base_elm_t base, hammer_tid_t tid);
index 562d7fd..84328d0 100644 (file)
@@ -1403,7 +1403,7 @@ vfs/devfs/devfs_rules.c           standard
 vfs/hammer/hammer_blockmap.c   optional hammer
 vfs/hammer/hammer_btree.c      optional hammer
 vfs/hammer/hammer_cursor.c     optional hammer
-vfs/hammer/hammer_expand.c     optional hammer
+vfs/hammer/hammer_volume.c     optional hammer
 vfs/hammer/hammer_flusher.c    optional hammer
 vfs/hammer/hammer_freemap.c    optional hammer
 vfs/hammer/hammer_inode.c      optional hammer
index af89cb2..dd38bb4 100644 (file)
  * Hammer privileges.
  */
 #define PRIV_HAMMER_IOCTL      650     /* can hammer_ioctl(). */
-#define PRIV_HAMMER_EXPAND     651     /* can hammer expand. */
+#define PRIV_HAMMER_VOLUME     651     /* HAMMER volume management */
 
 /*
  * Track end of privilege list.
index f40e0dc..2b9d568 100644 (file)
@@ -9,7 +9,7 @@ SRCS=   hammer_vfsops.c hammer_vnops.c hammer_inode.c \
        hammer_blockmap.c hammer_freemap.c hammer_undo.c \
        hammer_reblock.c hammer_rebalance.c \
        hammer_flusher.c hammer_mirror.c \
-       hammer_pfs.c hammer_prune.c hammer_expand.c
+       hammer_pfs.c hammer_prune.c hammer_volume.c
 SRCS+= opt_ktr.h
 
 .include <bsd.kmod.mk>
index 43cd17f..ad82881 100644 (file)
@@ -1241,8 +1241,8 @@ int hammer_ioc_upgrade_pseudofs(hammer_transaction_t trans, hammer_inode_t ip,
                         struct hammer_ioc_pseudofs_rw *pfs);
 int hammer_ioc_wait_pseudofs(hammer_transaction_t trans, hammer_inode_t ip,
                         struct hammer_ioc_pseudofs_rw *pfs);
-int hammer_ioc_expand(hammer_transaction_t trans, hammer_inode_t ip,
-                        struct hammer_ioc_expand *expand);
+int hammer_ioc_volume_add(hammer_transaction_t trans, hammer_inode_t ip,
+                        struct hammer_ioc_volume_add *ioc);
 
 int hammer_signal_check(hammer_mount_t hmp);
 
index 88b3015..3e9660c 100644 (file)
@@ -157,12 +157,12 @@ hammer_ioctl(hammer_inode_t ip, u_long com, caddr_t data, int fflag,
                                            (struct hammer_ioc_version *)data);
                }
                break;
-       case HAMMERIOC_EXPAND:
+       case HAMMERIOC_ADD_VOLUME:
                if (error == 0) {
-                       error = priv_check_cred(cred, PRIV_HAMMER_EXPAND, 0);
+                       error = priv_check_cred(cred, PRIV_HAMMER_VOLUME, 0);
                        if (error == 0)
-                               error = hammer_ioc_expand(&trans, ip,
-                                           (struct hammer_ioc_expand *)data);
+                               error = hammer_ioc_volume_add(&trans, ip,
+                                           (struct hammer_ioc_volume_add *)data);
                }
                break;
        case HAMMERIOC_ADD_SNAPSHOT:
index f4ea80a..951c925 100644 (file)
@@ -335,7 +335,7 @@ struct hammer_ioc_version {
        char                    description[64];
 };
 
-struct hammer_ioc_expand {
+struct hammer_ioc_volume_add {
        struct hammer_ioc_head head;
        char                    device_name[MAXPATHLEN];
        int64_t                 vol_size;
@@ -451,7 +451,7 @@ struct hammer_ioc_config {
 #define HAMMERIOC_SET_VERSION  _IOWR('h',14,struct hammer_ioc_version)
 #define HAMMERIOC_REBALANCE    _IOWR('h',15,struct hammer_ioc_rebalance)
 #define HAMMERIOC_GET_INFO     _IOR('h',16,struct hammer_ioc_info)
-#define HAMMERIOC_EXPAND       _IOWR('h',17,struct hammer_ioc_expand)
+#define HAMMERIOC_ADD_VOLUME   _IOWR('h',17,struct hammer_ioc_volume_add)
 #define HAMMERIOC_ADD_SNAPSHOT _IOWR('h',18,struct hammer_ioc_snapshot)
 #define HAMMERIOC_DEL_SNAPSHOT _IOWR('h',19,struct hammer_ioc_snapshot)
 #define HAMMERIOC_GET_SNAPSHOT _IOWR('h',20,struct hammer_ioc_snapshot)
similarity index 96%
rename from sys/vfs/hammer/hammer_expand.c
rename to sys/vfs/hammer/hammer_volume.c
index ae496bf..50af62c 100644 (file)
@@ -73,8 +73,8 @@ hammer_set_layer1_entry(struct hammer_mount *hmp,
        int *errorp);
 
 int
-hammer_ioc_expand(hammer_transaction_t trans, hammer_inode_t ip,
-               struct hammer_ioc_expand *expand)
+hammer_ioc_volume_add(hammer_transaction_t trans, hammer_inode_t ip,
+               struct hammer_ioc_volume_add *ioc)
 {
        struct hammer_mount *hmp = trans->hmp;
        struct mount *mp = hmp->mp;
@@ -83,7 +83,7 @@ hammer_ioc_expand(hammer_transaction_t trans, hammer_inode_t ip,
        int error;
 
        if (mp->mnt_flag & MNT_RDONLY) {
-               kprintf("Cannot expand read-only HAMMER filesystem\n");
+               kprintf("Cannot add volume to read-only HAMMER filesystem\n");
                return (EINVAL);
        }
 
@@ -106,7 +106,7 @@ hammer_ioc_expand(hammer_transaction_t trans, hammer_inode_t ip,
        }
 
        struct vnode *devvp = NULL;
-       error = hammer_setup_device(&devvp, expand->device_name, 0);
+       error = hammer_setup_device(&devvp, ioc->device_name, 0);
        if (error)
                goto end;
        KKASSERT(devvp);
@@ -116,14 +116,14 @@ hammer_ioc_expand(hammer_transaction_t trans, hammer_inode_t ip,
                hmp->rootvol->ondisk->vol_name,
                free_vol_no,
                hmp->nvolumes+1,
-               expand->vol_size,
-               expand->boot_area_size,
-               expand->mem_area_size);
+               ioc->vol_size,
+               ioc->boot_area_size,
+               ioc->mem_area_size);
        hammer_close_device(&devvp, 0);
        if (error)
                goto end;
 
-       error = hammer_install_volume(hmp, expand->device_name, NULL);
+       error = hammer_install_volume(hmp, ioc->device_name, NULL);
        if (error)
                goto end;
 
@@ -419,7 +419,7 @@ hammer_format_volume_header(struct hammer_mount *hmp, struct vnode *devvp,
         * before.
         */
        if (ondisk->vol_signature == HAMMER_FSBUF_VOLUME) {
-               kprintf("hammer_expand: Formatting of valid HAMMER volume "
+               kprintf("hammer_volume_add: Formatting of valid HAMMER volume "
                        "%s denied. Erase with dd!\n", vol_name);
                error = EFTYPE;
                goto late_failure;