On Thu, Mar 17, 2011 at 4:43 AM, Lennart Poettering
<lenn...@poettering.net> wrote:
> Anywaym uf you rework this patch to check for the usrquota/grpquota
> options I'd merge it promptly (or you can even merge it yourself, if
> Tollef grants you git access by then ;-)). Even better would be if you
> add a WANTS dep too, so that we can remove the service from being pulled
> in by default sysinit.target.

Like attached patch?
From: Andrey Borzenkov <arvidj...@gmail.com>
Subject: [PATCH] mount: pull in quota services from local mountpoints with usr/grpquota options

---
 Makefile.am                 |    4 ----
 src/mount.c                 |   19 +++++++++++++++++--
 src/special.h               |    1 +
 units/quotacheck.service.in |    3 ---
 units/quotaon.service       |    3 ---
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8d23430..69759fe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1332,10 +1332,6 @@ install-data-hook:
 		$(LN_S) $(systemunitdir)/getty@.service getty@tty4.service && \
 		$(LN_S) $(systemunitdir)/getty@.service getty@tty5.service && \
 		$(LN_S) $(systemunitdir)/getty@.service getty@tty6.service )
-	( cd $(DESTDIR)$(pkgsysconfdir)/system/local-fs.target.wants && \
-		rm -f quotaon.service quotacheck.service && \
-		$(LN_S) $(systemunitdir)/quotacheck.service quotacheck.service && \
-		$(LN_S) $(systemunitdir)/quotaon.service quotaon.service )
 	( cd $(DESTDIR)$(pkgsysconfdir)/system/multi-user.target.wants && \
 		rm -f remote-fs.target && \
 		$(LN_S) $(systemunitdir)/remote-fs.target remote-fs.target )
diff --git a/src/mount.c b/src/mount.c
index 39525b6..9f4c72b 100644
--- a/src/mount.c
+++ b/src/mount.c
@@ -413,9 +413,24 @@ static int mount_add_default_dependencies(Mount *m) {
 
         if (m->meta.manager->running_as == MANAGER_SYSTEM &&
             !path_equal(m->where, "/")) {
+                MountParameters *p;
 
-                if ((r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0)
-                        return r;
+                if (m->from_fragment)
+                        p = &m->parameters_fragment;
+                else if (m->from_etc_fstab)
+                        p = &m->parameters_etc_fstab;
+                else
+                        p = NULL;
+
+                if (!p ||
+                    (!mount_test_option(p->options, "_netdev") &&
+                    !(p->fstype && fstype_is_network(p->fstype)) &&
+                    (mount_test_option(p->options, "usrquota") || mount_test_option(p->options, "grpquota"))))
+                        if ((r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0 ||
+                            (r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, SPECIAL_QUOTAON_SERVICE, NULL, true)) < 0 ||
+                            (r = unit_add_dependency_by_name(UNIT(m), UNIT_WANTS, SPECIAL_QUOTACHECK_SERVICE, NULL, true)) < 0 ||
+                            (r = unit_add_dependency_by_name(UNIT(m), UNIT_BEFORE, SPECIAL_QUOTAON_SERVICE, NULL, true)) < 0)
+                                return r;
 
                 if ((r = unit_add_two_dependencies_by_name(UNIT(m), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true)) < 0)
                         return r;
diff --git a/src/special.h b/src/special.h
index 2f2d9e7..b60e1e7 100644
--- a/src/special.h
+++ b/src/special.h
@@ -54,6 +54,7 @@
 #define SPECIAL_SYSINIT_TARGET "sysinit.target"
 #define SPECIAL_FSCK_SERVICE "fsck@.service"
 #define SPECIAL_QUOTACHECK_SERVICE "quotacheck.service"
+#define SPECIAL_QUOTAON_SERVICE "quotaon.service"
 #define SPECIAL_RESCUE_TARGET "rescue.target"
 #define SPECIAL_EXIT_TARGET "exit.target"
 #define SPECIAL_EMERGENCY_TARGET "emergency.target"
diff --git a/units/quotacheck.service.in b/units/quotacheck.service.in
index d46a335..ed1ddc5 100644
--- a/units/quotacheck.service.in
+++ b/units/quotacheck.service.in
@@ -18,6 +18,3 @@ RemainAfterExit=yes
 ExecStart=@rootlibexecdir@/systemd-quotacheck
 StandardOutput=syslog
 TimeoutSec=0
-
-[Install]
-WantedBy=local-fs.target
diff --git a/units/quotaon.service b/units/quotaon.service
index ddb5128..2c7b36b 100644
--- a/units/quotaon.service
+++ b/units/quotaon.service
@@ -17,6 +17,3 @@ Type=oneshot
 RemainAfterExit=yes
 ExecStart=/sbin/quotaon -aug
 StandardOutput=syslog
-
-[Install]
-WantedBy=local-fs.target
-- 
tg: (a49408e..) u/local-fs-quota (depends on: origin/master)
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to