summaryrefslogtreecommitdiffstats
path: root/systemd/nfs-server-generator.c
diff options
context:
space:
mode:
Diffstat (limited to 'systemd/nfs-server-generator.c')
-rw-r--r--systemd/nfs-server-generator.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/systemd/nfs-server-generator.c b/systemd/nfs-server-generator.c
index cc99969..4aa6509 100644
--- a/systemd/nfs-server-generator.c
+++ b/systemd/nfs-server-generator.c
@@ -84,6 +84,28 @@ static void systemd_escape(FILE *f, char *path)
}
}
+static int has_noauto_flag(char *path)
+{
+ FILE *fstab;
+ struct mntent *mnt;
+
+ fstab = setmntent("/etc/fstab", "r");
+ if (!fstab)
+ return 0;
+
+ while ((mnt = getmntent(fstab)) != NULL) {
+ int l = strlen(mnt->mnt_dir);
+ if (strncmp(mnt->mnt_dir, path, l) != 0)
+ continue;
+ if (path[l] && path[l] != '/')
+ continue;
+ if (hasmntopt(mnt, "noauto"))
+ break;
+ }
+ fclose(fstab);
+ return mnt != NULL;
+}
+
int main(int argc, char *argv[])
{
char *path;
@@ -124,6 +146,10 @@ int main(int argc, char *argv[])
for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
if (!is_unique(&list, exp->m_export.e_path))
continue;
+ if (exp->m_export.e_mountpoint)
+ continue;
+ if (has_noauto_flag(exp->m_export.e_path))
+ continue;
if (strchr(exp->m_export.e_path, ' '))
fprintf(f, "RequiresMountsFor=\"%s\"\n",
exp->m_export.e_path);