On Wed, 04.05.11 11:01, Michael Olbrich ([email protected]) wrote:

> on a read-only file-system 'unlink' returns EROFS (Read-only file
> system) even if the file does not exists. To avoid false errors,
> check if the file exists first.

I now commited a different fix for this. Please test!

> -                if (unlink("/run/nologin") < 0 && errno != ENOENT) {
> +                if (stat("/run/nologin", &buffer) == 0 && 
> unlink("/run/nologin") < 0 && errno != ENOENT) {
>                          log_error("Failed to remove /run/nologin file: %m");
>                          r = -errno;
>                  }

/run/nologin *must* be writable, hence this check is not really applicable.

> -                if (unlink("/etc/nologin") < 0 && errno != ENOENT) {
> +                if (stat("/etc/nologin", &buffer) == 0 && 
> unlink("/etc/nologin") < 0 && errno != ENOENT) {
>                          log_error("Failed to remove /etc/nologin file: %m");
>                          q = -errno;
>                  }

access(F_OK) is usually nicer than stat() for this purpose. Also, I
think we should do unlink() first, and suppress the error message for
EROFS only if the file really doesn't exist. The patch I commited now
does that.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to