]> granicus.if.org Git - zfs/commitdiff
Fill in mountpoint buffer before using it in errors
authorilovezfs <ilovezfs@icloud.com>
Wed, 30 Apr 2014 05:47:14 +0000 (22:47 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 30 Apr 2014 22:52:01 +0000 (15:52 -0700)
zfs_is_mountable() fills in the mountpoint buffer, so, as in
upstream, it needs to have been called before the mountpoint
buffer can be used in error messages.

In particular,

return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED,
    dgettext(TEXT_DOMAIN, "cannot mount '%s'"),
    mountpoint));

should not come before the call to zfs_is_mountable().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: ilovezfs <ilovezfs@icloud.com>
Closes #2284

lib/libzfs/libzfs_mount.c

index b85c5d04ffea42e7bdbb1719ecc50e7bfbf4c5ac..83396c402678fbd7f0ff0d8a17aa81c63bc032ec 100644 (file)
@@ -405,6 +405,9 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
        if (zpool_get_prop_int(zhp->zpool_hdl, ZPOOL_PROP_READONLY, NULL))
                (void) strlcat(mntopts, "," MNTOPT_RO, sizeof (mntopts));
 
+       if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))
+               return (0);
+
        /*
         * Append default mount options which apply to the mount point.
         * This is done because under Linux (unlike Solaris) multiple mount
@@ -426,9 +429,6 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
         */
        strlcat(mntopts, "," MNTOPT_ZFSUTIL, sizeof (mntopts));
 
-       if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))
-               return (0);
-
        /* Create the directory if it doesn't already exist */
        if (lstat(mountpoint, &buf) != 0) {
                if (mkdirp(mountpoint, 0755) != 0) {