diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-10-27 18:32:35 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-10-27 18:32:35 +0100 |
commit | 9b6afcec2f6cfb2f0e0f01962f8d8fe6bd9f6762 (patch) | |
tree | fdd72e90d45d938c4c652ac2a6e97e4fd8bda95e /libdiskfs/dir-lookup.c | |
parent | 5e3bffe49bf5f6dd659e946b9e0b957dd16103c6 (diff) | |
download | hurd-9b6afcec2f6cfb2f0e0f01962f8d8fe6bd9f6762.tar.gz hurd-9b6afcec2f6cfb2f0e0f01962f8d8fe6bd9f6762.tar.bz2 hurd-9b6afcec2f6cfb2f0e0f01962f8d8fe6bd9f6762.zip |
libdiskfs: Do not register active translator if it failed to start
* libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Do not call
fshelp_set_active_translator if fshelp_fetch_root returned an error
which is not ENOENT.
Diffstat (limited to 'libdiskfs/dir-lookup.c')
-rw-r--r-- | libdiskfs/dir-lookup.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c index 05e3fc5b..b2d480f1 100644 --- a/libdiskfs/dir-lookup.c +++ b/libdiskfs/dir-lookup.c @@ -275,6 +275,10 @@ diskfs_S_dir_lookup (struct protid *dircred, if (!err) { char *end = strchr (retry_name, '\0'); + char *translator_path = strdupa (relpath); + char *end; + char *complete_path; + if (mustbedir) *end++ = '/'; /* Trailing slash. */ else if (!lastcomp) { @@ -282,45 +286,40 @@ diskfs_S_dir_lookup (struct protid *dircred, *end++ = '/'; strcpy (end, nextname); } - } - { - char *translator_path = strdupa (relpath); - char *end; - char *complete_path; - if (nextname != NULL) - { - /* This was not the last path component. - NEXTNAME points to the next component, locate - the end of the current component and use it - to trim TRANSLATOR_PATH. */ - end = nextname; - while (*end != 0) - end--; - translator_path[end - filename_start] = '\0'; - } + if (nextname != NULL) + { + /* This was not the last path component. + NEXTNAME points to the next component, locate + the end of the current component and use it + to trim TRANSLATOR_PATH. */ + end = nextname; + while (*end != 0) + end--; + translator_path[end - filename_start] = '\0'; + } - /* Trim trailing slashes. */ - end = &translator_path[strlen (translator_path) - 1]; - while (*end == '/' && end >= translator_path) - *end = '\0', end--; - - if (dircred->po->path == NULL - || !strcmp (dircred->po->path,".")) - /* dircred is the root directory. */ - complete_path = translator_path; - else - asprintf (&complete_path, "%s/%s", dircred->po->path, - translator_path); - - err = fshelp_set_active_translator (&newpi->pi, - complete_path, - &np->transbox); - if (complete_path != translator_path) - free(complete_path); - if (err) - goto out; - } + /* Trim trailing slashes. */ + end = &translator_path[strlen (translator_path) - 1]; + while (*end == '/' && end >= translator_path) + *end = '\0', end--; + + if (dircred->po->path == NULL + || !strcmp (dircred->po->path,".")) + /* dircred is the root directory. */ + complete_path = translator_path; + else + asprintf (&complete_path, "%s/%s", dircred->po->path, + translator_path); + + err = fshelp_set_active_translator (&newpi->pi, + complete_path, + &np->transbox); + if (complete_path != translator_path) + free(complete_path); + if (err) + goto out; + } goto out; } |