sys/vfs/hammer: Add typedef hammer_uuid_t
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 21 Sep 2017 16:06:37 +0000 (19:06 +0300)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 23 Sep 2017 11:59:54 +0000 (14:59 +0300)
Add typedef for uuid_t for better portability,
similar to hammer_crc_t and other hammer_xxx_t.
(Some platforms have char[16] for uuid_t instead of struct value)

No functional changes.

13 files changed:
lib/libstand/hammer1.c
sbin/hammer/cmd_cleanup.c
sbin/hammer/cmd_mirror.c
sbin/hammer/hammer_util.h
sbin/hammer/ondisk.c
sbin/hammer/uuid.c
sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_disk.h
sys/vfs/hammer/hammer_ioctl.h
sys/vfs/hammer/hammer_ondisk.c
sys/vfs/hammer/hammer_subs.c
sys/vfs/hammer/hammer_vnops.c
usr.sbin/fstyp/hammer.c

index 34ee538..e3dde9d 100644 (file)
@@ -326,7 +326,7 @@ hammer_directory_namekey(const void *name __unused, int len __unused)
  * Misc
  */
 static u_int32_t
-hammer_to_unix_xid(uuid_t *uuid)
+hammer_to_unix_xid(hammer_uuid_t *uuid)
 {
        return(*(u_int32_t *)&uuid->node[2]);
 }
index d5ee2b2..a834647 100644 (file)
@@ -64,7 +64,7 @@
 
 struct didpfs {
        struct didpfs *next;
-       uuid_t          uuid;
+       hammer_uuid_t uuid;
 };
 
 static void do_cleanup(const char *path);
index c0e82bc..129fbb9 100644 (file)
@@ -699,7 +699,7 @@ generate_histogram(int fd, const char *filesystem,
 
 static
 void
-create_pfs(const char *filesystem, uuid_t *s_uuid)
+create_pfs(const char *filesystem, hammer_uuid_t *s_uuid)
 {
        if (ForceYesOpt == 1) {
                fprintf(stderr, "PFS slave %s does not exist. "
index b917a33..73c975b 100644 (file)
@@ -111,8 +111,8 @@ typedef struct zone_stat {
        int64_t                 used;           /* bytes used */
 } *zone_stat_t;
 
-extern uuid_t Hammer_FSType;
-extern uuid_t Hammer_FSId;
+extern hammer_uuid_t Hammer_FSType;
+extern hammer_uuid_t Hammer_FSId;
 extern int UseReadBehind;
 extern int UseReadAhead;
 extern int DebugOpt;
@@ -174,11 +174,11 @@ void hammer_add_zone_stat_layer2(zone_stat_t stats,
                        hammer_blockmap_layer2_t layer2);
 void hammer_print_zone_stat(const zone_stat_t stats);
 
-void hammer_uuid_create(uuid_t *uuid);
-int hammer_uuid_from_string(const char *str, uuid_t *uuid);
-int hammer_uuid_to_string(const uuid_t *uuid, char **str);
-int hammer_uuid_name_lookup(uuid_t *u, const char *str);
-int hammer_uuid_compare(const uuid_t *uuid1, const uuid_t *uuid2);
+void hammer_uuid_create(hammer_uuid_t *uuid);
+int hammer_uuid_from_string(const char *str, hammer_uuid_t *uuid);
+int hammer_uuid_to_string(const hammer_uuid_t *uuid, char **str);
+int hammer_uuid_name_lookup(hammer_uuid_t *u, const char *str);
+int hammer_uuid_compare(const hammer_uuid_t *uuid1, const hammer_uuid_t *uuid2);
 
 #define hwarn(format, args...) warn("WARNING: "format,## args)
 #define hwarnx(format, args...)        warnx("WARNING: "format,## args)
index e71f178..d1e6b2f 100644 (file)
@@ -44,8 +44,8 @@ static __inline int readhammerbuf(buffer_info_t buffer);
 static __inline int writehammervol(volume_info_t volume);
 static __inline int writehammerbuf(buffer_info_t buffer);
 
-uuid_t Hammer_FSType;
-uuid_t Hammer_FSId;
+hammer_uuid_t Hammer_FSType;
+hammer_uuid_t Hammer_FSId;
 int UseReadBehind = -4;
 int UseReadAhead = 4;
 int DebugOpt;
index eef610f..984db88 100644 (file)
 
 #include "hammer_util.h"
 
-void hammer_uuid_create(uuid_t *uuid)
+void hammer_uuid_create(hammer_uuid_t *uuid)
 {
        uuid_create(uuid, NULL);
 }
 
-int hammer_uuid_from_string(const char *str, uuid_t *uuid)
+int hammer_uuid_from_string(const char *str, hammer_uuid_t *uuid)
 {
        uint32_t status = uuid_s_ok;
 
@@ -53,7 +53,7 @@ int hammer_uuid_from_string(const char *str, uuid_t *uuid)
        return(0);
 }
 
-int hammer_uuid_to_string(const uuid_t *uuid, char **str)
+int hammer_uuid_to_string(const hammer_uuid_t *uuid, char **str)
 {
        uint32_t status = uuid_s_ok;
 
@@ -64,7 +64,7 @@ int hammer_uuid_to_string(const uuid_t *uuid, char **str)
        return(0);
 }
 
-int hammer_uuid_name_lookup(uuid_t *u, const char *str)
+int hammer_uuid_name_lookup(hammer_uuid_t *u, const char *str)
 {
        uint32_t status = uuid_s_ok;
 
@@ -75,7 +75,7 @@ int hammer_uuid_name_lookup(uuid_t *u, const char *str)
        return(0);
 }
 
-int hammer_uuid_compare(const uuid_t *uuid1, const uuid_t *uuid2)
+int hammer_uuid_compare(const hammer_uuid_t *uuid1, const hammer_uuid_t *uuid2)
 {
        return(uuid_compare(uuid1, uuid2, NULL));
 }
index 1f743e0..d6de1a6 100644 (file)
@@ -857,7 +857,7 @@ typedef struct hammer_mount {
 
        u_int   check_interrupt;
        u_int   check_yield;
-       uuid_t  fsid;
+       hammer_uuid_t fsid;
        struct hammer_mod_rb_tree volu_root;    /* dirty undo buffers */
        struct hammer_mod_rb_tree undo_root;    /* dirty undo buffers */
        struct hammer_mod_rb_tree data_root;    /* dirty data buffers */
@@ -1096,8 +1096,8 @@ void      hammer_sync_lock_sh(hammer_transaction_t trans);
 int    hammer_sync_lock_sh_try(hammer_transaction_t trans);
 void   hammer_sync_unlock(hammer_transaction_t trans);
 
-uint32_t hammer_to_unix_xid(uuid_t *uuid);
-void hammer_guid_to_uuid(uuid_t *uuid, uint32_t guid);
+uint32_t hammer_to_unix_xid(hammer_uuid_t *uuid);
+void hammer_guid_to_uuid(hammer_uuid_t *uuid, uint32_t guid);
 void   hammer_time_to_timespec(uint64_t xtime, struct timespec *ts);
 uint64_t hammer_timespec_to_time(struct timespec *ts);
 int    hammer_str_to_tid(const char *str, int *ispfsp,
@@ -1446,7 +1446,7 @@ int hammer_recover_stage2(hammer_mount_t hmp, hammer_volume_t rootvol);
 void hammer_recover_flush_buffers(hammer_mount_t hmp,
                        hammer_volume_t root_volume, int final);
 
-udev_t hammer_fsid_to_udev(uuid_t *uuid);
+udev_t hammer_fsid_to_udev(hammer_uuid_t *uuid);
 
 
 int hammer_blocksize(int64_t file_offset);
index 8931cfd..6527f10 100644 (file)
 typedef uint64_t hammer_tid_t;
 typedef uint64_t hammer_off_t;
 typedef uint32_t hammer_crc_t;
+typedef uuid_t hammer_uuid_t;
 
 #define HAMMER_MIN_TID         0ULL                    /* unsigned */
 #define HAMMER_MAX_TID         0xFFFFFFFFFFFFFFFFULL   /* unsigned */
@@ -747,8 +748,8 @@ typedef struct hammer_volume_ondisk {
        int64_t vol_buf_end;    /* offset of volume EOF (on buffer boundary) */
        int64_t vol_reserved01;
 
-       uuid_t    vol_fsid;     /* identify filesystem */
-       uuid_t    vol_fstype;   /* identify filesystem type */
+       hammer_uuid_t vol_fsid; /* identify filesystem */
+       hammer_uuid_t vol_fstype; /* identify filesystem type */
        char vol_label[64];     /* filesystem label */
 
        int32_t vol_no;         /* volume number within filesystem */
@@ -891,8 +892,8 @@ typedef struct hammer_inode_data {
        uint32_t rminor;        /* used by device nodes */
        uint64_t ctime;
        int64_t parent_obj_id;  /* parent directory obj_id */
-       uuid_t    uid;
-       uuid_t    gid;
+       hammer_uuid_t uid;
+       hammer_uuid_t gid;
 
        uint8_t obj_type;
        uint8_t cap_flags;      /* capability support flags (extension) */
@@ -1002,8 +1003,8 @@ struct hammer_pseudofs_data {
        hammer_tid_t    sync_end_tid;   /* current synchronizatoin point */
        uint64_t        sync_beg_ts;    /* real-time of last completed sync */
        uint64_t        sync_end_ts;    /* initiation of current sync cycle */
-       uuid_t          shared_uuid;    /* shared uuid (match required) */
-       uuid_t          unique_uuid;    /* unique uuid of this master/slave */
+       hammer_uuid_t   shared_uuid;    /* shared uuid (match required) */
+       hammer_uuid_t   unique_uuid;    /* unique uuid of this master/slave */
        int32_t         reserved01;     /* reserved for future master_id */
        int32_t         mirror_flags;   /* misc flags */
        char            label[64];      /* filesystem space label */
index 04c6dae..30295f3 100644 (file)
@@ -228,8 +228,8 @@ struct hammer_ioc_info {
        struct hammer_ioc_head          head;
 
        char            vol_label[64];
-       uuid_t          vol_fsid;
-       uuid_t          vol_fstype;
+       hammer_uuid_t   vol_fsid;
+       hammer_uuid_t   vol_fstype;
 
        int             version;
        int             nvolumes;
@@ -275,7 +275,7 @@ struct hammer_ioc_mirror_rw {
        int                     size;           /* max size */
        int                     pfs_id;         /* PFS id being read/written */
        int                     reserved01;
-       uuid_t                  shared_uuid;    /* validator for safety */
+       hammer_uuid_t           shared_uuid;    /* validator for safety */
 };
 
 #define HAMMER_IOC_MIRROR_NODATA       0x0001  /* do not include bulk data */
index a00c4dc..3619558 100644 (file)
@@ -214,7 +214,7 @@ hammer_install_volume(hammer_mount_t hmp, const char *volname,
 
        if (RB_EMPTY(&hmp->rb_vols_root)) {
                hmp->fsid = ondisk->vol_fsid;
-       } else if (bcmp(&hmp->fsid, &ondisk->vol_fsid, sizeof(uuid_t))) {
+       } else if (bcmp(&hmp->fsid, &ondisk->vol_fsid, sizeof(hammer_uuid_t))) {
                hkprintf("volume %s's fsid does not match other volumes\n",
                        volume->vol_name);
                error = EFTYPE;
index 5c1d24b..1bae2d3 100644 (file)
@@ -779,13 +779,13 @@ hammer_sync_unlock(hammer_transaction_t trans)
  * Misc
  */
 uint32_t
-hammer_to_unix_xid(uuid_t *uuid)
+hammer_to_unix_xid(hammer_uuid_t *uuid)
 {
        return(*(uint32_t *)&uuid->node[2]);
 }
 
 void
-hammer_guid_to_uuid(uuid_t *uuid, uint32_t guid)
+hammer_guid_to_uuid(hammer_uuid_t *uuid, uint32_t guid)
 {
        bzero(uuid, sizeof(*uuid));
        *(uint32_t *)&uuid->node[2] = guid;
@@ -1129,7 +1129,7 @@ hammer_blockdemarc(int64_t file_offset1, int64_t file_offset2)
 }
 
 udev_t
-hammer_fsid_to_udev(uuid_t *uuid)
+hammer_fsid_to_udev(hammer_uuid_t *uuid)
 {
        uint32_t crc;
 
index 9b6b6fa..154176d 100644 (file)
@@ -2195,8 +2195,8 @@ hammer_vop_setattr(struct vop_setattr_args *ap)
                mode_t cur_mode = ip->ino_data.mode;
                uid_t cur_uid = hammer_to_unix_xid(&ip->ino_data.uid);
                gid_t cur_gid = hammer_to_unix_xid(&ip->ino_data.gid);
-               uuid_t uuid_uid;
-               uuid_t uuid_gid;
+               hammer_uuid_t uuid_uid;
+               hammer_uuid_t uuid_gid;
 
                error = vop_helper_chown(ap->a_vp, vap->va_uid, vap->va_gid,
                                         ap->a_cred,
index a89731d..1a74616 100644 (file)
@@ -52,7 +52,7 @@ static int
 __test_ondisk(const hammer_volume_ondisk_t ondisk)
 {
        static int count = 0;
-       static uuid_t fsid, fstype;
+       static hammer_uuid_t fsid, fstype;
        static char label[64];
 
        if (ondisk->vol_signature != HAMMER_FSBUF_VOLUME &&