Re: [systemd-devel] Patches to use -.mount without /etc/fstab

2013-10-01 Thread Lennart Poettering
On Tue, 01.10.13 16:09, Karel Zak (k...@redhat.com) wrote:

> > Why does it even print that warning? It's annoying and I don't see its
> > purpose. Unless you run fsck with the -A option, it doesn't even need
> > the fstab file.
> 
>  OK, fixed (will be in util-linux v2.24-rc2).

Thanks a lot for this fix! With the new GPT auto-discovery stuff the
abiity to boot without /etc/fstab is actually really useful, since we
really don't need it anymore then.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Patches to use -.mount without /etc/fstab

2013-10-01 Thread Thomas Bächler
Am 24.09.2013 21:53, schrieb Kelly Anderson:
> If I'm not mistaken, the intent way back in the early stages of systemd was 
> to 
> eliminate /etc/fstab and use .mount files exclusively.  Since it was never 
> fully implemented I took the prerogative to make it work on my systems.
> I've been using the setup for quite some time and it works without problem.

As Lennart said, it doesn't seem to be a goal. However, you can make a
system work without just fine without fstab (I run such a system).

> 1. if /etc/fstab is missing, systemd must remount / based on the options
> in /etc/systemd/system/-.mount.

Why does / need to be remounted? Simply mount / with the correct options
from initrd.

If you don't need initrd, a simple oneshot service with
 ExecStart=mount -o remount,rw /
should suffice, or, as Lennart said, a reload of the -.mount unit.

> 2.  If /etc/fstab is missing, systemd must create a valid fstab (in this case 
> /run/fstab) so that fsck runs properly.

fsck prints a warning if fstab is missing. It's annoying, so I created
an empty /etc/fstab on my system.




signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Patches to use -.mount without /etc/fstab

2013-10-01 Thread Karel Zak
On Tue, Oct 01, 2013 at 03:40:00PM +0200, Thomas Bächler wrote:
> Am 01.10.2013 15:26, schrieb Karel Zak:
> >>> 2.  If /etc/fstab is missing, systemd must create a valid fstab (in this 
> >>> case 
> >>> /run/fstab) so that fsck runs properly.
> >>
> >> Not following on this one really... If fsck fails if it doesn't find any
> >> fstab, then this is really something to fix in util-linux I am sure. It
> > 
> >  I didn't tests it, but according to code fsck prints warning only and
> >  continue as usually.
> 
> Why does it even print that warning? It's annoying and I don't see its
> purpose. Unless you run fsck with the -A option, it doesn't even need
> the fstab file.

 OK, fixed (will be in util-linux v2.24-rc2).

Karel


-- 
 Karel Zak  
 http://karelzak.blogspot.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Patches to use -.mount without /etc/fstab

2013-10-01 Thread Thomas Bächler
Am 01.10.2013 15:26, schrieb Karel Zak:
>>> 2.  If /etc/fstab is missing, systemd must create a valid fstab (in this 
>>> case 
>>> /run/fstab) so that fsck runs properly.
>>
>> Not following on this one really... If fsck fails if it doesn't find any
>> fstab, then this is really something to fix in util-linux I am sure. It
> 
>  I didn't tests it, but according to code fsck prints warning only and
>  continue as usually.

Why does it even print that warning? It's annoying and I don't see its
purpose. Unless you run fsck with the -A option, it doesn't even need
the fstab file.

I actually got rid of /etc/fstab (for fun) and only recreated an empty
one to get rid of the warning.




signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Patches to use -.mount without /etc/fstab

2013-10-01 Thread Karel Zak
On Tue, Oct 01, 2013 at 04:15:16AM +0200, Lennart Poettering wrote:
> On Tue, 24.09.13 13:53, Kelly Anderson (ke...@xilka.com) wrote:
> 
> > Hello,
> > 
> > If I'm not mistaken, the intent way back in the early stages of systemd was 
> > to 
> > eliminate /etc/fstab and use .mount files exclusively.  Since it was never 
> > fully implemented I took the prerogative to make it work on my systems.
> > I've been using the setup for quite some time and it works without
> > problem.
> 
> So, I am not really convinced that we really want to get rid of /etc/fstab...

 +1 ;-)

> > 2.  If /etc/fstab is missing, systemd must create a valid fstab (in this 
> > case 
> > /run/fstab) so that fsck runs properly.
> 
> Not following on this one really... If fsck fails if it doesn't find any
> fstab, then this is really something to fix in util-linux I am sure. It

 I didn't tests it, but according to code fsck prints warning only and
 continue as usually.

Karel

-- 
 Karel Zak  
 http://karelzak.blogspot.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Patches to use -.mount without /etc/fstab

2013-09-30 Thread Lennart Poettering
On Tue, 24.09.13 13:53, Kelly Anderson (ke...@xilka.com) wrote:

> Hello,
> 
> If I'm not mistaken, the intent way back in the early stages of systemd was 
> to 
> eliminate /etc/fstab and use .mount files exclusively.  Since it was never 
> fully implemented I took the prerogative to make it work on my systems.
> I've been using the setup for quite some time and it works without
> problem.

So, I am not really convinced that we really want to get rid of /etc/fstab...

> 1. if /etc/fstab is missing, systemd must remount / based on the options
> in /etc/systemd/system/-.mount.

This could be done by scheduling a reload job for -.mount. "systemctl
reload -- -.mount" should have the desired effect.

> 2.  If /etc/fstab is missing, systemd must create a valid fstab (in this case 
> /run/fstab) so that fsck runs properly.

Not following on this one really... If fsck fails if it doesn't find any
fstab, then this is really something to fix in util-linux I am sure. It
should treat a non-existant fstab the same way as an empty one.
 
> The attached patches address those issues.
> 

> +if ( ! f ) {
> +f = fopen("/etc/systemd/system/-.mount", "r");

This doesn't really work, as the unit file might at many other
places. Also, we really shouldn't process unit files anywhere except PID
1, and definitely not duplicate the code for it...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Patches to use -.mount without /etc/fstab

2013-09-24 Thread Kelly Anderson
Hello,

If I'm not mistaken, the intent way back in the early stages of systemd was to 
eliminate /etc/fstab and use .mount files exclusively.  Since it was never 
fully implemented I took the prerogative to make it work on my systems.
I've been using the setup for quite some time and it works without problem.

1. if /etc/fstab is missing, systemd must remount / based on the options
in /etc/systemd/system/-.mount.

2.  If /etc/fstab is missing, systemd must create a valid fstab (in this case 
/run/fstab) so that fsck runs properly.

The attached patches address those issues.

--- ./units/systemd-remount-fs.service.in.orig	2013-08-13 14:02:52.824756395 -0600
+++ ./units/systemd-remount-fs.service.in	2013-09-24 13:34:56.514061876 -0600
@@ -14,7 +14,6 @@ Conflicts=shutdown.target
 After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-fsck-root.service
 Before=local-fs-pre.target local-fs.target shutdown.target
 Wants=local-fs-pre.target
-ConditionPathExists=/etc/fstab
 
 [Service]
 Type=oneshot
--- ./src/remount-fs/remount-fs.c.orig	2013-09-24 13:34:56.485062277 -0600
+++ ./src/remount-fs/remount-fs.c	2013-09-24 13:34:56.530061656 -0600
@@ -38,6 +38,61 @@
  * options that are in /etc/fstab that systemd might not have
  * respected */
 
+static void remount(Hashmap *pids, int *pret, const char *mnt_dir, const char *mnt_options)
+{
+pid_t pid;
+int k;
+char *s;
+
+/* Remount the root fs, /usr and all API VFS */
+if (!mount_point_is_api(mnt_dir) &&
+!path_equal(mnt_dir, "/") &&
+!path_equal(mnt_dir, "/usr"))
+return;
+
+log_debug("Remounting %s", mnt_dir);
+
+pid = fork();
+if (pid < 0) {
+log_error("Failed to fork: %m");
+*pret = EXIT_FAILURE;
+return;
+}
+
+if (pid == 0) {
+const char *arguments[5];
+/* Child */
+
+arguments[0] = "/usr/bin/mount";
+arguments[1] = mnt_dir;
+arguments[2] = "-o";
+arguments[3] = mnt_options;
+arguments[4] = NULL;
+
+execv("/usr/bin/mount", (char **) arguments);
+
+log_error("Failed to execute /usr/bin/mount: %m");
+_exit(EXIT_FAILURE);
+}
+
+/* Parent */
+
+s = strdup(mnt_dir);
+if (!s) {
+log_oom();
+*pret = EXIT_FAILURE;
+return;
+}
+
+
+k = hashmap_put(pids, UINT_TO_PTR(pid), s);
+if (k < 0) {
+log_error("Failed to add PID to set: %s", strerror(-k));
+*pret = EXIT_FAILURE;
+return;
+}
+}
+
 int main(int argc, char *argv[]) {
 int ret = EXIT_FAILURE;
 FILE *f = NULL;
@@ -56,12 +111,7 @@ int main(int argc, char *argv[]) {
 umask(0022);
 
 f = setmntent("/etc/fstab", "r");
-if (!f) {
-if (errno == ENOENT) {
-ret = EXIT_SUCCESS;
-goto finish;
-}
-
+if (!f && (errno != ENOENT)) {
 log_error("Failed to open /etc/fstab: %m");
 goto finish;
 }
@@ -74,57 +124,38 @@ int main(int argc, char *argv[]) {
 
 ret = EXIT_SUCCESS;
 
-while ((me = getmntent(f))) {
-pid_t pid;
-int k;
-char *s;
-
-/* Remount the root fs, /usr and all API VFS */
-if (!mount_point_is_api(me->mnt_dir) &&
-!path_equal(me->mnt_dir, "/") &&
-!path_equal(me->mnt_dir, "/usr"))
-continue;
-
-log_debug("Remounting %s", me->mnt_dir);
-
-pid = fork();
-if (pid < 0) {
-log_error("Failed to fork: %m");
-ret = EXIT_FAILURE;
-continue;
-}
-
-if (pid == 0) {
-const char *arguments[5];
-/* Child */
-
-arguments[0] = "/usr/bin/mount";
-arguments[1] = me->mnt_dir;
-arguments[2] = "-o";
-arguments[3] = "remount";
-arguments[4] = NULL;
-
-execv("/usr/bin/mount", (char **) arguments);
+if ( ! f ) {
+f = fopen("/etc/systemd/system/-.mount", "r");
 
-log_error("Failed to execute /usr/bin/mount: %m");
-_exit(EXIT_FAILURE);
+if ( f ) {
+char *line = NULL;
+size_t len = 0;
+ssize_t read;
+
+while ((read = getline(&line, &len, f)) != -1) {
+if ( ! strncmp("Options="