summaryrefslogtreecommitdiffstats
path: root/mount
diff options
context:
space:
mode:
authorKarel Zak2009-01-07 00:18:41 +0100
committerKarel Zak2009-01-07 00:18:41 +0100
commit448d12483cc24cd1ba50fde6b95d4c0f5080f038 (patch)
treed3ebc5b31439fdebb95514624fb466af7d73b505 /mount
parentmount: finalize support of quoted LABELs/UUIDs (diff)
downloadkernel-qcow2-util-linux-448d12483cc24cd1ba50fde6b95d4c0f5080f038.tar.gz
kernel-qcow2-util-linux-448d12483cc24cd1ba50fde6b95d4c0f5080f038.tar.xz
kernel-qcow2-util-linux-448d12483cc24cd1ba50fde6b95d4c0f5080f038.zip
umount: cleanup gefs_by_specdir()
fix: - don't call canonicalize_spec() for LABELs/UUIDs - simplify the code - rename to getfs_by_devdir(), because we use it only for device names and not for SPECes (see umount.c). Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount')
-rw-r--r--mount/fstab.c45
-rw-r--r--mount/fstab.h2
-rw-r--r--mount/umount.c4
3 files changed, 22 insertions, 29 deletions
diff --git a/mount/fstab.c b/mount/fstab.c
index 8e7019a5d..c60c5f4db 100644
--- a/mount/fstab.c
+++ b/mount/fstab.c
@@ -326,46 +326,39 @@ has_uuid(const char *device, const char *uuid){
return ret;
}
-/* Find the entry (SPEC,DIR) in fstab -- spec and dir must be canonicalized! */
+/* Find the entry (DEV,DIR) in fstab -- spec and dir must be canonicalized! */
struct mntentchn *
-getfs_by_specdir (const char *spec, const char *dir) {
+getfs_by_devdir (const char *dev, const char *dir) {
struct mntentchn *mc, *mc0;
mc0 = fstab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
+ int ok = 1;
+
/* dir */
if (!streq(mc->m.mnt_dir, dir)) {
char *dr = canonicalize(mc->m.mnt_dir);
- int ok = 0;
-
- if (streq(dr, dir))
- ok = 1;
- free(dr);
- if (!ok)
- continue;
+ ok = streq(dr, dir);
+ my_free(dr);
}
/* spec */
- if (!streq(mc->m.mnt_fsname, spec)) {
- char *fs = canonicalize_spec(mc->m.mnt_fsname);
- int ok = 0;
-
- if (streq(fs, spec))
- ok = 1;
- else if (strncmp (fs, "LABEL=", 6) == 0) {
- if (has_label(spec, fs + 6))
- ok = 1;
- }
- else if (strncmp (fs, "UUID=", 5) == 0) {
- if (has_uuid(spec, fs + 5))
- ok = 1;
+ if (ok && !streq(mc->m.mnt_fsname, dev)) {
+ const char *fs = mc->m.mnt_fsname;
+
+ if (strncmp (fs, "LABEL=", 6) == 0) {
+ ok = has_label(dev, fs + 6);
+ } else if (strncmp (fs, "UUID=", 5) == 0) {
+ ok = has_uuid(dev, fs + 5);
+ } else {
+ fs = canonicalize_spec(mc->m.mnt_fsname);
+ ok = streq(fs, dev);
+ my_free(fs);
}
- free(fs);
- if (!ok)
- continue;
}
- return mc;
+ if (ok)
+ return mc;
}
return NULL;
diff --git a/mount/fstab.h b/mount/fstab.h
index 14b24c45e..8fc8fd41e 100644
--- a/mount/fstab.h
+++ b/mount/fstab.h
@@ -22,7 +22,7 @@ struct mntentchn *fstab_head (void);
struct mntentchn *getfs_by_dir (const char *dir);
struct mntentchn *getfs_by_spec (const char *spec);
struct mntentchn *getfs_by_devname (const char *devname);
-struct mntentchn *getfs_by_specdir (const char *spec, const char *dir);
+struct mntentchn *getfs_by_devdir (const char *dev, const char *dir);
struct mntentchn *getfs_by_uuid (const char *uuid);
struct mntentchn *getfs_by_label (const char *label);
diff --git a/mount/umount.c b/mount/umount.c
index 81f8bdf13..00745aed9 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -514,8 +514,8 @@ umount_file (char *arg) {
/dev/sda4 /mnt/zip auto user,noauto 0 0
then "mount /dev/sda4" followed by "umount /mnt/zip"
used to fail. So, we must not look for file, but for
- the pair (spec,file) in fstab. */
- fs = getfs_by_specdir(mc->m.mnt_fsname, mc->m.mnt_dir);
+ the pair (dev,file) in fstab. */
+ fs = getfs_by_devdir(mc->m.mnt_fsname, mc->m.mnt_dir);
if (!fs) {
if (!getfs_by_spec (file) && !getfs_by_dir (file))
die (2,