Remove double check for ft->mnt_dir and decode_octal.

This commit is contained in:
wbaumann 2012-01-21 20:47:50 +00:00
parent b3b534c342
commit b9f1ccd793
2 changed files with 6 additions and 43 deletions

View File

@ -5,6 +5,9 @@ ChangeLog for davfs2
* mount_davfs.c, check_fstab, get_options, parse_persona: * mount_davfs.c, check_fstab, get_options, parse_persona:
Rename check_persona into parse_persona. Rename check_persona into parse_persona.
Set n_args->uid and n_args->gid in check_fstab. Set n_args->uid and n_args->gid in check_fstab.
* mount_davfs.c, check_fstab:
Remove double check for ft->mnt_dir.
Remove unnecessary decode_octal.


2012-01-15 Werner Baumann (werner.baumann@onlinehome.de) 2012-01-15 Werner Baumann (werner.baumann@onlinehome.de)
* mount_davfs.c, parse_config, new_args: * mount_davfs.c, parse_config, new_args:

View File

@ -184,9 +184,6 @@ debug_opts(const char *s);
static int static int
debug_opts_neon(const char *s); debug_opts_neon(const char *s);


static char *
decode_octal(const char *s);

static void static void
delete_args(dav_args *args); delete_args(dav_args *args);


@ -690,7 +687,7 @@ check_fstab(const dav_args *args)
error(EXIT_FAILURE, errno, _("can't open file %s"), _PATH_MNTTAB); error(EXIT_FAILURE, errno, _("can't open file %s"), _PATH_MNTTAB);


struct mntent *ft = getmntent(fstab); struct mntent *ft = getmntent(fstab);
while (ft && ft->mnt_dir) { while (ft) {
if (ft->mnt_dir) { if (ft->mnt_dir) {
char *mp = canonicalize_file_name(ft->mnt_dir); char *mp = canonicalize_file_name(ft->mnt_dir);
if (mp) { if (mp) {
@ -707,12 +704,8 @@ check_fstab(const dav_args *args)
error(EXIT_FAILURE, 0, _("no entry for %s found in %s"), mpoint, error(EXIT_FAILURE, 0, _("no entry for %s found in %s"), mpoint,
_PATH_MNTTAB); _PATH_MNTTAB);


if (strcmp(url, ft->mnt_fsname) != 0) { if (strcmp(url, ft->mnt_fsname) != 0)
char *fstab_url = decode_octal(ft->mnt_fsname); error(EXIT_FAILURE, 0, _("different URL in %s"), _PATH_MNTTAB);
if (strcmp(url, fstab_url) != 0)
error(EXIT_FAILURE, 0, _("different URL in %s"), _PATH_MNTTAB);
free(fstab_url);
}


if (!ft->mnt_type || strcmp(DAV_FS_TYPE, ft->mnt_type) != 0) if (!ft->mnt_type || strcmp(DAV_FS_TYPE, ft->mnt_type) != 0)
error(EXIT_FAILURE, 0, _("different file system type in %s"), error(EXIT_FAILURE, 0, _("different file system type in %s"),
@ -1480,39 +1473,6 @@ debug_opts_neon(const char *s)
} }




/* Searches string s for octal encoded characters (like \040 for space).
It returns a new string where these have been replaced by the
respective characters. */
static char *
decode_octal(const char *s)
{
const char *old = s;
char *decoded = calloc(strlen(s) +1, 1);
if (!decoded) abort();
while (*old != '\0') {
char *pos = strstr(old, "\\0");
if (pos) {
char *tail;
int c = strtol(pos + 1, &tail, 8);
if ((tail - pos) == 4 && c != 0 && c >= CHAR_MIN && c <= CHAR_MAX) {
strncat(decoded, old, pos - old);
*(decoded + strlen(decoded)) = c;
old = tail;
} else {
pos += 2;
strncat(decoded, old, pos - old);
old = pos;
}
} else {
strcat(decoded, old);
old += strlen(old);
}
}
return decoded;
}


/* Frees all strings and arrays held by args and finally frees args. */ /* Frees all strings and arrays held by args and finally frees args. */
static void static void
delete_args(dav_args *args) delete_args(dav_args *args)