]> err.no Git - util-linux/commitdiff
libmount: add debug messages and fix typos in tab_update
authorKarel Zak <kzak@redhat.com>
Mon, 8 Nov 2010 11:21:41 +0000 (12:21 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:46 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/tab_parse.c
shlibs/mount/src/tab_update.c
shlibs/mount/src/utils.c

index a1857a44b618bdf74297834607a03b4d22b95f6b..af5008328c850640693ca36e645caec2e68d5a44 100644 (file)
@@ -148,7 +148,11 @@ static int mnt_parse_mountinfo_line(mnt_fs *fs, char *s)
                } else
                        unmangle_string(src);
 
-               unmangle_string(fs->fs_optstr);
+               if (!strcmp(fs->fs_optstr, "none")) {
+                       free(fs->fs_optstr);
+                       fs->fs_optstr = NULL;
+               } else
+                       unmangle_string(fs->fs_optstr);
 
                rc = __mnt_fs_set_fstype_ptr(fs, fstype);
                if (!rc)
index 09c9cdfa02e6f4822fcd75c2c9a6cb145afa1684..99b2a890b92b241d79a7f62cfc5d82651984f4e2 100644 (file)
@@ -676,18 +676,22 @@ static int update(const char *target, mnt_fs *fs, unsigned long mountflags)
 
                if (rc && writable)
                        upd = mnt_new_update(TRUE);
-               else
-                       return -EACCES;
+               else {
+                       fprintf(stderr, "utab useless: %m\n");
+                       return -1;
+               }
        }
 
        rc = mnt_update_set_fs(upd, mountflags, target, fs);
-       if (rc)
-               goto done;
        if (rc == 1) {
-               fprintf(stderr, "update is unnecessary\n");
+               /* update is unnecessary */
                rc = 0;
                goto done;
        }
+       if (rc) {
+               fprintf(stderr, "failed to set FS\n");
+               goto done;
+       }
 
        /* [... here should be mount(2) call ...]  */
 
index 410028fa7394bfef438cc9249ec377a16654f2f5..0f17edfea07dcf042e1ca8c1db53c4e1b75a203a 100644 (file)
@@ -448,6 +448,8 @@ int mnt_has_regular_mtab(const char **mtab, int *writable)
        int rc;
        const char *filename = mtab && *mtab ? *mtab : mnt_get_mtab_path();
 
+       if (writable)
+               *writable = 0;
        if (mtab && !*mtab)
                *mtab = filename;
 
@@ -462,17 +464,21 @@ int mnt_has_regular_mtab(const char **mtab, int *writable)
                                *writable = !try_write(filename);
                        return 1;
                }
-               return 0;       /* it's not regular file */
+               goto done;
        }
 
        /* try to create the file */
        if (writable) {
                *writable = !try_write(filename);
-               return *writable;
+               if (*writable)
+                       return 1;
        }
 
+done:
+       DBG(UTILS, mnt_debug("%s: irregular/non-writable", filename));
        return 0;
 }
+
 /**
  *
  * mnt_has_regular_utab:
@@ -492,6 +498,8 @@ int mnt_has_regular_utab(const char **utab, int *writable)
        int rc;
        const char *filename = utab && *utab ? *utab : mnt_get_utab_path();
 
+       if (writable)
+               *writable = 0;
        if (utab && !*utab)
                *utab = filename;
 
@@ -503,28 +511,31 @@ int mnt_has_regular_utab(const char **utab, int *writable)
                /* file exist */
                if (S_ISREG(st.st_mode)) {
                        if (writable)
-                               *writable = try_write(filename);
+                               *writable = !try_write(filename);
                        return 1;
                }
-               return 0;       /* it's not regular file */
+               goto done;      /* it's not regular file */
        }
 
        if (writable) {
                char *dirname = strdup(filename);
 
                if (!dirname)
-                       return 0;
+                       goto done;
 
                stripoff_last_component(dirname);       /* remove filename */
 
                rc = mkdir(dirname, 755);
                free(dirname);
                if (rc && errno != EEXIST)
-                       return 0;                       /* probably EACCES */
+                       goto done;                      /* probably EACCES */
 
                *writable = !try_write(filename);
-               return *writable;
+               if (*writable)
+                       return 1;
        }
+done:
+       DBG(UTILS, mnt_debug("%s: irregular/non-writable file", filename));
        return 0;
 }