summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2005-06-24 12:13:14 +0000
committerjkar8572 <jkar8572>2005-06-24 12:13:14 +0000
commitc1f3d672a89843a3538e8e327b5084b6dd59e990 (patch)
tree7ceb680f0bd3eb7cbe061a1b5d2e42a05ea0a1ba
parentbb62efa3c613427b29abf70b06b7fee1f55dcb5d (diff)
Added label recognition for reiserfs. (Jan Kara)
Added support for specification of LABEL= and UUID= on command line. (Jan Kara)
-rw-r--r--Changelog2
-rw-r--r--bylabel.c23
-rw-r--r--quotasys.c23
3 files changed, 41 insertions, 7 deletions
diff --git a/Changelog b/Changelog
index 04b6f13..1df5d26 100644
--- a/Changelog
+++ b/Changelog
@@ -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)
diff --git a/bylabel.c b/bylabel.c
index d784931..ebf3a9e 100644
--- a/bylabel.c
+++ b/bylabel.c
@@ -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;
}
diff --git a/quotasys.c b/quotasys.c
index 796832a..0875ef6 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -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;