hammer2 - Add pfs-fsid, pfs-clid directive
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 7 Aug 2012 21:22:15 +0000 (14:22 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 7 Aug 2012 21:22:15 +0000 (14:22 -0700)
* Add commands to retrieve specific uuid's for named PFSs.

sbin/hammer2/cmd_pfs.c

index 60a59c2..03c3566 100644 (file)
@@ -57,7 +57,7 @@ cmd_pfs_list(const char *sel_path)
                }
                if (count == 0) {
                        printf("Type        "
                }
                if (count == 0) {
                        printf("Type        "
-                              "Pfs_id                               "
+                              "ClusterId (pfs_clid)                 "
                               "Label\n");
                }
                switch(pfs.pfs_type) {
                               "Label\n");
                }
                switch(pfs.pfs_type) {
@@ -102,6 +102,37 @@ cmd_pfs_list(const char *sel_path)
 }
 
 int
 }
 
 int
+cmd_pfs_getid(const char *sel_path, const char *name, int privateid)
+{
+       hammer2_ioc_pfs_t pfs;
+       int ecode = 0;
+       int fd;
+       uint32_t status;
+       char *pfs_id_str = NULL;
+
+       if ((fd = hammer2_ioctl_handle(sel_path)) < 0)
+               return(1);
+       bzero(&pfs, sizeof(pfs));
+
+       snprintf(pfs.name, sizeof(pfs.name), "%s", name);
+       if (ioctl(fd, HAMMER2IOC_PFS_LOOKUP, &pfs) < 0) {
+               perror("ioctl");
+               ecode = 1;
+       } else {
+               if (privateid)
+                       uuid_to_string(&pfs.pfs_fsid, &pfs_id_str, &status);
+               else
+                       uuid_to_string(&pfs.pfs_clid, &pfs_id_str, &status);
+               printf("%s\n", pfs_id_str);
+               free(pfs_id_str);
+               pfs_id_str = NULL;
+       }
+       close(fd);
+       return (ecode);
+}
+
+
+int
 cmd_pfs_create(const char *sel_path, const char *name,
               uint8_t pfs_type, const char *uuid_str)
 {
 cmd_pfs_create(const char *sel_path, const char *name,
               uint8_t pfs_type, const char *uuid_str)
 {