- Revert patch from Christophe applied by Yura.
- Provide a realpath() alternative for systems which do not have it. This is _much_ nicer as it avoids the horrible #ifdef gunk in the code...edge.strict_endians
parent
bf91f7c0fc
commit
a40d7e55d6
|
@ -8,6 +8,9 @@
|
|||
into alternate chroot / other system still works. (Anton)
|
||||
- ntfscmp: fix some corner cases and all memory leaks; handle corrupt
|
||||
NTFS more gracefully. (Szaka)
|
||||
- If the system does not have realpath(), supply our own dummy version
|
||||
which just copies the string without any kind of checking or
|
||||
expansion. (Anton)
|
||||
|
||||
07/10/2005 - 1.12.0 - Lots of fixes and enhancements!
|
||||
|
||||
|
|
|
@ -317,9 +317,9 @@ AC_FUNC_STAT
|
|||
AC_FUNC_STRFTIME
|
||||
AC_FUNC_UTIME_NULL
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS([atexit fdatasync hasmntopt memmove memset realpath regcomp setlocale \
|
||||
strcasecmp strchr strdup strerror strtol strtoul utime mbsinit \
|
||||
setxattr getopt_long ])
|
||||
AC_CHECK_FUNCS([atexit fdatasync getopt_long hasmntopt mbsinit memmove memset \
|
||||
realpath regcomp setlocale setxattr strcasecmp strchr strdup strerror \
|
||||
strtol strtoul utime])
|
||||
|
||||
# Makefiles to be created by configure.
|
||||
AC_CONFIG_FILES([
|
||||
|
|
|
@ -1264,6 +1264,17 @@ int ntfs_umount(ntfs_volume *vol,
|
|||
}
|
||||
|
||||
#ifdef HAVE_MNTENT_H
|
||||
|
||||
#ifndef HAVE_REALPATH
|
||||
/* If there is no realpath() on the system, provide a dummy one. */
|
||||
static char *realpath(const char *path, char *resolved_path)
|
||||
{
|
||||
strncpy(resolved_path, path, PATH_MAX);
|
||||
resolved_path[PATH_MAX] = '\0';
|
||||
return resolved_path;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Internal:
|
||||
*
|
||||
|
@ -1277,13 +1288,10 @@ int ntfs_umount(ntfs_volume *vol,
|
|||
static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
|
||||
{
|
||||
struct mntent *mnt;
|
||||
#ifdef HAVE_REALPATH
|
||||
char *real_file = NULL, *real_fsname = NULL;
|
||||
#endif
|
||||
FILE *f;
|
||||
int err = 0;
|
||||
|
||||
#ifdef HAVE_REALPATH
|
||||
real_file = malloc(PATH_MAX + 1);
|
||||
if (!real_file)
|
||||
return -1;
|
||||
|
@ -1296,21 +1304,15 @@ static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
|
|||
err = errno;
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
if (!(f = setmntent(MOUNTED, "r"))) {
|
||||
err = errno;
|
||||
goto exit;
|
||||
}
|
||||
while ((mnt = getmntent(f))) {
|
||||
#ifdef HAVE_REALPATH
|
||||
if (!realpath(mnt->mnt_fsname, real_fsname))
|
||||
continue;
|
||||
if (!strcmp(real_file, real_fsname))
|
||||
break;
|
||||
#else
|
||||
if (!strcmp(file, mnt->mnt_fsname))
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
endmntent(f);
|
||||
if (!mnt)
|
||||
|
@ -1323,12 +1325,9 @@ static int ntfs_mntent_check(const char *file, unsigned long *mnt_flags)
|
|||
*mnt_flags |= NTFS_MF_READONLY;
|
||||
#endif
|
||||
exit:
|
||||
#ifdef HAVE_REALPATH
|
||||
if (real_file)
|
||||
free(real_file);
|
||||
free(real_file);
|
||||
if (real_fsname)
|
||||
free(real_fsname);
|
||||
#endif
|
||||
if (err) {
|
||||
errno = err;
|
||||
return -1;
|
||||
|
|
|
@ -1336,6 +1336,16 @@ static void usage(void)
|
|||
Eprintf("Default options are: \"%s\".\n", def_opts);
|
||||
}
|
||||
|
||||
#ifndef HAVE_REALPATH
|
||||
/* If there is no realpath() on the system, provide a dummy one. */
|
||||
static char *realpath(const char *path, char *resolved_path)
|
||||
{
|
||||
strncpy(resolved_path, path, PATH_MAX);
|
||||
resolved_path[PATH_MAX] = '\0';
|
||||
return resolved_path;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* parse_options - Read and validate the programs command line
|
||||
*
|
||||
|
@ -1375,7 +1385,6 @@ static int parse_options(int argc, char *argv[])
|
|||
err++;
|
||||
break;
|
||||
}
|
||||
#ifdef HAVE_REALPATH
|
||||
/* We don't want relative path in /etc/mtab. */
|
||||
if (argv[optind - 1][0] != '/') {
|
||||
if (!realpath(argv[optind - 1],
|
||||
|
@ -1388,9 +1397,6 @@ static int parse_options(int argc, char *argv[])
|
|||
}
|
||||
} else
|
||||
strcpy(opts.device, argv[optind - 1]);
|
||||
#else
|
||||
strcpy(opts.device, argv[optind - 1]);
|
||||
#endif
|
||||
} else if (!opts.mnt_point)
|
||||
opts.mnt_point = argv[optind - 1];
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue