sys/vfs/hammer: Add HAMMER_ROOT_PFSID macro
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 13 Dec 2015 15:15:08 +0000 (00:15 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Mon, 14 Dec 2015 11:57:31 +0000 (20:57 +0900)
Explicitly show PFS#0 is root PFS.

sbin/hammer/cmd_pfs.c
sys/vfs/hammer/hammer_disk.h
sys/vfs/hammer/hammer_pfs.c

index 5bd5968..5bc884b 100644 (file)
@@ -284,7 +284,7 @@ hammer_cmd_pseudofs_create(char **av, int ac, int is_slave)
        pfs.bytes = sizeof(pfsd);
 
        ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs);
-       if (pfs.pfs_id != 0) {
+       if (pfs.pfs_id != HAMMER_ROOT_PFSID) {
                fprintf(stderr,
                        "You are attempting to access a PFS softlink "
                        "from a PFS.  It may not represent the PFS\n"
@@ -357,7 +357,7 @@ hammer_cmd_pseudofs_destroy(char **av, int ac)
                pseudofs_usage(1);
        fd = getpfs(&pfs, av[0]);
 
-       if (pfs.pfs_id == 0) {
+       if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
                fprintf(stderr, "You cannot destroy PFS#0\n");
                exit(1);
        }
@@ -453,7 +453,7 @@ hammer_cmd_pseudofs_upgrade(char **av, int ac)
                pseudofs_usage(1);
        fd = getpfs(&pfs, av[0]);
 
-       if (pfs.pfs_id == 0) {
+       if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
                fprintf(stderr, "You cannot upgrade PFS#0"
                                " (It should already be a master)\n");
                exit(1);
@@ -482,7 +482,7 @@ hammer_cmd_pseudofs_downgrade(char **av, int ac)
                pseudofs_usage(1);
        fd = getpfs(&pfs, av[0]);
 
-       if (pfs.pfs_id == 0) {
+       if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
                fprintf(stderr, "You cannot downgrade PFS#0\n");
                exit(1);
        } else if (pfs.ondisk->mirror_flags & HAMMER_PFSD_SLAVE) {
@@ -516,7 +516,7 @@ hammer_cmd_pseudofs_update(char **av, int ac)
        if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) == 0) {
                parse_pfsd_options(av + 1, ac - 1, pfs.ondisk);
                if ((pfs.ondisk->mirror_flags & HAMMER_PFSD_SLAVE) &&
-                   pfs.pfs_id == 0) {
+                   pfs.pfs_id == HAMMER_ROOT_PFSID) {
                        printf("The real mount point cannot be made a PFS "
                               "slave, only PFS sub-directories can be made "
                               "slaves\n");
index e4a53b7..f98f80a 100644 (file)
@@ -894,6 +894,7 @@ typedef struct hammer_pseudofs_data *hammer_pseudofs_data_t;
 
 #define HAMMER_MAX_PFS         65536
 #define HAMMER_MAX_PFSID       (HAMMER_MAX_PFS - 1)
+#define HAMMER_ROOT_PFSID      0
 
 /*
  * Snapshot meta-data { Objid = HAMMER_OBJID_ROOT, Key = tid, rectype = SNAPSHOT }.
index 9903ee8..7734a36 100644 (file)
@@ -116,7 +116,7 @@ hammer_ioc_set_pseudofs(hammer_transaction_t trans, hammer_inode_t ip,
        /*
         * Make sure a caller isn't creating a PFS from non-root PFS.
         */
-       if (lo_to_pfs(ip->obj_localization) != 0) {
+       if (lo_to_pfs(ip->obj_localization) != HAMMER_ROOT_PFSID) {
                hmkprintf(trans->hmp,
                        "Creating a PFS from non-root PFS is not allowed\n");
                return(EINVAL);