diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-02-03 11:51:54 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-02-03 11:51:54 +0100 |
commit | 25ce7cfc93d5f7422524ab6f787868ed9a43b93c (patch) | |
tree | 41e9f400fa1aabb90e11466a962d37f04653dda4 | |
parent | 35566ad3a6714dc312508934379663dab17655c0 (diff) |
add ajoin.patch
-rw-r--r-- | debian/patches/ajoin.patch | 63 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 64 insertions, 0 deletions
diff --git a/debian/patches/ajoin.patch b/debian/patches/ajoin.patch new file mode 100644 index 00000000..dcda59bd --- /dev/null +++ b/debian/patches/ajoin.patch @@ -0,0 +1,63 @@ +From 00f493fb731f677e037baecded7b8fa066739ad6 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Tue, 3 Feb 2015 11:50:36 +0100 +Subject: [PATCH hurd] XXX libdiskfs: avoid frequent asprintf in dir_lookup + +--- + libdiskfs/dir-lookup.c | 26 +++++++++++++++++++++----- + 1 file changed, 21 insertions(+), 5 deletions(-) + +diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c +index f3364cd..c1f7a68 100644 +--- a/libdiskfs/dir-lookup.c ++++ b/libdiskfs/dir-lookup.c +@@ -26,6 +26,25 @@ + #include "priv.h" + #include "fs_S.h" + ++/* Join paths A and B. The result is allocated using malloc. */ ++static inline char * ++ajoin (const char *a, const char *b) ++{ ++ char *result; ++ size_t sa, sb; ++ sa = strlen (a); ++ sb = strlen (b); ++ result = malloc (sa + sb + 2); ++ if (result) ++ { ++ memcpy (result, a, sa); ++ result[sa] = '/'; ++ memcpy (result + sa + 1, b, sb); ++ result[sa + sb + 1] = 0; ++ } ++ return result; ++} ++ + /* Implement dir_lookup as described in <hurd/fs.defs>. */ + kern_return_t + diskfs_S_dir_lookup (struct protid *dircred, +@@ -331,7 +350,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + /* dircred is the root directory. */ + complete_path = translator_path; + else +- asprintf (&complete_path, "%s/%s", dircred->po->path, translator_path); ++ complete_path = ajoin (dircred->po->path, translator_path); + + error = fshelp_set_active_translator (&newpi->pi, + complete_path, +@@ -535,10 +554,7 @@ diskfs_S_dir_lookup (struct protid *dircred, + relpath = NULL; /* Do not free relpath. */ + } + else +- { +- newpi->po->path = NULL; +- asprintf (&newpi->po->path, "%s/%s", dircred->po->path, relpath); +- } ++ newpi->po->path = ajoin (dircred->po->path, relpath); + + if (! newpi->po->path) + error = errno; +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 467a9c53..ccf870f4 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -52,3 +52,4 @@ thomas_term.patch 0005-bootshell-add-facility-to-load-embedded-scripts.patch 0006-bootshell-improve-error-message.patch 0007-XXX-bootshell.patch +ajoin.patch |