diff options
author | Scott Mayhew <smayhew@redhat.com> | 2017-04-10 07:10:45 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2017-04-10 07:10:45 -0400 |
commit | 3892174834ea1a4729348f0ecd3078cc1d5458e4 (patch) | |
tree | e531d9259d7b9af6535182fea7e4c7726e650a6c /systemd/nfs-server-generator.c | |
parent | da866d7f6a787045e2c9f4a700e23b58ec71400a (diff) | |
download | nfs-utils-3892174834ea1a4729348f0ecd3078cc1d5458e4.tar.gz nfs-utils-3892174834ea1a4729348f0ecd3078cc1d5458e4.tar.xz nfs-utils-3892174834ea1a4729348f0ecd3078cc1d5458e4.zip |
systemd: add a generator for the rpc_pipefs mountpoint
The nfs.conf has config options for the rpc_pipefs mountpoint.
Currently, changing these from the default also requires manually
overriding the systemd unit files that are hard-coded to mount the
filesystem on /var/lib/nfs/rpc_pipefs.
This patch adds a generator that creates a mount unit file for the
rpc_pipefs when a non-default value is specified in /etc/nfs.conf, as
well as a target unit file to override the dependencies for the systemd
units using the rpc_pipefs. The blkmapd, idmapd, and gssd service unit
files have been modified to define their dependencies on the rpc_pipefs
mountpoint indirectly via the rpc_pipefs target unit file. Since both
rpc-pipefs-generator.c and nfs-server-generator.c need to convert path
names to unit file names, that functionality has been moved to
systemd.c.
This patch also removes the dependency on the rpc_pipefs from the
rpc-svcgssd.service unit file. rpc.svcgssd uses the sunrpc cache
mechanism to exchange data with the kernel, not the rpc_pipefs.
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'systemd/nfs-server-generator.c')
-rw-r--r-- | systemd/nfs-server-generator.c | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c index 4aa6509..737f109 100644 --- a/systemd/nfs-server-generator.c +++ b/systemd/nfs-server-generator.c @@ -29,6 +29,7 @@ #include "misc.h" #include "nfslib.h" #include "exportfs.h" +#include "systemd.h" /* A simple "set of strings" to remove duplicates * found in /etc/exports @@ -55,35 +56,6 @@ static int is_unique(struct list **lp, char *path) return 1; } -/* We need to convert a path name to a systemd unit - * name. This requires some translation ('/' -> '-') - * and some escaping. - */ -static void systemd_escape(FILE *f, char *path) -{ - while (*path == '/') - path++; - if (!*path) { - /* "/" becomes "-", otherwise leading "/" is ignored */ - fputs("-", f); - return; - } - while (*path) { - char c = *path++; - - if (c == '/') { - /* multiple non-trailing slashes become '-' */ - while (*path == '/') - path++; - if (*path) - fputs("-", f); - } else if (isalnum(c) || c == ':' || c == '.') - fputc(c, f); - else - fprintf(f, "\\x%02x", c & 0xff); - } -} - static int has_noauto_flag(char *path) { FILE *fstab; @@ -108,7 +80,7 @@ static int has_noauto_flag(char *path) int main(int argc, char *argv[]) { - char *path; + char *path, *spath; char dirbase[] = "/nfs-server.service.d"; char filebase[] = "/order-with-mounts.conf"; nfs_export *exp; @@ -167,9 +139,15 @@ int main(int argc, char *argv[]) if (strcmp(mnt->mnt_type, "nfs") != 0 && strcmp(mnt->mnt_type, "nfs4") != 0) continue; - fprintf(f, "Before= "); - systemd_escape(f, mnt->mnt_dir); - fprintf(f, ".mount\n"); + + spath = systemd_escape(mnt->mnt_dir, ".mount"); + if (!spath) { + fprintf(stderr, + "nfs-server-generator: convert path failed: %s\n", + mnt->mnt_dir); + continue; + } + fprintf(f, "Before=%s\n", spath); } fclose(fstab); |