diff options
author | Justus Winter <justus@gnupg.org> | 2016-04-19 12:38:35 +0200 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2016-04-19 12:38:35 +0200 |
commit | cd9cf221f1aaf4b68a9facd9659eb8e170cf05de (patch) | |
tree | ef8c69649185973a22860123a35a49c0ab460d97 /debian/patches | |
parent | e39094c03508c3528497ea14155c6018a6edba69 (diff) |
add patch series
Diffstat (limited to 'debian/patches')
5 files changed, 1134 insertions, 0 deletions
diff --git a/debian/patches/fs_unification0001-libnetfs-rename-error-to-err.patch b/debian/patches/fs_unification0001-libnetfs-rename-error-to-err.patch new file mode 100644 index 00000000..59a7e67a --- /dev/null +++ b/debian/patches/fs_unification0001-libnetfs-rename-error-to-err.patch @@ -0,0 +1,259 @@ +From 615c6671376c8c5fa940d13ceee26f80f021bf43 Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Mon, 18 Apr 2016 19:00:31 +0200 +Subject: [PATCH hurd 1/4] libnetfs: rename 'error' to 'err' + +* libnetfs/dir-lookup.c (netfs_S_dir_lookup): Rename 'error' to 'err'. +--- + libnetfs/dir-lookup.c | 92 +++++++++++++++++++++++++-------------------------- + 1 file changed, 46 insertions(+), 46 deletions(-) + +diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c +index cbe2941..9a92c29 100644 +--- a/libnetfs/dir-lookup.c ++++ b/libnetfs/dir-lookup.c +@@ -48,7 +48,7 @@ netfs_S_dir_lookup (struct protid *diruser, + struct node *dnp, *np; + char *nextname; + char *relpath; +- error_t error; ++ error_t err; + struct protid *newpi = NULL; + struct iouser *user; + +@@ -132,7 +132,7 @@ netfs_S_dir_lookup (struct protid *diruser, + strcpy (retry_name, "/"); + else if (!lastcomp) + strcpy (retry_name, nextname); +- error = 0; ++ err = 0; + pthread_mutex_unlock (&dnp->lock); + goto out; + } +@@ -148,40 +148,40 @@ netfs_S_dir_lookup (struct protid *diruser, + strcpy (retry_name, "/"); + else if (!lastcomp) + strcpy (retry_name, nextname); +- error = 0; ++ err = 0; + pthread_mutex_unlock (&dnp->lock); + goto out; + } + else + /* We are global root */ + { +- error = 0; ++ err = 0; + np = dnp; + netfs_nref (np); + } + else + /* Attempt a lookup on the next pathname component. */ +- error = netfs_attempt_lookup (diruser->user, dnp, filename, &np); ++ err = netfs_attempt_lookup (diruser->user, dnp, filename, &np); + + /* At this point, DNP is unlocked */ + + /* Implement O_EXCL flag here */ +- if (lastcomp && create && excl && !error) +- error = EEXIST; ++ if (lastcomp && create && excl && !err) ++ err = EEXIST; + + /* Create the new node if necessary */ +- if (lastcomp && create && error == ENOENT) ++ if (lastcomp && create && err == ENOENT) + { + mode &= ~(S_IFMT | S_ISPARE | S_ISVTX); + mode |= S_IFREG; + pthread_mutex_lock (&dnp->lock); +- error = netfs_attempt_create_file (diruser->user, dnp, +- filename, mode, &np); ++ err = netfs_attempt_create_file (diruser->user, dnp, ++ filename, mode, &np); + + /* If someone has already created the file (between our lookup + and this create) then we just got EEXIST. If we are + EXCL, that's fine; otherwise, we have to retry the lookup. */ +- if (error == EEXIST && !excl) ++ if (err == EEXIST && !excl) + { + pthread_mutex_lock (&dnp->lock); + goto retry_lookup; +@@ -191,11 +191,11 @@ netfs_S_dir_lookup (struct protid *diruser, + } + + /* All remaining errors get returned to the user */ +- if (error) ++ if (err) + goto out; + +- error = netfs_validate_stat (np, diruser->user); +- if (error) ++ err = netfs_validate_stat (np, diruser->user); ++ if (err) + goto out; + + if ((((flags & O_NOTRANS) == 0) || !lastcomp || mustbedir) +@@ -251,21 +251,21 @@ netfs_S_dir_lookup (struct protid *diruser, + + /* Create an unauthenticated port for DNP, and then + unlock it. */ +- error = iohelp_create_empty_iouser (&user); +- if (! error) ++ err = iohelp_create_empty_iouser (&user); ++ if (! err) + { + newpi = netfs_make_protid (netfs_make_peropen (dnp, 0, + diruser->po), + user); + if (! newpi) + { +- error = errno; ++ err = errno; + iohelp_free_iouser (user); + } + } + + boolean_t register_translator = 0; +- if (! error) ++ if (! err) + { + dirport = ports_get_send_right (newpi); + +@@ -275,24 +275,24 @@ netfs_S_dir_lookup (struct protid *diruser, + translators. */ + register_translator = np->transbox.active == MACH_PORT_NULL; + +- error = fshelp_fetch_root (&np->transbox, diruser->po, +- dirport, +- diruser->user, +- lastcomp ? flags : 0, +- ((np->nn_translated & S_IPTRANS) +- ? _netfs_translator_callback1 +- : short_circuited_callback1), +- _netfs_translator_callback2, +- do_retry, retry_name, retry_port); ++ err = fshelp_fetch_root (&np->transbox, diruser->po, ++ dirport, ++ diruser->user, ++ lastcomp ? flags : 0, ++ ((np->nn_translated & S_IPTRANS) ++ ? _netfs_translator_callback1 ++ : short_circuited_callback1), ++ _netfs_translator_callback2, ++ do_retry, retry_name, retry_port); + /* fetch_root copies DIRPORT for success, so we always should + deallocate our send right. */ + mach_port_deallocate (mach_task_self (), dirport); + } + +- if (error != ENOENT) ++ if (err != ENOENT) + { + *retry_port_type = MACH_MSG_TYPE_MOVE_SEND; +- if (!error) ++ if (!err) + { + char *end = strchr (retry_name, '\0'); + if (mustbedir) +@@ -326,12 +326,12 @@ netfs_S_dir_lookup (struct protid *diruser, + else + asprintf (&complete_path, "%s/%s", diruser->po->path, translator_path); + +- error = fshelp_set_active_translator (&newpi->pi, +- complete_path, +- np->transbox.active); ++ err = fshelp_set_active_translator (&newpi->pi, ++ complete_path, ++ np->transbox.active); + if (complete_path != translator_path) + free(complete_path); +- if (error) ++ if (err) + { + ports_port_deref (newpi); + goto out; +@@ -346,7 +346,7 @@ netfs_S_dir_lookup (struct protid *diruser, + + /* ENOENT means there was a hiccup, and the translator vanished + while NP was unlocked inside fshelp_fetch_root; continue as normal. */ +- error = 0; ++ err = 0; + } + + if (S_ISLNK (np->nn_translated) +@@ -360,7 +360,7 @@ netfs_S_dir_lookup (struct protid *diruser, + /* Handle symlink interpretation */ + if (nsymlinks++ > netfs_maxsymlinks) + { +- error = ELOOP; ++ err = ELOOP; + goto out; + } + +@@ -370,8 +370,8 @@ netfs_S_dir_lookup (struct protid *diruser, + newnamelen = nextnamelen + linklen + 1 + 1; + linkbuf = alloca (newnamelen); + +- error = netfs_attempt_readlink (diruser->user, np, linkbuf); +- if (error) ++ err = netfs_attempt_readlink (diruser->user, np, linkbuf); ++ if (err) + goto out; + + if (nextname) +@@ -436,19 +436,19 @@ netfs_S_dir_lookup (struct protid *diruser, + netfs_validate_stat (np, diruser->user); + if (!S_ISDIR (np->nn_stat.st_mode)) + { +- error = ENOTDIR; ++ err = ENOTDIR; + goto out; + } + } +- error = netfs_check_open_permissions (diruser->user, np, +- flags, newnode); +- if (error) ++ err = netfs_check_open_permissions (diruser->user, np, ++ flags, newnode); ++ if (err) + goto out; + + flags &= ~OPENONLY_STATE_MODES; + +- error = iohelp_dup_iouser (&user, diruser->user); +- if (error) ++ err = iohelp_dup_iouser (&user, diruser->user); ++ if (err) + goto out; + + newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po), +@@ -456,7 +456,7 @@ netfs_S_dir_lookup (struct protid *diruser, + if (! newpi) + { + iohelp_free_iouser (user); +- error = errno; ++ err = errno; + goto out; + } + +@@ -474,7 +474,7 @@ netfs_S_dir_lookup (struct protid *diruser, + } + + if (! newpi->po->path) +- error = errno; ++ err = errno; + + *retry_port = ports_get_right (newpi); + ports_port_deref (newpi); +@@ -485,5 +485,5 @@ netfs_S_dir_lookup (struct protid *diruser, + if (dnp) + netfs_nrele (dnp); + free (relpath); +- return error; ++ return err; + } +-- +2.1.4 + diff --git a/debian/patches/fs_unification0002-libnetfs-rename-diruser-to-dircred.patch b/debian/patches/fs_unification0002-libnetfs-rename-diruser-to-dircred.patch new file mode 100644 index 00000000..2ecaeccf --- /dev/null +++ b/debian/patches/fs_unification0002-libnetfs-rename-diruser-to-dircred.patch @@ -0,0 +1,226 @@ +From 07153eadf3bfbf47b375e1662129ce0b7747ac5d Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Mon, 18 Apr 2016 19:06:59 +0200 +Subject: [PATCH hurd 2/4] libnetfs: rename 'diruser' to 'dircred' + +* libnetfs/dir-lookup.c (netfs_S_dir_lookup): Rename 'diruser' to +'dircred'. +--- + libnetfs/dir-lookup.c | 58 +++++++++++++++++++++++++-------------------------- + 1 file changed, 29 insertions(+), 29 deletions(-) + +diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c +index 9a92c29..caeb151 100644 +--- a/libnetfs/dir-lookup.c ++++ b/libnetfs/dir-lookup.c +@@ -30,7 +30,7 @@ + #include "misc.h" + + error_t +-netfs_S_dir_lookup (struct protid *diruser, ++netfs_S_dir_lookup (struct protid *dircred, + char *filename, + int flags, + mode_t mode, +@@ -52,7 +52,7 @@ netfs_S_dir_lookup (struct protid *diruser, + struct protid *newpi = NULL; + struct iouser *user; + +- if (!diruser) ++ if (!dircred) + return EOPNOTSUPP; + + create = (flags & O_CREAT); +@@ -62,7 +62,7 @@ netfs_S_dir_lookup (struct protid *diruser, + while (*filename == '/') + filename++; + +- /* Preserve the path relative to diruser->po->path. */ ++ /* Preserve the path relative to dircred->po->path. */ + relpath = strdup (filename); + if (! relpath) + return ENOMEM; +@@ -79,13 +79,13 @@ netfs_S_dir_lookup (struct protid *diruser, + { + /* Set things up in the state expected by the code from gotit: on. */ + dnp = 0; +- np = diruser->po->np; ++ np = dircred->po->np; + pthread_mutex_lock (&np->lock); + netfs_nref (np); + goto gotit; + } + +- dnp = diruser->po->np; ++ dnp = dircred->po->np; + pthread_mutex_lock (&dnp->lock); + + netfs_nref (dnp); /* acquire a reference for later netfs_nput */ +@@ -120,13 +120,13 @@ netfs_S_dir_lookup (struct protid *diruser, + + retry_lookup: + +- if ((dnp == netfs_root_node || dnp == diruser->po->shadow_root) ++ if ((dnp == netfs_root_node || dnp == dircred->po->shadow_root) + && filename[0] == '.' && filename[1] == '.' && filename[2] == '\0') +- if (dnp == diruser->po->shadow_root) ++ if (dnp == dircred->po->shadow_root) + /* We're at the root of a shadow tree. */ + { + *do_retry = FS_RETRY_REAUTH; +- *retry_port = diruser->po->shadow_root_parent; ++ *retry_port = dircred->po->shadow_root_parent; + *retry_port_type = MACH_MSG_TYPE_COPY_SEND; + if (lastcomp && mustbedir) /* Trailing slash. */ + strcpy (retry_name, "/"); +@@ -136,13 +136,13 @@ netfs_S_dir_lookup (struct protid *diruser, + pthread_mutex_unlock (&dnp->lock); + goto out; + } +- else if (diruser->po->root_parent != MACH_PORT_NULL) +- /* We're at a real translator root; even if DIRUSER->po has a ++ else if (dircred->po->root_parent != MACH_PORT_NULL) ++ /* We're at a real translator root; even if DIRCRED->po has a + shadow root, we can get here if its in a directory that was + renamed out from under it... */ + { + *do_retry = FS_RETRY_REAUTH; +- *retry_port = diruser->po->root_parent; ++ *retry_port = dircred->po->root_parent; + *retry_port_type = MACH_MSG_TYPE_COPY_SEND; + if (lastcomp && mustbedir) /* Trailing slash. */ + strcpy (retry_name, "/"); +@@ -161,7 +161,7 @@ netfs_S_dir_lookup (struct protid *diruser, + } + else + /* Attempt a lookup on the next pathname component. */ +- err = netfs_attempt_lookup (diruser->user, dnp, filename, &np); ++ err = netfs_attempt_lookup (dircred->user, dnp, filename, &np); + + /* At this point, DNP is unlocked */ + +@@ -175,7 +175,7 @@ netfs_S_dir_lookup (struct protid *diruser, + mode &= ~(S_IFMT | S_ISPARE | S_ISVTX); + mode |= S_IFREG; + pthread_mutex_lock (&dnp->lock); +- err = netfs_attempt_create_file (diruser->user, dnp, ++ err = netfs_attempt_create_file (dircred->user, dnp, + filename, mode, &np); + + /* If someone has already created the file (between our lookup +@@ -194,7 +194,7 @@ netfs_S_dir_lookup (struct protid *diruser, + if (err) + goto out; + +- err = netfs_validate_stat (np, diruser->user); ++ err = netfs_validate_stat (np, dircred->user); + if (err) + goto out; + +@@ -216,7 +216,7 @@ netfs_S_dir_lookup (struct protid *diruser, + struct node *np = cookie1; + error_t err; + +- err = netfs_validate_stat (np, diruser->user); ++ err = netfs_validate_stat (np, dircred->user); + if (err) + return err; + +@@ -255,7 +255,7 @@ netfs_S_dir_lookup (struct protid *diruser, + if (! err) + { + newpi = netfs_make_protid (netfs_make_peropen (dnp, 0, +- diruser->po), ++ dircred->po), + user); + if (! newpi) + { +@@ -275,9 +275,9 @@ netfs_S_dir_lookup (struct protid *diruser, + translators. */ + register_translator = np->transbox.active == MACH_PORT_NULL; + +- err = fshelp_fetch_root (&np->transbox, diruser->po, ++ err = fshelp_fetch_root (&np->transbox, dircred->po, + dirport, +- diruser->user, ++ dircred->user, + lastcomp ? flags : 0, + ((np->nn_translated & S_IPTRANS) + ? _netfs_translator_callback1 +@@ -320,11 +320,11 @@ netfs_S_dir_lookup (struct protid *diruser, + translator_path[end - filename_start] = '\0'; + } + +- if (diruser->po->path == NULL || !strcmp (diruser->po->path,".")) +- /* diruser is the root directory. */ ++ if (dircred->po->path == NULL || !strcmp (dircred->po->path,".")) ++ /* dircred is the root directory. */ + complete_path = translator_path; + else +- asprintf (&complete_path, "%s/%s", diruser->po->path, translator_path); ++ asprintf (&complete_path, "%s/%s", dircred->po->path, translator_path); + + err = fshelp_set_active_translator (&newpi->pi, + complete_path, +@@ -370,7 +370,7 @@ netfs_S_dir_lookup (struct protid *diruser, + newnamelen = nextnamelen + linklen + 1 + 1; + linkbuf = alloca (newnamelen); + +- err = netfs_attempt_readlink (diruser->user, np, linkbuf); ++ err = netfs_attempt_readlink (dircred->user, np, linkbuf); + if (err) + goto out; + +@@ -433,25 +433,25 @@ netfs_S_dir_lookup (struct protid *diruser, + + if (mustbedir) + { +- netfs_validate_stat (np, diruser->user); ++ netfs_validate_stat (np, dircred->user); + if (!S_ISDIR (np->nn_stat.st_mode)) + { + err = ENOTDIR; + goto out; + } + } +- err = netfs_check_open_permissions (diruser->user, np, ++ err = netfs_check_open_permissions (dircred->user, np, + flags, newnode); + if (err) + goto out; + + flags &= ~OPENONLY_STATE_MODES; + +- err = iohelp_dup_iouser (&user, diruser->user); ++ err = iohelp_dup_iouser (&user, dircred->user); + if (err) + goto out; + +- newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po), ++ newpi = netfs_make_protid (netfs_make_peropen (np, flags, dircred->po), + user); + if (! newpi) + { +@@ -461,16 +461,16 @@ netfs_S_dir_lookup (struct protid *diruser, + } + + free (newpi->po->path); +- if (diruser->po->path == NULL || !strcmp (diruser->po->path,".")) ++ if (dircred->po->path == NULL || !strcmp (dircred->po->path,".")) + { +- /* diruser is the root directory. */ ++ /* dircred is the root directory. */ + newpi->po->path = relpath; + relpath = NULL; /* Do not free relpath. */ + } + else + { + newpi->po->path = NULL; +- asprintf (&newpi->po->path, "%s/%s", diruser->po->path, relpath); ++ asprintf (&newpi->po->path, "%s/%s", dircred->po->path, relpath); + } + + if (! newpi->po->path) +-- +2.1.4 + diff --git a/debian/patches/fs_unification0003-libdiskfs-cosmetic-changes.patch b/debian/patches/fs_unification0003-libdiskfs-cosmetic-changes.patch new file mode 100644 index 00000000..8c5483aa --- /dev/null +++ b/debian/patches/fs_unification0003-libdiskfs-cosmetic-changes.patch @@ -0,0 +1,314 @@ +From d3be2913b8a5dbdb827a6724eb6c62791e903e3a Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Mon, 18 Apr 2016 19:33:03 +0200 +Subject: [PATCH hurd 3/4] libdiskfs: cosmetic changes + +* libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Rename identifiers to +be more idiomatic and closer to libnetfs and the interface +specification. Massage the code so that it aligns closer with the +dir_lookup server function in libnetfs. It should not change the +behavior. +--- + libdiskfs/dir-lookup.c | 113 +++++++++++++++++++++++++------------------------ + 1 file changed, 57 insertions(+), 56 deletions(-) + +diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c +index c50970d..72ada0f 100644 +--- a/libdiskfs/dir-lookup.c ++++ b/libdiskfs/dir-lookup.c +@@ -27,19 +27,19 @@ + #include "fs_S.h" + + /* Implement dir_lookup as described in <hurd/fs.defs>. */ +-kern_return_t ++error_t + diskfs_S_dir_lookup (struct protid *dircred, +- char *path, ++ char *filename, + int flags, + mode_t mode, +- enum retry_type *retry, +- char *retryname, +- file_t *returned_port, +- mach_msg_type_name_t *returned_port_poly) ++ retry_type *do_retry, ++ char *retry_name, ++ mach_port_t *retry_port, ++ mach_msg_type_name_t *retry_port_type) + { + struct node *dnp; + struct node *np; +- int nsymlink = 0; ++ int nsymlinks = 0; + char *nextname; + char *relpath; + int nextnamelen; +@@ -66,23 +66,23 @@ diskfs_S_dir_lookup (struct protid *dircred, + excl = (flags & O_EXCL); + + /* Skip leading slashes */ +- while (path[0] == '/') +- path++; ++ while (*filename == '/') ++ filename++; + +- /* Preserve the path relative to diruser->po->path. */ +- relpath = strdup (path); ++ /* Preserve the path relative to dircred->po->path. */ ++ relpath = strdup (filename); + if (! relpath) + return ENOMEM; + +- /* Keep a pointer to the start of the path for length ++ /* Keep a pointer to the start of the filename for length + calculations. */ +- char *path_start = path; ++ char *filename_start = filename; + +- *returned_port_poly = MACH_MSG_TYPE_MAKE_SEND; +- *retry = FS_RETRY_NORMAL; +- retryname[0] = '\0'; ++ *retry_port_type = MACH_MSG_TYPE_MAKE_SEND; ++ *do_retry = FS_RETRY_NORMAL; ++ *retry_name = '\0'; + +- if (path[0] == '\0') ++ if (*filename == '\0') + { + /* Set things up in the state expected by the code from gotit: on. */ + dnp = 0; +@@ -93,9 +93,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + } + + dnp = dircred->po->np; +- + pthread_mutex_lock (&dnp->lock); +- np = 0; + + diskfs_nref (dnp); /* acquire a reference for later diskfs_nput */ + +@@ -104,7 +102,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + assert (!lastcomp); + + /* Find the name of the next pathname component */ +- nextname = index (path, '/'); ++ nextname = index (filename, '/'); + + if (nextname) + { +@@ -132,10 +130,10 @@ diskfs_S_dir_lookup (struct protid *dircred, + { + if (!ds) + ds = alloca (diskfs_dirstat_size); +- err = diskfs_lookup (dnp, path, CREATE, &np, ds, dircred); ++ err = diskfs_lookup (dnp, filename, CREATE, &np, ds, dircred); + } + else +- err = diskfs_lookup (dnp, path, LOOKUP, &np, 0, dircred); ++ err = diskfs_lookup (dnp, filename, LOOKUP, &np, 0, dircred); + + if (lastcomp && create && excl && (!err || err == EAGAIN)) + err = EEXIST; +@@ -158,13 +156,13 @@ diskfs_S_dir_lookup (struct protid *dircred, + else + { + /* Punt the client up to the shadow root parent. */ +- *retry = FS_RETRY_REAUTH; +- *returned_port = dircred->po->shadow_root_parent; +- *returned_port_poly = MACH_MSG_TYPE_COPY_SEND; ++ *do_retry = FS_RETRY_REAUTH; ++ *retry_port = dircred->po->shadow_root_parent; ++ *retry_port_type = MACH_MSG_TYPE_COPY_SEND; + if (lastcomp && mustbedir) /* Trailing slash. */ +- strcpy (retryname, "/"); ++ strcpy (retry_name, "/"); + else if (!lastcomp) +- strcpy (retryname, nextname); ++ strcpy (retry_name, nextname); + err = 0; + goto out; + } +@@ -174,13 +172,13 @@ diskfs_S_dir_lookup (struct protid *dircred, + shadow root, we can get here if its in a directory that was + renamed out from under it... */ + { +- *retry = FS_RETRY_REAUTH; +- *returned_port = dircred->po->root_parent; +- *returned_port_poly = MACH_MSG_TYPE_COPY_SEND; ++ *do_retry = FS_RETRY_REAUTH; ++ *retry_port = dircred->po->root_parent; ++ *retry_port_type = MACH_MSG_TYPE_COPY_SEND; + if (lastcomp && mustbedir) /* Trailing slash. */ +- strcpy (retryname, "/"); ++ strcpy (retry_name, "/"); + else if (!lastcomp) +- strcpy (retryname, nextname); ++ strcpy (retry_name, nextname); + err = 0; + goto out; + } +@@ -200,7 +198,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + { + mode &= ~(S_IFMT | S_ISPARE | S_ISVTX | S_ITRANS); + mode |= S_IFREG; +- err = diskfs_create_node (dnp, path, mode, &np, dircred, ds); ++ err = diskfs_create_node (dnp, filename, mode, &np, dircred, ds); + if (diskfs_synchronous) + { + diskfs_file_update (dnp, 1); +@@ -228,7 +226,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + struct iouser *user; + + /* A callback function for short-circuited translators. +- Symlink & ifsock are handled elsewhere. */ ++ S_ISLNK and S_IFSOCK are handled elsewhere. */ + error_t short_circuited_callback1 (void *cookie1, void *cookie2, + uid_t *uid, gid_t *gid, + char **argz, size_t *argz_len) +@@ -239,17 +237,19 @@ diskfs_S_dir_lookup (struct protid *dircred, + { + case S_IFCHR: + case S_IFBLK: +- asprintf (argz, "%s%c%d%c%d", +- (S_ISCHR (node->dn_stat.st_mode) +- ? _HURD_CHRDEV : _HURD_BLKDEV), +- 0, major (node->dn_stat.st_rdev), +- 0, minor (node->dn_stat.st_rdev)); ++ if (asprintf (argz, "%s%c%d%c%d", ++ (S_ISCHR (node->dn_stat.st_mode) ++ ? _HURD_CHRDEV : _HURD_BLKDEV), ++ 0, major (node->dn_stat.st_rdev), ++ 0, minor (node->dn_stat.st_rdev)) < 0) ++ return ENOMEM; + *argz_len = strlen (*argz) + 1; + *argz_len += strlen (*argz + *argz_len) + 1; + *argz_len += strlen (*argz + *argz_len) + 1; + break; + case S_IFIFO: +- asprintf (argz, "%s", _HURD_FIFO); ++ if (asprintf (argz, "%s", _HURD_FIFO) < 0) ++ return ENOMEM; + *argz_len = strlen (*argz) + 1; + break; + default: +@@ -299,7 +299,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + ? _diskfs_translator_callback1 + : short_circuited_callback1), + _diskfs_translator_callback2, +- retry, retryname, returned_port); ++ do_retry, retry_name, retry_port); + + /* fetch_root copies DIRPORT for success, so we always should + deallocate our send right. */ +@@ -307,14 +307,14 @@ diskfs_S_dir_lookup (struct protid *dircred, + + if (err != ENOENT) + { +- *returned_port_poly = MACH_MSG_TYPE_MOVE_SEND; ++ *retry_port_type = MACH_MSG_TYPE_MOVE_SEND; + if (!err) + { +- char *end = strchr (retryname, '\0'); ++ char *end = strchr (retry_name, '\0'); + if (mustbedir) + *end++ = '/'; /* Trailing slash. */ + else if (!lastcomp) { +- if (end != retryname) ++ if (end != retry_name) + *end++ = '/'; + strcpy (end, nextname); + } +@@ -333,7 +333,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + char *end = nextname; + while (*end != 0) + end--; +- translator_path[end - path_start] = '\0'; ++ translator_path[end - filename_start] = '\0'; + } + + if (dircred->po->path == NULL || !strcmp (dircred->po->path,".")) +@@ -363,7 +363,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + err = 0; + if (np != dnp) + { +- if (!strcmp (path, "..")) ++ if (!strcmp (filename, "..")) + pthread_mutex_lock (&dnp->lock); + else + { +@@ -384,7 +384,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + { + /* Handle symlink interpretation */ + +- if (nsymlink++ > diskfs_maxsymlinks) ++ if (nsymlinks++ > diskfs_maxsymlinks) + { + err = ELOOP; + goto out; +@@ -412,7 +412,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + goto out; + + if (np->dn_stat.st_size == 0) /* symlink to "" */ +- path = nextname; ++ filename = nextname; + else + { + if (nextname) +@@ -432,13 +432,13 @@ diskfs_S_dir_lookup (struct protid *dircred, + if (pathbuf[0] == '/') + { + /* Punt to the caller. */ +- *retry = FS_RETRY_MAGICAL; +- *returned_port = MACH_PORT_NULL; +- strcpy (retryname, pathbuf); ++ *do_retry = FS_RETRY_MAGICAL; ++ *retry_port = MACH_PORT_NULL; ++ strcpy (retry_name, pathbuf); + goto out; + } + +- path = pathbuf; ++ filename = pathbuf; + mustbedir = 0; + } + +@@ -448,7 +448,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + diskfs_nput (np); + np = 0; + +- if (path == 0) /* symlink to "" was the last component */ ++ if (filename == 0) /* symlink to "" was the last component */ + { + np = dnp; + dnp = 0; +@@ -458,7 +458,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + else + { + /* Handle normal nodes */ +- path = nextname; ++ filename = nextname; + if (np == dnp) + diskfs_nrele (dnp); + else +@@ -471,7 +471,8 @@ diskfs_S_dir_lookup (struct protid *dircred, + else + dnp = 0; + } +- } while (path && *path); ++ } ++ while (filename && *filename); + + /* At this point, np is the node to return. If newnode is set, then + we just created this node. */ +@@ -553,7 +554,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + if (! newpi->po->path) + err = errno; + +- *returned_port = ports_get_right (newpi); ++ *retry_port = ports_get_right (newpi); + ports_port_deref (newpi); + newpi = 0; + } +-- +2.1.4 + diff --git a/debian/patches/fs_unification0004-YYY-Unify-the-short-circuit-translator-logic.patch b/debian/patches/fs_unification0004-YYY-Unify-the-short-circuit-translator-logic.patch new file mode 100644 index 00000000..d2652bcc --- /dev/null +++ b/debian/patches/fs_unification0004-YYY-Unify-the-short-circuit-translator-logic.patch @@ -0,0 +1,331 @@ +From 5507188abfeaf049bcf43f23613d8ce4df95bcf3 Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Mon, 18 Apr 2016 21:53:28 +0200 +Subject: [PATCH hurd 4/4] YYY Unify the short-circuit translator logic + +* libdiskfs/dir-lookup.c (short_circuited_callback1): Drop function. +* libdiskfs/trans-callback.c +* libfshelp/fetch-root.c +* libfshelp/fshelp.h +* libnetfs/dir-lookup.c +* libnetfs/trans-callback.c +--- + libdiskfs/dir-lookup.c | 61 ++++++++++++---------------------------------- + libdiskfs/trans-callback.c | 4 ++- + libfshelp/fetch-root.c | 39 +++++++++++++++++++++++++++++ + libfshelp/fshelp.h | 16 ++++++++++++ + libnetfs/dir-lookup.c | 53 +++++++--------------------------------- + libnetfs/trans-callback.c | 4 ++- + 6 files changed, 86 insertions(+), 91 deletions(-) + +diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c +index 72ada0f..8b43e27 100644 +--- a/libdiskfs/dir-lookup.c ++++ b/libdiskfs/dir-lookup.c +@@ -20,6 +20,7 @@ + #include <fcntl.h> + #include <string.h> + #include <sys/file.h> ++#include <hurd/fshelp.h> + #include <hurd/fsys.h> + #include <hurd/paths.h> + +@@ -225,43 +226,6 @@ diskfs_S_dir_lookup (struct protid *dircred, + mach_port_t dirport; + struct iouser *user; + +- /* A callback function for short-circuited translators. +- S_ISLNK and S_IFSOCK are handled elsewhere. */ +- error_t short_circuited_callback1 (void *cookie1, void *cookie2, +- uid_t *uid, gid_t *gid, +- char **argz, size_t *argz_len) +- { +- struct node *node = cookie1; +- +- switch (node->dn_stat.st_mode & S_IFMT) +- { +- case S_IFCHR: +- case S_IFBLK: +- if (asprintf (argz, "%s%c%d%c%d", +- (S_ISCHR (node->dn_stat.st_mode) +- ? _HURD_CHRDEV : _HURD_BLKDEV), +- 0, major (node->dn_stat.st_rdev), +- 0, minor (node->dn_stat.st_rdev)) < 0) +- return ENOMEM; +- *argz_len = strlen (*argz) + 1; +- *argz_len += strlen (*argz + *argz_len) + 1; +- *argz_len += strlen (*argz + *argz_len) + 1; +- break; +- case S_IFIFO: +- if (asprintf (argz, "%s", _HURD_FIFO) < 0) +- return ENOMEM; +- *argz_len = strlen (*argz) + 1; +- break; +- default: +- return ENOENT; +- } +- +- *uid = node->dn_stat.st_uid; +- *gid = node->dn_stat.st_gid; +- +- return 0; +- } +- + /* Create an unauthenticated port for DNP, and then + unlock it. */ + err = iohelp_create_empty_iouser (&user); +@@ -292,14 +256,21 @@ diskfs_S_dir_lookup (struct protid *dircred, + boolean_t register_translator = + np->transbox.active == MACH_PORT_NULL; + +- err = fshelp_fetch_root (&np->transbox, dircred->po, +- dirport, dircred->user, +- lastcomp ? flags : 0, +- ((np->dn_stat.st_mode & S_IPTRANS) +- ? _diskfs_translator_callback1 +- : short_circuited_callback1), +- _diskfs_translator_callback2, +- do_retry, retry_name, retry_port); ++ struct fshelp_stat_cookie2 cookie = { ++ .statp = &np->dn_stat, ++ .modep = &np->dn_stat.st_mode, ++ .next = dircred->po, ++ }; ++ err = fshelp_fetch_root (&np->transbox, ++ &cookie, ++ dirport, ++ dircred->user, ++ lastcomp ? flags : 0, ++ ((np->dn_stat.st_mode & S_IPTRANS) ++ ? _diskfs_translator_callback1 ++ : fshelp_short_circuited_callback1), ++ _diskfs_translator_callback2, ++ do_retry, retry_name, retry_port); + + /* fetch_root copies DIRPORT for success, so we always should + deallocate our send right. */ +diff --git a/libdiskfs/trans-callback.c b/libdiskfs/trans-callback.c +index 283b184..15e8f9a 100644 +--- a/libdiskfs/trans-callback.c ++++ b/libdiskfs/trans-callback.c +@@ -20,6 +20,7 @@ + + #include "priv.h" + #include <fcntl.h> ++#include <hurd/fshelp.h> + + /* Callback function needed for calls to fshelp_fetch_root. See + <hurd/fshelp.h> for the interface description. */ +@@ -56,6 +57,7 @@ _diskfs_translator_callback2_fn (void *cookie1, void *cookie2, + mach_msg_type_name_t *underlying_type) + { + struct node *np = cookie1; ++ struct fshelp_stat_cookie2 *statc = cookie2; + struct protid *cred; + struct peropen *po; + error_t err; +@@ -66,7 +68,7 @@ _diskfs_translator_callback2_fn (void *cookie1, void *cookie2, + if (err) + return err; + +- err = diskfs_make_peropen (np, flags, cookie2, &po); ++ err = diskfs_make_peropen (np, flags, statc->next, &po); + if (! err) + { + err = diskfs_create_protid (po, user, &cred); +diff --git a/libfshelp/fetch-root.c b/libfshelp/fetch-root.c +index cc9fa50..eb43993 100644 +--- a/libfshelp/fetch-root.c ++++ b/libfshelp/fetch-root.c +@@ -20,6 +20,7 @@ + + #include <assert.h> + #include <hurd/fsys.h> ++#include <hurd/paths.h> + #include <hurd/ports.h> + #include <stdlib.h> + #include <string.h> +@@ -197,3 +198,41 @@ fshelp_fetch_root (struct transbox *box, void *cookie, + + return err; + } ++ ++/* A callback function for short-circuited translators. S_ISLNK and ++ S_IFSOCK must be handled elsewhere. */ ++error_t ++fshelp_short_circuited_callback1 (void *cookie1, void *cookie2, ++ uid_t *uid, gid_t *gid, ++ char **argz, size_t *argz_len) ++{ ++ struct fshelp_stat_cookie2 *statc = cookie2; ++ ++ switch (*statc->modep & S_IFMT) ++ { ++ case S_IFCHR: ++ case S_IFBLK: ++ if (asprintf (argz, "%s%c%d%c%d", ++ (S_ISCHR (*statc->modep) ++ ? _HURD_CHRDEV : _HURD_BLKDEV), ++ 0, major (statc->statp->st_rdev), ++ 0, minor (statc->statp->st_rdev)) < 0) ++ return ENOMEM; ++ *argz_len = strlen (*argz) + 1; ++ *argz_len += strlen (*argz + *argz_len) + 1; ++ *argz_len += strlen (*argz + *argz_len) + 1; ++ break; ++ case S_IFIFO: ++ if (asprintf (argz, "%s", _HURD_FIFO) < 0) ++ return ENOMEM; ++ *argz_len = strlen (*argz) + 1; ++ break; ++ default: ++ return ENOENT; ++ } ++ ++ *uid = statc->statp->st_uid; ++ *gid = statc->statp->st_gid; ++ ++ return 0; ++} +diff --git a/libfshelp/fshelp.h b/libfshelp/fshelp.h +index d04c056..ecd9335 100644 +--- a/libfshelp/fshelp.h ++++ b/libfshelp/fshelp.h +@@ -148,6 +148,22 @@ typedef error_t (*fshelp_fetch_root_callback1_t) (void *cookie1, void *cookie2, + uid_t *uid, gid_t *gid, + char **argz, size_t *argz_len); + ++/* A cookie for fshelp_short_circuited_callback1. Such a structure ++ must be passed to the call to fshelp_fetch_root. */ ++struct fshelp_stat_cookie2 ++{ ++ io_statbuf_t *statp; ++ mode_t *modep; ++ void *next; ++}; ++ ++/* A callback function for short-circuited translators. S_ISLNK and ++ S_IFSOCK must be handled elsewhere. */ ++error_t fshelp_short_circuited_callback1 (void *cookie1, void *cookie2, ++ uid_t *uid, gid_t *gid, ++ char **argz, size_t *argz_len); ++ ++ + /* This routine is called by fshelp_fetch_root to fetch more information. + Return an unauthenticated node for the file itself in *UNDERLYING and + *UNDERLYING_TYPE (opened with FLAGS). COOKIE1 is the cookie passed in +diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c +index caeb151..3bcc745 100644 +--- a/libnetfs/dir-lookup.c ++++ b/libnetfs/dir-lookup.c +@@ -207,48 +207,6 @@ netfs_S_dir_lookup (struct protid *dircred, + { + mach_port_t dirport; + +- /* A callback function for short-circuited translators. +- S_ISLNK and S_IFSOCK are handled elsewhere. */ +- error_t short_circuited_callback1 (void *cookie1, void *cookie2, +- uid_t *uid, gid_t *gid, +- char **argz, size_t *argz_len) +- { +- struct node *np = cookie1; +- error_t err; +- +- err = netfs_validate_stat (np, dircred->user); +- if (err) +- return err; +- +- switch (np->nn_translated & S_IFMT) +- { +- case S_IFCHR: +- case S_IFBLK: +- if (asprintf (argz, "%s%c%d%c%d", +- (S_ISCHR (np->nn_translated) +- ? _HURD_CHRDEV : _HURD_BLKDEV), +- 0, major (np->nn_stat.st_rdev), +- 0, minor (np->nn_stat.st_rdev)) < 0) +- return ENOMEM; +- *argz_len = strlen (*argz) + 1; +- *argz_len += strlen (*argz + *argz_len) + 1; +- *argz_len += strlen (*argz + *argz_len) + 1; +- break; +- case S_IFIFO: +- if (asprintf (argz, "%s", _HURD_FIFO) < 0) +- return ENOMEM; +- *argz_len = strlen (*argz) + 1; +- break; +- default: +- return ENOENT; +- } +- +- *uid = np->nn_stat.st_uid; +- *gid = np->nn_stat.st_gid; +- +- return 0; +- } +- + /* Create an unauthenticated port for DNP, and then + unlock it. */ + err = iohelp_create_empty_iouser (&user); +@@ -267,6 +225,12 @@ netfs_S_dir_lookup (struct protid *dircred, + boolean_t register_translator = 0; + if (! err) + { ++ struct fshelp_stat_cookie2 cookie = { ++ .statp = &np->nn_stat, ++ .modep = &np->nn_translated, ++ .next = dircred->po, ++ }; ++ + dirport = ports_get_send_right (newpi); + + /* Check if an active translator is currently running. If +@@ -275,13 +239,14 @@ netfs_S_dir_lookup (struct protid *dircred, + translators. */ + register_translator = np->transbox.active == MACH_PORT_NULL; + +- err = fshelp_fetch_root (&np->transbox, dircred->po, ++ err = fshelp_fetch_root (&np->transbox, ++ &cookie, + dirport, + dircred->user, + lastcomp ? flags : 0, + ((np->nn_translated & S_IPTRANS) + ? _netfs_translator_callback1 +- : short_circuited_callback1), ++ : fshelp_short_circuited_callback1), + _netfs_translator_callback2, + do_retry, retry_name, retry_port); + /* fetch_root copies DIRPORT for success, so we always should +diff --git a/libnetfs/trans-callback.c b/libnetfs/trans-callback.c +index ed21aa2..99f4dc0 100644 +--- a/libnetfs/trans-callback.c ++++ b/libnetfs/trans-callback.c +@@ -20,6 +20,7 @@ + + #include "priv.h" + #include <fcntl.h> ++#include <hurd/fshelp.h> + + /* Callback function needed for calls to fshelp_fetch_root. See + <hurd/fshelp.h> for the interface description. */ +@@ -57,6 +58,7 @@ _netfs_translator_callback2_fn (void *cookie1, void *cookie2, int flags, + error_t err; + struct protid *cred; + struct node *node = cookie1; ++ struct fshelp_stat_cookie2 *statc = cookie2; + struct iouser *user; + struct peropen *po; + +@@ -65,7 +67,7 @@ _netfs_translator_callback2_fn (void *cookie1, void *cookie2, int flags, + if (err) + return err; + +- po = netfs_make_peropen (node, flags, cookie2); ++ po = netfs_make_peropen (node, flags, statc->next); + if (! po) + { + err = errno; +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 5ceec025..52855c11 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -39,3 +39,7 @@ crash0001-xxx-crash-logging-works.patch gpg0001-trans-add-identity-translator.patch gpg0002-trans-add-transparent-GnuPG-translator.patch libdiskfs-fix0001-libdiskfs-improve-error-handling.patch +fs_unification0001-libnetfs-rename-error-to-err.patch +fs_unification0002-libnetfs-rename-diruser-to-dircred.patch +fs_unification0003-libdiskfs-cosmetic-changes.patch +fs_unification0004-YYY-Unify-the-short-circuit-translator-logic.patch |