libntfs/volume.c: fix ntfs_check_if_mounted to cope with dirrerent names of same file.
ntfsprogs/ntfsmount.c: don't put relative path to /etc/mtab.edge.strict_endians
parent
d8b586c014
commit
fc2382b742
|
@ -19,6 +19,7 @@ xx/07/2005 - 1.11.0-WIP - Fixes and a new utility ntfsmount, a FUSE ntfsmodule.
|
|||
when sector size was less than 512 bytes and then we wrote 512 bytes,
|
||||
i.e. beyond the end of the device.) (Anton)
|
||||
- Add new utility (make extra) - ntfsdecrypt. (Yuval)
|
||||
- Improve "already mounted" ckeck. (Yura)
|
||||
|
||||
20/06/2005 - 1.10.0 - Lots of new features, enhancements, and bug fixes.
|
||||
|
||||
|
|
|
@ -1246,16 +1246,35 @@ int ntfs_umount(ntfs_volume *vol,
|
|||
static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
|
||||
{
|
||||
struct mntent *mnt;
|
||||
char *real_file = NULL, *real_fsname = NULL;
|
||||
FILE *f;
|
||||
int err = 0;
|
||||
|
||||
if (!(f = setmntent(MOUNTED, "r")))
|
||||
real_file = malloc(PATH_MAX + 1);
|
||||
if (!real_file)
|
||||
return -1;
|
||||
while ((mnt = getmntent(f)))
|
||||
if (!strcmp(file, mnt->mnt_fsname))
|
||||
real_fsname = malloc(PATH_MAX + 1);
|
||||
if (!real_fsname) {
|
||||
err = errno;
|
||||
goto exit;
|
||||
}
|
||||
if (!realpath(file, real_file)) {
|
||||
err = errno;
|
||||
goto exit;
|
||||
}
|
||||
if (!(f = setmntent(MOUNTED, "r"))) {
|
||||
err = errno;
|
||||
goto exit;
|
||||
}
|
||||
while ((mnt = getmntent(f))) {
|
||||
if (!realpath(mnt->mnt_fsname, real_fsname))
|
||||
continue;
|
||||
if (!strcmp(real_file, real_fsname))
|
||||
break;
|
||||
}
|
||||
endmntent(f);
|
||||
if (!mnt)
|
||||
return 0;
|
||||
goto exit;
|
||||
*mnt_flags = NTFS_MF_MOUNTED;
|
||||
if (!strcmp(mnt->mnt_dir, "/"))
|
||||
*mnt_flags |= NTFS_MF_ISROOT;
|
||||
|
@ -1263,6 +1282,15 @@ static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
|
|||
if (hasmntopt(mnt, "ro") && !hasmntopt(mnt, "rw"))
|
||||
*mnt_flags |= NTFS_MF_READONLY;
|
||||
#endif
|
||||
exit:
|
||||
if (real_file)
|
||||
free(real_file);
|
||||
if (real_fsname)
|
||||
free(real_fsname);
|
||||
if (err) {
|
||||
errno = err;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_MNTENT_H */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef HAVE_SETXATTR
|
||||
#include <sys/xattr.h>
|
||||
|
@ -905,12 +906,12 @@ static char *parse_options(char *options, char **device)
|
|||
|
||||
*device = NULL;
|
||||
/*
|
||||
* +3 for different in length of "fsname=..." and "dev=...".
|
||||
* +1 for comma
|
||||
* +1 for null-terminator.
|
||||
* Total: +5
|
||||
* +3 for different in length of "fsname=..." and "dev=...".
|
||||
* +1 for comma.
|
||||
* +1 for null-terminator.
|
||||
* +PATH_MAX for resolved by realpath() device name
|
||||
*/
|
||||
ret = malloc(strlen(def_opts) + strlen(options) + 5);
|
||||
ret = malloc(strlen(def_opts) + strlen(options) + 5 + PATH_MAX);
|
||||
if (!ret) {
|
||||
perror("malloc failed");
|
||||
return NULL;
|
||||
|
@ -929,8 +930,19 @@ static char *parse_options(char *options, char **device)
|
|||
Eprintf("dev option should have value.\n");
|
||||
goto err_exit;
|
||||
}
|
||||
*device = malloc(strlen(val) + 1);
|
||||
strcpy(*device, val);
|
||||
*device = malloc(PATH_MAX + 1);
|
||||
if (!*device)
|
||||
goto err_exit;
|
||||
/* We don't want relative path in /etc/mtab. */
|
||||
if (val[0] != '/') {
|
||||
if (!realpath(val, *device)) {
|
||||
perror("");
|
||||
free(*device);
|
||||
*device = NULL;
|
||||
goto err_exit;
|
||||
}
|
||||
} else
|
||||
strcpy(*device, val);
|
||||
} else if (!strcmp(opt, "ro")) { /* Read-only mount. */
|
||||
if (val) {
|
||||
Eprintf("ro option should not have value.\n");
|
||||
|
|
Loading…
Reference in New Issue