diff options
-rw-r--r-- | Changelog | 2 | ||||
-rw-r--r-- | bylabel.c | 23 | ||||
-rw-r--r-- | quotasys.c | 23 |
3 files changed, 41 insertions, 7 deletions
@@ -1,4 +1,6 @@ Changes in quota-tools from 3.12 to 3.13 +* volume label and UUID support for reiserfs (Jan Kara) +* support for LABEL= and UUID= on a command line (Jan Kara) * parse NFSD export table to find pseudofilesystem root for NFSv4 (Jan Kara) * handle better when quota file should become empty (Niu YaWei) * minor manpage and help-text fixes (Jan Kara) @@ -54,6 +54,15 @@ struct xfs_super_block { u_char s_fsname[12]; }; +#define REISER_SUPER_MAGIC "ReIsEr2Fs" +struct reiserfs_super_block { + u_char s_dummy1[52]; + u_char s_magic[10]; + u_char s_dummy2[22]; + u_char s_uuid[16]; + u_char s_volume_name[16]; +}; + static inline unsigned short swapped(unsigned short a) { return (a >> 8) | (a << 8); @@ -65,11 +74,11 @@ static int get_label_uuid(const char *device, char **label, char *uuid) /* start with ext2 and xfs tests, taken from mount_guess_fstype */ /* should merge these later */ - int fd; - int rv = 1; + int fd, rv = 1; size_t namesize; struct ext2_super_block e2sb; struct xfs_super_block xfsb; + struct reiserfs_super_block reisersb; fd = open(device, O_RDONLY); if (fd < 0) @@ -94,7 +103,15 @@ static int get_label_uuid(const char *device, char **label, char *uuid) sstrncpy(*label, xfsb.s_fsname, namesize); rv = 0; } - + else if (lseek(fd, 65536, SEEK_SET) == 65536 + && read(fd, (char *)&reisersb, sizeof(reisersb)) == sizeof(reisersb) + && !strncmp((char *)&reisersb.s_magic, REISER_SUPER_MAGIC, 9)) { + memcpy(uuid, reisersb.s_uuid, sizeof(reisersb.s_uuid)); + namesize = sizeof(reisersb.s_volume_name); + *label = smalloc(namesize + 1); + sstrncpy(*label, reisersb.s_volume_name, namesize); + rv = 0; + } close(fd); return rv; } @@ -997,10 +997,25 @@ static int process_dirs(int dcnt, char **dirs, int flags) if (dcnt) { check_dirs = smalloc(sizeof(struct searched_dir) * dcnt); for (i = 0; i < dcnt; i++) { - if (stat(dirs[i], &st) < 0) { - errstr(_("Can't stat() given mountpoint %s: %s\nSkipping...\n"), dirs[i], strerror(errno)); - continue; + if (!strncmp(dirs[i], "UUID=", 5) || !strncmp(dirs[i], "LABEL=", 6)) { + char *devname = (char *)get_device_name(dirs[i]); + + if (!devname) { + errstr(_("Can't find a device with %s.\nSkipping...\n"), dirs[i]); + continue; + } + if (stat(devname, &st) < 0) { + errstr(_("Can't stat() a mountpoint with %s: %s\nSkipping...\n"), dirs[i], strerror(errno)); + free(devname); + continue; + } + free(devname); } + else + if (stat(dirs[i], &st) < 0) { + errstr(_("Can't stat() given mountpoint %s: %s\nSkipping...\n"), dirs[i], strerror(errno)); + continue; + } check_dirs[check_dirs_cnt].sd_dir = S_ISDIR(st.st_mode); if (S_ISDIR(st.st_mode)) { const char *realmnt = dirs[i]; @@ -1008,7 +1023,7 @@ static int process_dirs(int dcnt, char **dirs, int flags) /* Return st of mountpoint of dir in st.. */ if (flags & MS_NO_MNTPOINT && !(realmnt = find_dir_mntpoint(&st))) { if (!(flags & MS_QUIET)) - errstr(_("Can't find filesystem mountpoint for directory %s\n"), dirs[i]); + errstr(_("Can't find a filesystem mountpoint for directory %s\n"), dirs[i]); continue; } check_dirs[check_dirs_cnt].sd_dev = st.st_dev; |