diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2009-02-10 08:48:30 -0500 |
---|---|---|
committer | Steven Whitehouse <steve@dolmen.chygwyn.com> | 2009-03-24 07:21:21 -0400 |
commit | 02e3cc70ecbd4352ae4d26459929f43ab1547251 (patch) | |
tree | 56d0dd9501481545e592430e408e5cf1495ed373 /fs | |
parent | f15ab5619d8068a321094f4705147764d689e88e (diff) |
GFS2: Expose UUID via sysfs/uevent
Since we have a UUID, we ought to expose it to the user via sysfs
and uevents. We already have the fs name in both of these places
(a combination of the lock proto and lock table name) so if we add
the UUID as well, we have a full set.
For older filesystems (i.e. those created before mkfs.gfs2 was writing
UUIDs by default) the sysfs file will appear zero length, and no UUID
env var will be added to the uevents.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/incore.h | 1 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 1 | ||||
-rw-r--r-- | fs/gfs2/sys.c | 37 |
3 files changed, 39 insertions, 0 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 3f29bd224ba1..980a0864ca6c 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -470,6 +470,7 @@ struct gfs2_sb_host { | |||
470 | 470 | ||
471 | char sb_lockproto[GFS2_LOCKNAME_LEN]; | 471 | char sb_lockproto[GFS2_LOCKNAME_LEN]; |
472 | char sb_locktable[GFS2_LOCKNAME_LEN]; | 472 | char sb_locktable[GFS2_LOCKNAME_LEN]; |
473 | u8 sb_uuid[16]; | ||
473 | }; | 474 | }; |
474 | 475 | ||
475 | /* | 476 | /* |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index e502b379a4da..804ca7273a49 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -234,6 +234,7 @@ static void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf) | |||
234 | 234 | ||
235 | memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN); | 235 | memcpy(sb->sb_lockproto, str->sb_lockproto, GFS2_LOCKNAME_LEN); |
236 | memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); | 236 | memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); |
237 | memcpy(sb->sb_uuid, str->sb_uuid, 16); | ||
237 | } | 238 | } |
238 | 239 | ||
239 | /** | 240 | /** |
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index a78997ea5037..4d284d14980b 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
@@ -36,6 +36,30 @@ static ssize_t fsname_show(struct gfs2_sbd *sdp, char *buf) | |||
36 | return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname); | 36 | return snprintf(buf, PAGE_SIZE, "%s\n", sdp->sd_fsname); |
37 | } | 37 | } |
38 | 38 | ||
39 | static int gfs2_uuid_valid(const u8 *uuid) | ||
40 | { | ||
41 | int i; | ||
42 | |||
43 | for (i = 0; i < 16; i++) { | ||
44 | if (uuid[i]) | ||
45 | return 1; | ||
46 | } | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf) | ||
51 | { | ||
52 | const u8 *uuid = sdp->sd_sb.sb_uuid; | ||
53 | buf[0] = '\0'; | ||
54 | if (!gfs2_uuid_valid(uuid)) | ||
55 | return 0; | ||
56 | return snprintf(buf, PAGE_SIZE, "%02X%02X%02X%02X-%02X%02X-" | ||
57 | "%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n", | ||
58 | uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], | ||
59 | uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], | ||
60 | uuid[12], uuid[13], uuid[14], uuid[15]); | ||
61 | } | ||
62 | |||
39 | static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf) | 63 | static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf) |
40 | { | 64 | { |
41 | unsigned int count; | 65 | unsigned int count; |
@@ -158,6 +182,7 @@ static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store) | |||
158 | 182 | ||
159 | GFS2_ATTR(id, 0444, id_show, NULL); | 183 | GFS2_ATTR(id, 0444, id_show, NULL); |
160 | GFS2_ATTR(fsname, 0444, fsname_show, NULL); | 184 | GFS2_ATTR(fsname, 0444, fsname_show, NULL); |
185 | GFS2_ATTR(uuid, 0444, uuid_show, NULL); | ||
161 | GFS2_ATTR(freeze, 0644, freeze_show, freeze_store); | 186 | GFS2_ATTR(freeze, 0644, freeze_show, freeze_store); |
162 | GFS2_ATTR(withdraw, 0644, withdraw_show, withdraw_store); | 187 | GFS2_ATTR(withdraw, 0644, withdraw_show, withdraw_store); |
163 | GFS2_ATTR(statfs_sync, 0200, NULL, statfs_sync_store); | 188 | GFS2_ATTR(statfs_sync, 0200, NULL, statfs_sync_store); |
@@ -168,6 +193,7 @@ GFS2_ATTR(quota_refresh_group, 0200, NULL, quota_refresh_group_store); | |||
168 | static struct attribute *gfs2_attrs[] = { | 193 | static struct attribute *gfs2_attrs[] = { |
169 | &gfs2_attr_id.attr, | 194 | &gfs2_attr_id.attr, |
170 | &gfs2_attr_fsname.attr, | 195 | &gfs2_attr_fsname.attr, |
196 | &gfs2_attr_uuid.attr, | ||
171 | &gfs2_attr_freeze.attr, | 197 | &gfs2_attr_freeze.attr, |
172 | &gfs2_attr_withdraw.attr, | 198 | &gfs2_attr_withdraw.attr, |
173 | &gfs2_attr_statfs_sync.attr, | 199 | &gfs2_attr_statfs_sync.attr, |
@@ -598,12 +624,23 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp) | |||
598 | kobject_put(&sdp->sd_kobj); | 624 | kobject_put(&sdp->sd_kobj); |
599 | } | 625 | } |
600 | 626 | ||
627 | |||
601 | static int gfs2_uevent(struct kset *kset, struct kobject *kobj, | 628 | static int gfs2_uevent(struct kset *kset, struct kobject *kobj, |
602 | struct kobj_uevent_env *env) | 629 | struct kobj_uevent_env *env) |
603 | { | 630 | { |
604 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); | 631 | struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); |
632 | const u8 *uuid = sdp->sd_sb.sb_uuid; | ||
633 | |||
605 | add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); | 634 | add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); |
606 | add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); | 635 | add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); |
636 | if (gfs2_uuid_valid(uuid)) { | ||
637 | add_uevent_var(env, "UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-" | ||
638 | "%02X%02X-%02X%02X%02X%02X%02X%02X", | ||
639 | uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], | ||
640 | uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], | ||
641 | uuid[10], uuid[11], uuid[12], uuid[13], | ||
642 | uuid[14], uuid[15]); | ||
643 | } | ||
607 | return 0; | 644 | return 0; |
608 | } | 645 | } |
609 | 646 | ||