Re: [systemd-devel] [PATCH 1/9] fsckd daemon for inter-fsckd communication

2015-02-18 Thread Martin Pitt
Ça va Didier,

these now apply/build/check fine against master, I tested the binaries
on my laptop and in a VM, all review comments were addressed. As
discussed with Zbigniew on IRC I landed them now.

A big omission is of course the lack of German translations! :-)
(I'll commit them now)

Merci,

Martin
-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)


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


Re: [systemd-devel] [PATCH 1/9] fsckd daemon for inter-fsckd communication

2015-02-18 Thread Didier Roche

Le 18/02/2015 17:00, Martin Pitt a écrit :

Ça va Didier,

these now apply/build/check fine against master, I tested the binaries
on my laptop and in a VM, all review comments were addressed. As
discussed with Zbigniew on IRC I landed them now.


Thanks a lot Martin for doing this further testing and reviews!


A big omission is of course the lack of German translations! :-)
(I'll commit them now)

You didn't want me to try to add those translations, believe me ;)

Danke schön.
Didier
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/9] fsckd daemon for inter-fsckd communication

2015-02-17 Thread Didier Roche

Le 14/02/2015 17:21, Zbigniew Jędrzejewski-Szmek a écrit :

Thanks for the review, reattached the patch with those fixes.


On Thu, Feb 05, 2015 at 06:06:50PM +0100, Didier Roche wrote:
+if (fsckd_fd  0) {
+log_warning_errno(errno, Cannot open fsckd socket, we won't report 
fsck progress: %m);
+return -errno;
+}
+if (connect(fsckd_fd, sa.sa, offsetof(struct sockaddr_un, sun_path) + 
strlen(sa.un.sun_path))  0) {
+log_warning_errno(errno, Cannot connect to fsckd socket, we won't 
report fsck progress: %m);
+return -errno;
Use 'return log_warning_errno(...)'.


+}
  
  f = fdopen(fd, r);

  if (!f) {
-safe_close(fd);
+log_warning_errno(errno, Cannot connect to fsck, we won't report 
fsck progress: %m);
  return -errno;
  }

Also changed it on this last one below, thanks!


  


+
+/* ensure we have enough data to read */
+r = ioctl(fd, FIONREAD, buflen);
+if (r == 0  buflen != 0  (size_t) buflen  sizeof(FsckProgress)) {
+if (client-buflen != buflen)
+client-buflen = buflen;
+/* we got twice the same size from a bad behaving client, kick 
it off the list */
+else {

Shouldn't this be logged? Seems like this should be detected and fixed
if it happens.


Good suggestion. We don't have that much information on the client than 
the fd at this stage (if we never got progress, we don't know device 
major and minor numbers), but at least, we'll know that there are bad 
behaving client. Added.



Didier
From fb6d1cc4df6a27684720ccfacdeca3cddadc44ca Mon Sep 17 00:00:00 2001
From: Didier Roche didro...@ubuntu.com
Date: Wed, 4 Feb 2015 16:42:47 +0100
Subject: [PATCH 1/9] fsckd daemon for inter-fsckd communication

Add systemd-fsckd multiplexer which accepts multiple systemd-fsck
instances to connect to it and sends progress report. systemd-fsckd then
computes and writes to /dev/console the number of devices currently being
checked and the minimum fsck progress. This will be used for interactive
progress report and cancelling in plymouth.

systemd-fsckd stops on idle when no systemd-fsck is connected.

Make the necessary changes to systemd-fsck to connect to the systemd-fsckd
socket.
---
 .gitignore |   1 +
 Makefile.am|  13 ++
 src/fsck/fsck.c|  88 
 src/fsckd/Makefile |   1 +
 src/fsckd/fsckd.c  | 404 +
 src/fsckd/fsckd.h  |  34 +
 6 files changed, 484 insertions(+), 57 deletions(-)
 create mode 12 src/fsckd/Makefile
 create mode 100644 src/fsckd/fsckd.c
 create mode 100644 src/fsckd/fsckd.h

diff --git a/.gitignore b/.gitignore
index ab6d9d1..9400e75 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@
 /systemd-evcat
 /systemd-firstboot
 /systemd-fsck
+/systemd-fsckd
 /systemd-fstab-generator
 /systemd-getty-generator
 /systemd-gnome-ask-password-agent
diff --git a/Makefile.am b/Makefile.am
index c463f23..e0e8bc6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -389,6 +389,7 @@ rootlibexec_PROGRAMS = \
 	systemd-remount-fs \
 	systemd-reply-password \
 	systemd-fsck \
+	systemd-fsckd \
 	systemd-machine-id-commit \
 	systemd-ac-power \
 	systemd-sysctl \
@@ -2355,6 +2356,18 @@ systemd_fsck_LDADD = \
 	libsystemd-shared.la
 
 # --
+systemd_fsckd_SOURCES = \
+	src/fsckd/fsckd.c \
+	$(NULL)
+
+systemd_fsckd_LDADD = \
+	libsystemd-internal.la \
+	libsystemd-label.la \
+	libsystemd-shared.la \
+	libudev-internal.la \
+	$(NULL)
+
+# --
 systemd_machine_id_commit_SOURCES = \
 	src/machine-id-commit/machine-id-commit.c \
 	src/core/machine-id-setup.c \
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 20b7940..f6ed1d1 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -27,6 +27,7 @@
 #include unistd.h
 #include fcntl.h
 #include sys/file.h
+#include sys/stat.h
 
 #include sd-bus.h
 #include libudev.h
@@ -39,6 +40,8 @@
 #include fileio.h
 #include udev-util.h
 #include path-util.h
+#include socket-util.h
+#include fsckd/fsckd.h
 
 static bool arg_skip = false;
 static bool arg_force = false;
@@ -132,58 +135,36 @@ static void test_files(void) {
 arg_show_progress = true;
 }
 
-static double percent(int pass, unsigned long cur, unsigned long max) {
-/* Values stolen from e2fsck */
-
-static const int pass_table[] = {
-0, 70, 90, 92, 95, 100
+static int process_progress(int fd, dev_t device_num) {
+_cleanup_fclose_ FILE *f = NULL;
+usec_t last = 0;
+_cleanup_close_ int fsckd_fd = -1;
+static const union sockaddr_union sa = {
+.un.sun_family = AF_UNIX,
+.un.sun_path = FSCKD_SOCKET_PATH,
 };
 
-

Re: [systemd-devel] [PATCH 1/9] fsckd daemon for inter-fsckd communication

2015-02-14 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Feb 05, 2015 at 06:06:50PM +0100, Didier Roche wrote:
 Hey,
 
 Posting the new set of patches for the fsck/plymouth integration,
 rebased from all the comments and the systemd event loop system.
 
 This version talks the raw plymouth protocol directly, supporting
 only what is needed (sending updates, messages, requesting key
 listening, get key events). It's using Control+C as the cancellation
 key. If plymouth disconnects and then later respawn, the connection
 will be taken back. Same for any new fsck connection incoming after
 a cancellation (they will get cancelled right away). The update
 progress message is always reflecting the current connection state
 (they will only disappear once they are actually cleaned).
 
 As always, I'm opened to any comments.
 Cheers,
 Didier

 From ac8d6f10768a5bcba0b7932547419637983637b2 Mon Sep 17 00:00:00 2001
 From: Didier Roche didro...@ubuntu.com
 Date: Wed, 4 Feb 2015 16:42:47 +0100
 Subject: [PATCH 1/9] fsckd daemon for inter-fsckd communication
 
 Add systemd-fsckd multiplexer which accepts multiple systemd-fsck
 instances to connect to it and sends progress report. systemd-fsckd then
 computes and writes to /dev/console the number of devices currently being
 checked and the minimum fsck progress. This will be used for interactive
 progress report and cancelling in plymouth.
 
 systemd-fsckd stops on idle when no systemd-fsck is connected.
 
 Make the necessary changes to systemd-fsck to connect to the systemd-fsckd
 socket.
 ---
  .gitignore |   1 +
  Makefile.am|  13 ++
  src/fsck/fsck.c|  88 +---
  src/fsckd/Makefile |   1 +
  src/fsckd/fsckd.c  | 403 
 +
  src/fsckd/fsckd.h  |  34 +
  6 files changed, 486 insertions(+), 54 deletions(-)
  create mode 12 src/fsckd/Makefile
  create mode 100644 src/fsckd/fsckd.c
  create mode 100644 src/fsckd/fsckd.h
 
 diff --git a/.gitignore b/.gitignore
 index ab6d9d1..9400e75 100644
 --- a/.gitignore
 +++ b/.gitignore
 @@ -74,6 +74,7 @@
  /systemd-evcat
  /systemd-firstboot
  /systemd-fsck
 +/systemd-fsckd
  /systemd-fstab-generator
  /systemd-getty-generator
  /systemd-gnome-ask-password-agent
 diff --git a/Makefile.am b/Makefile.am
 index c463f23..e0e8bc6 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -389,6 +389,7 @@ rootlibexec_PROGRAMS = \
   systemd-remount-fs \
   systemd-reply-password \
   systemd-fsck \
 + systemd-fsckd \
   systemd-machine-id-commit \
   systemd-ac-power \
   systemd-sysctl \
 @@ -2355,6 +2356,18 @@ systemd_fsck_LDADD = \
   libsystemd-shared.la
  
  # 
 --
 +systemd_fsckd_SOURCES = \
 + src/fsckd/fsckd.c \
 + $(NULL)
 +
 +systemd_fsckd_LDADD = \
 + libsystemd-internal.la \
 + libsystemd-label.la \
 + libsystemd-shared.la \
 + libudev-internal.la \
 + $(NULL)
 +
 +# 
 --
  systemd_machine_id_commit_SOURCES = \
   src/machine-id-commit/machine-id-commit.c \
   src/core/machine-id-setup.c \
 diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
 index 20b7940..9d9739b 100644
 --- a/src/fsck/fsck.c
 +++ b/src/fsck/fsck.c
 @@ -27,6 +27,7 @@
  #include unistd.h
  #include fcntl.h
  #include sys/file.h
 +#include sys/stat.h
  
  #include sd-bus.h
  #include libudev.h
 @@ -39,6 +40,8 @@
  #include fileio.h
  #include udev-util.h
  #include path-util.h
 +#include socket-util.h
 +#include fsckd/fsckd.h
  
  static bool arg_skip = false;
  static bool arg_force = false;
 @@ -132,58 +135,42 @@ static void test_files(void) {
  arg_show_progress = true;
  }
  
 -static double percent(int pass, unsigned long cur, unsigned long max) {
 -/* Values stolen from e2fsck */
 -
 -static const int pass_table[] = {
 -0, 70, 90, 92, 95, 100
 +static int process_progress(int fd, dev_t device_num) {
 +_cleanup_fclose_ FILE *f = NULL;
 +usec_t last = 0;
 +_cleanup_close_ int fsckd_fd = -1;
 +static const union sockaddr_union sa = {
 +.un.sun_family = AF_UNIX,
 +.un.sun_path = FSCKD_SOCKET_PATH,
  };
  
 -if (pass = 0)
 -return 0.0;
 -
 -if ((unsigned) pass = ELEMENTSOF(pass_table) || max == 0)
 -return 100.0;
 -
 -return (double) pass_table[pass-1] +
 -((double) pass_table[pass] - (double) pass_table[pass-1]) *
 -(double) cur / (double) max;
 -}
 -
 -static int process_progress(int fd) {
 -_cleanup_fclose_ FILE *console = NULL, *f = NULL;
 -usec_t last = 0;
 -bool locked = false;
 -int clear = 0;
 +fsckd_fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
 +if (fsckd_fd  0) {
 +log_warning_errno(errno, Cannot open fsckd socket, we won't 
 report fsck 

[systemd-devel] [PATCH 1/9] fsckd daemon for inter-fsckd communication

2015-02-05 Thread Didier Roche

Hey,

Posting the new set of patches for the fsck/plymouth integration, 
rebased from all the comments and the systemd event loop system.


This version talks the raw plymouth protocol directly, supporting only 
what is needed (sending updates, messages, requesting key listening, get 
key events). It's using Control+C as the cancellation key. If plymouth 
disconnects and then later respawn, the connection will be taken back. 
Same for any new fsck connection incoming after a cancellation (they 
will get cancelled right away). The update progress message is always 
reflecting the current connection state (they will only disappear once 
they are actually cleaned).


As always, I'm opened to any comments.
Cheers,
Didier
From ac8d6f10768a5bcba0b7932547419637983637b2 Mon Sep 17 00:00:00 2001
From: Didier Roche didro...@ubuntu.com
Date: Wed, 4 Feb 2015 16:42:47 +0100
Subject: [PATCH 1/9] fsckd daemon for inter-fsckd communication

Add systemd-fsckd multiplexer which accepts multiple systemd-fsck
instances to connect to it and sends progress report. systemd-fsckd then
computes and writes to /dev/console the number of devices currently being
checked and the minimum fsck progress. This will be used for interactive
progress report and cancelling in plymouth.

systemd-fsckd stops on idle when no systemd-fsck is connected.

Make the necessary changes to systemd-fsck to connect to the systemd-fsckd
socket.
---
 .gitignore |   1 +
 Makefile.am|  13 ++
 src/fsck/fsck.c|  88 +---
 src/fsckd/Makefile |   1 +
 src/fsckd/fsckd.c  | 403 +
 src/fsckd/fsckd.h  |  34 +
 6 files changed, 486 insertions(+), 54 deletions(-)
 create mode 12 src/fsckd/Makefile
 create mode 100644 src/fsckd/fsckd.c
 create mode 100644 src/fsckd/fsckd.h

diff --git a/.gitignore b/.gitignore
index ab6d9d1..9400e75 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@
 /systemd-evcat
 /systemd-firstboot
 /systemd-fsck
+/systemd-fsckd
 /systemd-fstab-generator
 /systemd-getty-generator
 /systemd-gnome-ask-password-agent
diff --git a/Makefile.am b/Makefile.am
index c463f23..e0e8bc6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -389,6 +389,7 @@ rootlibexec_PROGRAMS = \
 	systemd-remount-fs \
 	systemd-reply-password \
 	systemd-fsck \
+	systemd-fsckd \
 	systemd-machine-id-commit \
 	systemd-ac-power \
 	systemd-sysctl \
@@ -2355,6 +2356,18 @@ systemd_fsck_LDADD = \
 	libsystemd-shared.la
 
 # --
+systemd_fsckd_SOURCES = \
+	src/fsckd/fsckd.c \
+	$(NULL)
+
+systemd_fsckd_LDADD = \
+	libsystemd-internal.la \
+	libsystemd-label.la \
+	libsystemd-shared.la \
+	libudev-internal.la \
+	$(NULL)
+
+# --
 systemd_machine_id_commit_SOURCES = \
 	src/machine-id-commit/machine-id-commit.c \
 	src/core/machine-id-setup.c \
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 20b7940..9d9739b 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -27,6 +27,7 @@
 #include unistd.h
 #include fcntl.h
 #include sys/file.h
+#include sys/stat.h
 
 #include sd-bus.h
 #include libudev.h
@@ -39,6 +40,8 @@
 #include fileio.h
 #include udev-util.h
 #include path-util.h
+#include socket-util.h
+#include fsckd/fsckd.h
 
 static bool arg_skip = false;
 static bool arg_force = false;
@@ -132,58 +135,42 @@ static void test_files(void) {
 arg_show_progress = true;
 }
 
-static double percent(int pass, unsigned long cur, unsigned long max) {
-/* Values stolen from e2fsck */
-
-static const int pass_table[] = {
-0, 70, 90, 92, 95, 100
+static int process_progress(int fd, dev_t device_num) {
+_cleanup_fclose_ FILE *f = NULL;
+usec_t last = 0;
+_cleanup_close_ int fsckd_fd = -1;
+static const union sockaddr_union sa = {
+.un.sun_family = AF_UNIX,
+.un.sun_path = FSCKD_SOCKET_PATH,
 };
 
-if (pass = 0)
-return 0.0;
-
-if ((unsigned) pass = ELEMENTSOF(pass_table) || max == 0)
-return 100.0;
-
-return (double) pass_table[pass-1] +
-((double) pass_table[pass] - (double) pass_table[pass-1]) *
-(double) cur / (double) max;
-}
-
-static int process_progress(int fd) {
-_cleanup_fclose_ FILE *console = NULL, *f = NULL;
-usec_t last = 0;
-bool locked = false;
-int clear = 0;
+fsckd_fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+if (fsckd_fd  0) {
+log_warning_errno(errno, Cannot open fsckd socket, we won't report fsck progress: %m);
+return -errno;
+}
+if (connect(fsckd_fd, sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path))  0) {
+log_warning_errno(errno, Cannot connect to fsckd socket, we won't report fsck progress: