|
|
8fa62f |
autofs-5.1.5 - add glibc getmntent_r()
|
|
|
8fa62f |
|
|
|
8fa62f |
From: Ian Kent <raven@themaw.net>
|
|
|
8fa62f |
|
|
|
8fa62f |
Add a slightly modified version of the glibc getmntent_r() function
|
|
|
8fa62f |
so autofs can read the proc mount table directly.
|
|
|
8fa62f |
|
|
|
8fa62f |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
8fa62f |
---
|
|
|
8fa62f |
CHANGELOG | 1
|
|
|
8fa62f |
lib/mounts.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
8fa62f |
2 files changed, 96 insertions(+)
|
|
|
8fa62f |
|
|
|
8fa62f |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
8fa62f |
+++ autofs-5.1.4/CHANGELOG
|
|
|
8fa62f |
@@ -66,6 +66,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
8fa62f |
- use bit flags for autofs mount types in mnt_list.
|
|
|
8fa62f |
- use mp instead of path in mnt_list entries.
|
|
|
8fa62f |
- always use PROC_MOUNTS to make mount lists.
|
|
|
8fa62f |
+- add glibc getmntent_r().
|
|
|
8fa62f |
|
|
|
8fa62f |
19/12/2017 autofs-5.1.4
|
|
|
8fa62f |
- fix spec file url.
|
|
|
8fa62f |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
8fa62f |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
8fa62f |
@@ -786,6 +786,101 @@ done:
|
|
|
8fa62f |
return ret;
|
|
|
8fa62f |
}
|
|
|
8fa62f |
|
|
|
8fa62f |
+/* From glibc decode_name() */
|
|
|
8fa62f |
+/* Since the values in a line are separated by spaces, a name cannot
|
|
|
8fa62f |
+ * contain a space. Therefore some programs encode spaces in names
|
|
|
8fa62f |
+ * by the strings "\040". We undo the encoding when reading an entry.
|
|
|
8fa62f |
+ * The decoding happens in place.
|
|
|
8fa62f |
+ */
|
|
|
8fa62f |
+static char *local_decode_name(char *buf)
|
|
|
8fa62f |
+{
|
|
|
8fa62f |
+ char *rp = buf;
|
|
|
8fa62f |
+ char *wp = buf;
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ do {
|
|
|
8fa62f |
+ if (rp[0] == '\\' && rp[1] == '0' &&
|
|
|
8fa62f |
+ rp[2] == '4' && rp[3] == '0') {
|
|
|
8fa62f |
+ /* \040 is a SPACE. */
|
|
|
8fa62f |
+ *wp++ = ' ';
|
|
|
8fa62f |
+ rp += 3;
|
|
|
8fa62f |
+ } else if (rp[0] == '\\' && rp[1] == '0' &&
|
|
|
8fa62f |
+ rp[2] == '1' && rp[3] == '1') {
|
|
|
8fa62f |
+ /* \011 is a TAB. */
|
|
|
8fa62f |
+ *wp++ = '\t';
|
|
|
8fa62f |
+ rp += 3;
|
|
|
8fa62f |
+ } else if (rp[0] == '\\' && rp[1] == '0' &&
|
|
|
8fa62f |
+ rp[2] == '1' && rp[3] == '2') {
|
|
|
8fa62f |
+ /* \012 is a NEWLINE. */
|
|
|
8fa62f |
+ *wp++ = '\n';
|
|
|
8fa62f |
+ rp += 3;
|
|
|
8fa62f |
+ } else if (rp[0] == '\\' && rp[1] == '\\') {
|
|
|
8fa62f |
+ /*
|
|
|
8fa62f |
+ * We have to escape \\ to be able to represent
|
|
|
8fa62f |
+ * all characters.
|
|
|
8fa62f |
+ */
|
|
|
8fa62f |
+ *wp++ = '\\';
|
|
|
8fa62f |
+ rp += 1;
|
|
|
8fa62f |
+ } else if (rp[0] == '\\' && rp[1] == '1' &&
|
|
|
8fa62f |
+ rp[2] == '3' && rp[3] == '4') {
|
|
|
8fa62f |
+ /* \134 is also \\. */
|
|
|
8fa62f |
+ *wp++ = '\\';
|
|
|
8fa62f |
+ rp += 3;
|
|
|
8fa62f |
+ } else
|
|
|
8fa62f |
+ *wp++ = *rp;
|
|
|
8fa62f |
+ } while (*rp++ != '\0');
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ return buf;
|
|
|
8fa62f |
+}
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+/* From glibc getmntent_r() */
|
|
|
8fa62f |
+static struct mntent *
|
|
|
8fa62f |
+local_getmntent_r(FILE *tab, struct mntent *mnt, char *buf, int size)
|
|
|
8fa62f |
+{
|
|
|
8fa62f |
+ char *cp, *head;
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ do {
|
|
|
8fa62f |
+ char *end_ptr;
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ if (fgets(buf, size, tab) == NULL)
|
|
|
8fa62f |
+ return 0;
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ end_ptr = strchr(buf, '\n');
|
|
|
8fa62f |
+ if (end_ptr != NULL) {
|
|
|
8fa62f |
+ while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
|
|
|
8fa62f |
+ end_ptr--;
|
|
|
8fa62f |
+ *end_ptr = '\0';
|
|
|
8fa62f |
+ } else {
|
|
|
8fa62f |
+ /* Whole line was not read. Do it now but forget it. */
|
|
|
8fa62f |
+ char tmp[1024];
|
|
|
8fa62f |
+ while (fgets(tmp, sizeof tmp, tab) != NULL)
|
|
|
8fa62f |
+ if (strchr(tmp, '\n') != NULL)
|
|
|
8fa62f |
+ break;
|
|
|
8fa62f |
+ }
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ head = buf + strspn(buf, " \t");
|
|
|
8fa62f |
+ /* skip empty lines and comment lines */
|
|
|
8fa62f |
+ } while (head[0] == '\0' || head[0] == '#');
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ cp = strsep(&head, " \t");
|
|
|
8fa62f |
+ mnt->mnt_fsname = cp != NULL ? local_decode_name(cp) : (char *) "";
|
|
|
8fa62f |
+ if (head)
|
|
|
8fa62f |
+ head += strspn(head, " \t");
|
|
|
8fa62f |
+ cp = strsep(&head, " \t");
|
|
|
8fa62f |
+ mnt->mnt_dir = cp != NULL ? local_decode_name (cp) : (char *) "";
|
|
|
8fa62f |
+ if (head)
|
|
|
8fa62f |
+ head += strspn(head, " \t");
|
|
|
8fa62f |
+ cp = strsep(&head, " \t");
|
|
|
8fa62f |
+ mnt->mnt_type = cp != NULL ? local_decode_name (cp) : (char *) "";
|
|
|
8fa62f |
+ if (head)
|
|
|
8fa62f |
+ head += strspn (head, " \t");
|
|
|
8fa62f |
+ cp = strsep (&head, " \t");
|
|
|
8fa62f |
+ mnt->mnt_opts = cp != NULL ? local_decode_name (cp) : (char *) "";
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ /* autofs doesn't need freq or passno */
|
|
|
8fa62f |
+
|
|
|
8fa62f |
+ return mnt;
|
|
|
8fa62f |
+}
|
|
|
8fa62f |
+
|
|
|
8fa62f |
/*
|
|
|
8fa62f |
* Get list of mounts under path in longest->shortest order
|
|
|
8fa62f |
*/
|