Re: [systemd-devel] Finding a block device quickly with libblkid

2024-03-04 Thread Karel Zak
On Fri, Mar 01, 2024 at 06:30:15PM +, Eric Curtin wrote:
> We are looking into optimizing the boot sequence of a device with many
> partitions.

Nice topic :-)

> On boot in the default systemd implementation, all the block devices
> are queried via libblkid and the various symlinks are set up in
> /dev/disk/* from the results of those queries. The problem is on a
> device with many partitions this can delay the boot by hundreds of
> milliseconds, which is not ideal, especially when in many cases all
> you really care about is mounting the block device that represents the
> rootfs partition.

It's a little bit more complex. It's not just about rootfs. The reason
why udevd scans all the devices is to create a udev database and fill
it with data usable for running the system. For example, when you type
'lsblk --fs', it reads the data from the database (findmnt, mount,
etc.), which is also used by udev rules and for dependency evaluations
in systemd, etc. This is the reason why the system gathers all the
data about a new device when it's detected.

If you want to avoid all of this, you need to customize udev rules
where you can filter out what and how to scan.

> We can sort of guess "/dev/sde38" is the correct
> one, but that's not deterministic.
> 
> So we started digging and came across blkid_find_dev_with_tag and
> blkid_dev_devname, which you can call like this:
> 
> blkid_dev_devname(blkid_find_dev_with_tag(cache, "PARTLABEL", "system_a")))
> 
> blkid_dev_devname(blkid_find_dev_with_tag(cache, "PARTLABEL", "system_b")))

You're on the right track. PARTLABEL and PARTUUID are stored in the
partition table, so it's unnecessary to scan partitions for their
content (filesystems).

> On first glance this looks useful as you don't have to loop through
> all the devices to use.
> 
> But this function only seems to work if the data is already cached, so
> it's not so useful on boot.

Yes, using blkid_dev_devname() is not advisable. It's part of the old
high-level libblkid API from the pre-udev era.

If you truly need to read data from the device, then utilizing the
low-level probing API is recommended. This can be done from the
command line with 'blkid -p', but you'll need to disable scanning for
all unwanted data (using '--usage no*'). For instance:

blkid -o udev -p --usages nofilesystem,raid,crypto,others /dev/sda1

This command will only return ID_PART_ENTRY_* data from the partition
table.

You can use the LIBBLKID_DEBUG=all environment variable to see
the library's operations.

The question arises whether using blkid is the ideal solution if you
only require PARTLABELs and PARTUUIDs. For example, sfdisk could be a
more efficient approach:

sfdisk -l /dev/sda -o+NAME,UUID

However, a potential issue is that sfdisk only provides the guessed
partition names (paths); the name used by the kernel might be different.

> Has anyone any ideas on how we can optimize the identification of a
> block device via UUID, LABEL, PARTUUID, PARTLABEL, etc.? Because the
> current implementations don't scale well when you have many block
> devices.

It depends on your goal. You can heavily customize your system to
speed up boot (all the necessary tools are available for this
purpose). However, the problem I see is the issue of portability and
the maintenance overhead.

Karel

-- 
 Karel Zak  
 http://karelzak.blogspot.com



Re: [systemd-devel] [PATCH] rfkill: Add systemd integration

2018-12-10 Thread Karel Zak
On Tue, Nov 27, 2018 at 07:16:04PM +0100, Stanislav Brabec wrote:
> Sami Kerola wrote:
> That said,
> > getting a clarification from Jochen would nice because otherwise we are
> > simply guessing.
> 
> Jochen Keil already left SUSE and I have no contact e-mail to him.
> 
> But I got complain that it is missing after migration of rfkill to util-linux:
> https://bugzilla.opensuse.org/show_bug.cgi?id=1092820

 It seems the best would be to ask upstream systemd guys. Maybe it's
 really Suse specific and maybe it's something we can support for more
 distros. I don't know.

 All thread:
 
https://lore.kernel.org/util-linux/0ce3309a-009a-7c00-3a2c-e4917b894...@suse.cz/T/#m221ad50b88792236c10c507f9163b57761c254a7

Karel

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


Re: [systemd-devel] systemd 210 - mount/umount/remount

2016-10-18 Thread Karel Zak
On Fri, Oct 14, 2016 at 12:06:00PM +0200, Michael Hirmke wrote:
> Hi *,
> 
> I've read the man pages and some more documentation about the mount
> behaviour of systemd, but I couldn't find a definitive answer to my
> questions.
> I have a backup script, that copies all files to backup to a hard disk
> partition, then duplicates the partition to one on a second disk, which
> in turn is changed every day. Before duplicating, the script tries to
> umount the partition on the original disk, does an fsck and then mounts
> the partition read only. When duplicating is finished, the original
> partition is remounted read write again.

Not sure if you copy individual files or all partition (dd(1) or so),
but would be enough to use fsfreeze(8) to avoid umount/mount? 

I guess you can call fsck on duplicated partition on the second disk.
IMHO fsfreeze is less invasive than umount. Or use LVM snapshots ;-)

Karel

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


Re: [systemd-devel] [packaging] split of systemd package

2015-11-12 Thread Karel Zak
On Thu, Nov 12, 2015 at 09:59:34AM +0100, Lennart Poettering wrote:
> The other option of course is to declare all internal APIs exported
> .so symbols, but that would mean to commit to a stable API for them
> (which is completely out of the question), or to bump the soname on
> each release (which is not an option either).

You don't have to change soname, but all you need it use symbols
versioning with package (or build) specific version for private-API.
This method uses libvirt.so where is large number of private but 
exported symbols.

 https://github.com/libvirt/libvirt/blob/master/src/Makefile.am#L2031

so something like:

 ...
 LIBSYSTEMD_227 {
 global:  
 sd_bus_default_flush_close;
 sd_bus_path_decode_many;
 sd_bus_path_encode_many;
 sd_listen_fds_with_names;
 } LIBSYSTEMD_226;
 

 LIBSYSTEMD_PRIVATE_$(VERSION) {
 global:
funcA;
funcB;
 };

where $(VERSION) is always different, then you can be sure that people
won't be able to link against the symbols and mix libsystemd with
systemd binaries from different versions.

Karel

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


Re: [systemd-devel] systemd-nspawn and process spawning using nsenter issue

2015-11-04 Thread Karel Zak
On Mon, Nov 02, 2015 at 03:36:49PM +, Richard Maw wrote:
> > for that? If not is there a kernel interface to create one?
> 
> I don't know of any utilities, but /proc/$pid/ns/net is a symlink pointing
> to a magic file that refers to the network namespace.

I think about "lsns" command to list namespaces where /proc/$pid/ns/*
is different to /proc/$ppid/ns/*, but not sure how usable it will be
and what information list. Suggestions & comments?

Karel

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


Re: [systemd-devel] SMACK runtime vs build-time checks? (aka: tmp.mount broke my boot)

2015-10-27 Thread Karel Zak
On Sun, Oct 18, 2015 at 12:22:15PM +0200, Kay Sievers wrote:
> On Sun, Oct 18, 2015 at 6:01 AM, Mantas Mikulėnas <graw...@gmail.com> wrote:
> > So far all existing SELinux and SMACK options had runtime checks – if
> > systemd was built with +SMACK but the kernel wasn't, it still worked fine.
> > (Arch uses such a configuration.)
> >
> > But then https://github.com/systemd/systemd/issues/1571 added an option to
> > tmp.mount which only depends on the build-time option, which creates
> > problems when booting a non-SMACK kernel...
> >
> > Any ideas on how to fix it? All previous such fixes were for API filesystems
> > in mount-setup.c and could do flexible checks, but that clearly won't work
> > for mount units.
> 
> I have reverted it. It needs a different solution.

I'm not sure how systemd mounts /tmp, but if you have mount(8) with
smack (util-linux --with-smack) and you have kernel with disabled
smack than mount(8) removes smack mount options before it calls
mount(2) syscall. 

It means that your fstab is always valid independently on your kernel.
The same we use for SELinux.  

Karel

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


Re: [systemd-devel] Stricter handling of failing mounts during boot under systemd - crap idea !

2015-07-02 Thread Karel Zak
On Mon, Jun 29, 2015 at 11:24:17PM +0200, Lennart Poettering wrote:
 Also, again, nofail predates systemd: you should have used it for
 your usecase even in sysvinit. If you so will, then the old setup was
 already borked for you, even though admittedly the effect was less
 fatal.

Note that nofail has been originally introduced for fsck and 
 
   mount -a

(used by initscripts) has never been sensitive to nofail. The mount
-a is very optimistic and it fails on fatal errors like ENOMEM only
and everything else is ignored. It means with sysvinit you do not 
need nofail. So for users who upgrade from sysvinit to systemd 
it seems like a regression.

Anyway, it does not mean that systemd nofail concept is wrong.

The original mount -a solution is fragile and IMHO it is better to have
explicit system setting in your fstab to distinguish between important
and unimportant filesystems.

Karel

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


[systemd-devel] [PATCH] mount: use libmount to monitor mountinfo utab

2015-06-03 Thread Karel Zak
The current implementation directly monitor /proc/self/mountinfo and
/run/mount/utab files. It's really not optimal because utab file is
private libmount stuff without any official guaranteed semantic.

The libmount since v2.26 provides API to monitor mount kernel 
userspace changes. This patch replaces the current implementation with
libmount based solution.

Now the manager.h includes libmount.h, so $MOUNT_CFLAGS has been
necessary to add to many tests CFLAGS.

Note that mnt_monitor_event_cleanup() in v2.26 is broken, so the patch
uses mnt_monitor_next_change(). It's exactly the same solution which
uses the current libmount HEAD (mnt_monitor_event_cleanup() is API
shorcut only).
---
V2:
 - update README
 - add missing (void) 

 Makefile.am|  33 --
 README |   2 +-
 configure.ac   |   2 +-
 src/core/manager.c |   2 +-
 src/core/manager.h |   5 ++-
 src/core/mount.c   | 100 -
 6 files changed, 50 insertions(+), 94 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 64038a5..c1a97de 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1329,7 +1329,8 @@ systemd_SOURCES = \
 
 systemd_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 systemd_LDADD = \
libsystemd-core.la \
@@ -1532,7 +1533,8 @@ test_engine_SOURCES = \
 
 test_engine_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_engine_LDADD = \
libsystemd-core.la \
@@ -1543,7 +1545,8 @@ test_job_type_SOURCES = \
 
 test_job_type_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_job_type_LDADD = \
libsystemd-core.la \
@@ -1587,7 +1590,8 @@ test_unit_name_SOURCES = \
 
 test_unit_name_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_unit_name_LDADD = \
libsystemd-core.la \
@@ -1598,7 +1602,8 @@ test_unit_file_SOURCES = \
 
 test_unit_file_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_unit_file_LDADD = \
libsystemd-core.la \
@@ -1811,7 +1816,8 @@ test_tables_CPPFLAGS = \
 
 test_tables_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_tables_LDADD = \
libsystemd-logs.la \
@@ -1944,7 +1950,8 @@ test_cgroup_mask_SOURCES = \
src/test/test-cgroup-mask.c
 
 test_cgroup_mask_CPPFLAGS = \
-   $(AM_CPPFLAGS)
+   $(AM_CPPFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_cgroup_mask_CFLAGS = \
$(AM_CFLAGS) \
@@ -1990,7 +1997,8 @@ test_path_SOURCES = \
src/test/test-path.c
 
 test_path_CFLAGS = \
-   $(AM_CFLAGS)
+   $(AM_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_path_LDADD = \
libsystemd-core.la
@@ -1999,7 +2007,8 @@ test_execute_SOURCES = \
src/test/test-execute.c
 
 test_execute_CFLAGS = \
-   $(AM_CFLAGS)
+   $(AM_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_execute_LDADD = \
libsystemd-core.la
@@ -2027,7 +2036,8 @@ test_sched_prio_SOURCES = \
src/test/test-sched-prio.c
 
 test_sched_prio_CPPFLAGS = \
-   $(AM_CPPFLAGS)
+   $(AM_CPPFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_sched_prio_CFLAGS = \
$(AM_CFLAGS) \
@@ -2104,7 +2114,8 @@ systemd_analyze_SOURCES = \
 
 systemd_analyze_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 systemd_analyze_LDADD = \
libsystemd-core.la \
diff --git a/README b/README
index b810044..19abeb2 100644
--- a/README
+++ b/README
@@ -114,7 +114,7 @@ REQUIREMENTS:
 
 glibc = 2.16
 libcap
-libmount = 2.20 (from util-linux)
+libmount = 2.26 (from util-linux)
 libseccomp = 1.0.0 (optional)
 libblkid = 2.24 (from util-linux) (optional)
 libkmod = 15 (optional)
diff --git a/configure.ac b/configure.ac
index 0532c54..61f9a0f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -438,7 +438,7 @@ AM_CONDITIONAL(HAVE_BLKID, [test $have_blkid = yes])
 
 # 
--
 have_libmount=no
-PKG_CHECK_MODULES(MOUNT, [ mount = 2.20 ],
+PKG_CHECK_MODULES(MOUNT, [ mount = 2.26 ],
 [AC_DEFINE(HAVE_LIBMOUNT, 1, [Define if libmount is available]) 
have_libmount=yes], have_libmount=no)
 if test x$have_libmount = xno; then
 AC_MSG_ERROR([*** libmount support required but libraries not found])
diff --git a/src/core/manager.c b/src/core/manager.c
index ae473d0..10ab83a 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -568,7 +568,7 @@ int manager_new(ManagerRunningAs running_as, bool test_run, 
Manager **_m) {
 
 m-idle_pipe[0] = m-idle_pipe[1] = m-idle_pipe[2] = m-idle_pipe[3] 
= -1;
 
-m-pin_cgroupfs_fd 

Re: [systemd-devel] [PATCH] mount: use libmount to monitor mountinfo utab

2015-06-02 Thread Karel Zak
On Mon, Jun 01, 2015 at 05:06:56PM +0200, Tom Gundersen wrote:
  -(void) 
  sd_event_source_set_description(m-mount_utab_event_source, 
  mount-utab-dispatch);
  +sd_event_source_set_description(m-mount_event_source, 
  mount-monitor-dispatch);
 
 This should be cast to (void) unless you check the return.

Frankly, I don't like it. It's old-style programming garbage. For
compiler it's probably irrelevant construction and for developers
(code readers) we have better things like warn_unused_result.

I have removed many of these (void) from util-linux and nobody
complains. 
 
If you really want to force people to check return code than mark 
function by warn_unused_result and if you still want to ignore the
result for these functions in some situations then you can use
something like:

# define ignore_result(x) __extension__ ({ \
__typeof__(x) __dummy __attribute__((__unused__)) = (x);
(void) __dummy; \
})


the result is more readable and obvious:

   ignore_result( sd_event_source_set_description(foo, bar ) );


Sometimes we use this macro to keep silent some crazy glibc functions.


Anyway, if (void) is really systemd coding style then I'm going to
update the patch. No problem ;-)

Karel

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


[systemd-devel] [PATCH] mount: use libmount to monitor mountinfo utab

2015-06-01 Thread Karel Zak
The current implementation directly monitor /proc/self/mountinfo and
/run/mount/utab files. It's really not optimal because utab file is
private libmount stuff without any official guaranteed semantic.

The libmount since v2.26 provides API to monitor mount kernel 
userspace changes. This patch replaces the current implementation with
libmount based solution.

Now the manager.h includes libmount.h, so $MOUNT_CFLAGS has been
necessary to add to many tests CFLAGS.

Note that mnt_monitor_event_cleanup() in v2.26 is broken, so the patch
uses mnt_monitor_next_change(). It's exactly the same solution which
uses the current libmount HEAD (mnt_monitor_event_cleanup() is API
shorcut only).
---
 Makefile.am|  33 --
 configure.ac   |   2 +-
 src/core/manager.c |   2 +-
 src/core/manager.h |   5 ++-
 src/core/mount.c   | 100 -
 5 files changed, 49 insertions(+), 93 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ed5135d..3815e72 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1352,7 +1352,8 @@ systemd_SOURCES = \
 
 systemd_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 systemd_LDADD = \
libsystemd-core.la \
@@ -1554,7 +1555,8 @@ test_engine_SOURCES = \
 
 test_engine_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_engine_LDADD = \
libsystemd-core.la \
@@ -1565,7 +1567,8 @@ test_job_type_SOURCES = \
 
 test_job_type_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_job_type_LDADD = \
libsystemd-core.la \
@@ -1609,7 +1612,8 @@ test_unit_name_SOURCES = \
 
 test_unit_name_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_unit_name_LDADD = \
libsystemd-core.la \
@@ -1620,7 +1624,8 @@ test_unit_file_SOURCES = \
 
 test_unit_file_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_unit_file_LDADD = \
libsystemd-core.la \
@@ -1838,7 +1843,8 @@ test_tables_CPPFLAGS = \
 
 test_tables_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_tables_LDADD = \
libsystemd-logs.la \
@@ -1973,7 +1979,8 @@ test_cgroup_mask_SOURCES = \
src/test/test-cgroup-mask.c
 
 test_cgroup_mask_CPPFLAGS = \
-   $(AM_CPPFLAGS)
+   $(AM_CPPFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_cgroup_mask_CFLAGS = \
$(AM_CFLAGS) \
@@ -2022,7 +2029,8 @@ test_path_SOURCES = \
src/test/test-path.c
 
 test_path_CFLAGS = \
-   $(AM_CFLAGS)
+   $(AM_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_path_LDADD = \
libsystemd-core.la
@@ -2031,7 +2039,8 @@ test_execute_SOURCES = \
src/test/test-execute.c
 
 test_execute_CFLAGS = \
-   $(AM_CFLAGS)
+   $(AM_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_execute_LDADD = \
libsystemd-core.la
@@ -2061,7 +2070,8 @@ test_sched_prio_SOURCES = \
src/test/test-sched-prio.c
 
 test_sched_prio_CPPFLAGS = \
-   $(AM_CPPFLAGS)
+   $(AM_CPPFLAGS) \
+   $(MOUNT_CFLAGS)
 
 test_sched_prio_CFLAGS = \
$(AM_CFLAGS) \
@@ -2133,7 +2143,8 @@ systemd_analyze_SOURCES = \
 
 systemd_analyze_CFLAGS = \
$(AM_CFLAGS) \
-   $(SECCOMP_CFLAGS)
+   $(SECCOMP_CFLAGS) \
+   $(MOUNT_CFLAGS)
 
 systemd_analyze_LDADD = \
libsystemd-core.la \
diff --git a/configure.ac b/configure.ac
index 48cedb5..74ec386 100644
--- a/configure.ac
+++ b/configure.ac
@@ -454,7 +454,7 @@ AM_CONDITIONAL(HAVE_BLKID, [test $have_blkid = yes])
 
 # 
--
 have_libmount=no
-PKG_CHECK_MODULES(MOUNT, [ mount = 2.20 ],
+PKG_CHECK_MODULES(MOUNT, [ mount = 2.26 ],
 [AC_DEFINE(HAVE_LIBMOUNT, 1, [Define if libmount is available]) 
have_libmount=yes], have_libmount=no)
 if test x$have_libmount = xno; then
 AC_MSG_ERROR([*** libmount support required but libraries not found])
diff --git a/src/core/manager.c b/src/core/manager.c
index b931b0d..6881bb2 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -567,7 +567,7 @@ int manager_new(ManagerRunningAs running_as, bool test_run, 
Manager **_m) {
 
 m-idle_pipe[0] = m-idle_pipe[1] = m-idle_pipe[2] = m-idle_pipe[3] 
= -1;
 
-m-pin_cgroupfs_fd = m-notify_fd = m-signal_fd = m-time_change_fd = 
m-dev_autofs_fd = m-private_listen_fd = m-kdbus_fd = m-utab_inotify_fd = -1;
+m-pin_cgroupfs_fd = m-notify_fd = m-signal_fd = m-time_change_fd = 
m-dev_autofs_fd = m-private_listen_fd = m-kdbus_fd = -1;
 m-current_job_id = 1; /* start as id #1, so that we can leave #0 
around as null-like value */
 
 m-ask_password_inotify_fd = -1;
diff --git a/src/core/manager.h 

[systemd-devel] [PATCH] build-sys: fix typo

2015-05-29 Thread Karel Zak
There is nothing like systemd_verify_* in Makefile.am. The bug has
been invisible because automake uses the default CFLAGS when component
CFLAGS are undefined.
---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index d6010c5..ed5135d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2131,7 +2131,7 @@ systemd_analyze_SOURCES = \
src/analyze/analyze-verify.c \
src/analyze/analyze-verify.h
 
-systemd_verify_CFLAGS = \
+systemd_analyze_CFLAGS = \
$(AM_CFLAGS) \
$(SECCOMP_CFLAGS)
 
-- 
2.4.1

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


[systemd-devel] [PATCH] swap: use swapon -o

2015-05-25 Thread Karel Zak
This patch simplify swapon usage in systemd. The command swapon(8)
since util-linux v2.26 supports -o list. The idea is exactly the
same like for mount(8). The -o specifies options in fstab-compatible
way. For systemd it means that it does not have to care about things
like discard or another swapon specific options.

swapon -o options-from-fstab

For backward compatibility the code cares about Priority: swap unit
field (for a case when Priority: is set, but pri= in the Options: is
missing).

References: 
http://lists.freedesktop.org/archives/systemd-devel/2014-October/023576.html
---
V2:
 - update README
 - add hint to systemd.swap man page
 - don't care about pri= in systed-fstab-generator at all
 - add warning about duplicate priority configuration
 - use warning rather than notice for non-parsable pri=

 README|  2 +-
 man/systemd.swap.xml  |  3 ++-
 src/core/swap.c   | 43 +++
 src/fstab-generator/fstab-generator.c | 28 ---
 4 files changed, 26 insertions(+), 50 deletions(-)

diff --git a/README b/README
index 039110e..2b8c68e 100644
--- a/README
+++ b/README
@@ -136,7 +136,7 @@ REQUIREMENTS:
 During runtime, you need the following additional
 dependencies:
 
-util-linux = v2.25 required
+util-linux = v2.26 required
 dbus = 1.4.0 (strictly speaking optional, but recommended)
 dracut (optional)
 PolicyKit (optional)
diff --git a/man/systemd.swap.xml b/man/systemd.swap.xml
index 5016f45..c398677 100644
--- a/man/systemd.swap.xml
+++ b/man/systemd.swap.xml
@@ -177,7 +177,8 @@
 
 listitemparaSwap priority to use when activating the swap
 device or file. This takes an integer. This setting is
-optional./para/listitem
+optional and ignored when priotiry is set by optionpri=/option in 
the
+varnameOptions=/varname option./para/listitem
   /varlistentry
 
   varlistentry
diff --git a/src/core/swap.c b/src/core/swap.c
index 12ebf84..193c8c3 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -717,8 +717,8 @@ fail:
 }
 
 static void swap_enter_activating(Swap *s) {
-_cleanup_free_ char *discard = NULL;
-int r, priority = -1;
+_cleanup_free_ char *opts = NULL;
+int r;
 
 assert(s);
 
@@ -726,13 +726,21 @@ static void swap_enter_activating(Swap *s) {
 s-control_command = s-exec_command + SWAP_EXEC_ACTIVATE;
 
 if (s-from_fragment) {
-fstab_filter_options(s-parameters_fragment.options, 
discard\0, NULL, discard, NULL);
+int priority = -1;
 
-priority = s-parameters_fragment.priority;
-if (priority  0) {
-r = fstab_find_pri(s-parameters_fragment.options, 
priority);
+r = fstab_find_pri(s-parameters_fragment.options, priority);
+if (r  0)
+log_warning_errno(r, Failed to parse swap priority 
\%s\, ignoring: %m, s-parameters_fragment.options);
+else if (r == 1  s-parameters_fragment.priority = 0)
+log_warning(Duplicate swap priority configuration by 
Priority and Options fields.);
+
+if (r = 0  s-parameters_fragment.priority = 0) {
+if (s-parameters_fragment.options)
+r = asprintf(opts, %s,pri=%i, 
s-parameters_fragment.options, s-parameters_fragment.priority);
+else
+r = asprintf(opts, pri=%i, 
s-parameters_fragment.priority);
 if (r  0)
-log_notice_errno(r, Failed to parse swap 
priority \%s\, ignoring: %m, s-parameters_fragment.options);
+goto fail;
 }
 }
 
@@ -740,24 +748,9 @@ static void swap_enter_activating(Swap *s) {
 if (r  0)
 goto fail;
 
-if (priority = 0) {
-char p[DECIMAL_STR_MAX(int)];
-
-sprintf(p, %i, priority);
-r = exec_command_append(s-control_command, -p, p, NULL);
-if (r  0)
-goto fail;
-}
-
-if (discard  !streq(discard, none)) {
-const char *discard_arg;
-
-if (streq(discard, all))
-discard_arg = --discard;
-else
-discard_arg = strjoina(--discard=, discard);
-
-r = exec_command_append(s-control_command, discard_arg, NULL);
+if (s-parameters_fragment.options || opts) {
+r = exec_command_append(s-control_command, -o,
+opts ? : s-parameters_fragment.options, NULL);
 if (r  0)
 goto fail;
 }
diff --git a/src/fstab-generator/fstab-generator.c 

Re: [systemd-devel] [PATCH] swap: use swapon -o

2015-05-21 Thread Karel Zak
On Thu, May 21, 2015 at 04:45:44PM +0200, Lennart Poettering wrote:
 I think it might be a good idea to log a warning if the priority is
 specified both in s-parameters_frament.priority and in
 s-parameters_fragment.options.

This (priority specified by both fields) is standard fstab-generator behaviour.
Maybe the generator should be also updated to stop generate Priority:.

Karel

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


[systemd-devel] [PATCH] swap: use swapon -o

2015-05-20 Thread Karel Zak
This patch simplify swapon usage in systemd. The command swapon(8)
since util-linux v2.26 supports -o list. The idea is exactly the
same like for mount(8). The -o specifies options in fstab-compatible
way. For systemd it means that it does not have to care about things
like discard or another swapon specific options.

swapon -o options-from-fstab

For backward compatibility the code cares about Priority: swap unit
field (for a case when Priority: is set, but pri= in the Options: is
missing).

References: 
http://lists.freedesktop.org/archives/systemd-devel/2014-October/023576.html
---
 src/core/swap.c | 41 -
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/src/core/swap.c b/src/core/swap.c
index 12ebf84..658ac8b 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -717,8 +717,8 @@ fail:
 }
 
 static void swap_enter_activating(Swap *s) {
-_cleanup_free_ char *discard = NULL;
-int r, priority = -1;
+_cleanup_free_ char *opts = NULL;
+int r;
 
 assert(s);
 
@@ -726,13 +726,19 @@ static void swap_enter_activating(Swap *s) {
 s-control_command = s-exec_command + SWAP_EXEC_ACTIVATE;
 
 if (s-from_fragment) {
-fstab_filter_options(s-parameters_fragment.options, 
discard\0, NULL, discard, NULL);
+int priority = -1;
+
+r = fstab_find_pri(s-parameters_fragment.options, priority);
+if (r  0)
+log_notice_errno(r, Failed to parse swap priority 
\%s\, ignoring: %m, s-parameters_fragment.options);
 
-priority = s-parameters_fragment.priority;
-if (priority  0) {
-r = fstab_find_pri(s-parameters_fragment.options, 
priority);
+if (r = 0  s-parameters_fragment.priority = 0) {
+if (s-parameters_fragment.options)
+r = asprintf(opts, %s,pri=%i, 
s-parameters_fragment.options, s-parameters_fragment.priority);
+else
+r = asprintf(opts, pri=%i, 
s-parameters_fragment.priority);
 if (r  0)
-log_notice_errno(r, Failed to parse swap 
priority \%s\, ignoring: %m, s-parameters_fragment.options);
+goto fail;
 }
 }
 
@@ -740,24 +746,9 @@ static void swap_enter_activating(Swap *s) {
 if (r  0)
 goto fail;
 
-if (priority = 0) {
-char p[DECIMAL_STR_MAX(int)];
-
-sprintf(p, %i, priority);
-r = exec_command_append(s-control_command, -p, p, NULL);
-if (r  0)
-goto fail;
-}
-
-if (discard  !streq(discard, none)) {
-const char *discard_arg;
-
-if (streq(discard, all))
-discard_arg = --discard;
-else
-discard_arg = strjoina(--discard=, discard);
-
-r = exec_command_append(s-control_command, discard_arg, NULL);
+if (s-parameters_fragment.options || opts) {
+r = exec_command_append(s-control_command, -o,
+opts ? : s-parameters_fragment.options, NULL);
 if (r  0)
 goto fail;
 }
-- 
2.1.0

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


[systemd-devel] [PATCH] fstab-generator: add x-systemd.requires and x-systemd.requires-mounts-for

2015-05-18 Thread Karel Zak
Currently we have no way how to specify dependencies between fstab
entries (or another units) in the /etc/fstab. It means that users are
forced to bypass fstab and write .mount units manually.

The patch introduces new systemd fstab options:

x-systemd.requires=PATH

 - to specify dependence an another mount (PATH is translated to unit name)

x-systemd.requires=UNIT

 - to specify dependence on arbitrary UNIT

x-systemd.requires-mounts-for=PATH ...

 - to specify dependence on another paths, implemented by
   RequiresMountsFor=. The option may be specified more than once.

For example two bind mounts where B depends on A:

 /mnt/test/A/mnt/test/A nonebind,defaults
 /mnt/test/A/mnt/test/B nonebind,x-systemd.requires=/mnt/test/A

More complex example with overlay FS where one mount point depends on
low and upper directories:

 /dev/sdc1   /mnt/lowext4 defaults
 /dev/sdc2   /mnt/high   ext4 defaults
 overlay /mnt/merged overlay  
lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work,x-systemd.requires-mounts-for=/mnt/low,x-systemd.requires-mounts-for=mnt/high

References: https://bugzilla.redhat.com/show_bug.cgi?id=812826
---
v4:
 - allow to specify x-systemd.requires= more than once
 - add OOM check, simplify strv usage in fstab_extract_values()
v3:
 - add generic fstab_extract_values() to fstab-util.c
 - completely rely on unit_name_mangle_with_suffix()
v2:
 - rename x-systemd.after to x-systemd.requires
 - allow to specify x-systemd.requires-mounts-for= more than once
 - propagate errors
 - fix some typos

 man/systemd.mount.xml | 20 +
 src/fstab-generator/fstab-generator.c | 77 +++
 src/shared/fstab-util.c   | 30 ++
 src/shared/fstab-util.h   |  2 +
 4 files changed, 129 insertions(+)

diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
index 862f42e..7e9435e 100644
--- a/man/systemd.mount.xml
+++ b/man/systemd.mount.xml
@@ -139,6 +139,26 @@
 variablelist class='fstab-options'
 
   varlistentry
+termoptionx-systemd.requires=/option/term
+
+listitemparaConfigures varnameAfter=/varname and 
varnameRequires=/varname dependency
+between the mount and another mount, device or systemd unit. The 
argument is absolute path or unit name.
+This option may be specified more than once. See 
varnameAfter=/varname and varnameRequires=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+  /varlistentry
+
+  varlistentry
+termoptionx-systemd.requires-mounts-for=/option/term
+
+listitemparaConfigures varnameRequiresMountsFor=/varname 
dependency between the mount and
+another mount. The argument must be absolute path. This option may be 
specified more than once.
+See varnameRequiresMountsFor=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+   /varlistentry
+
+  varlistentry
 termoptionx-systemd.automount/option/term
 
 listitemparaAn automount unit will be created for the file
diff --git a/src/fstab-generator/fstab-generator.c 
b/src/fstab-generator/fstab-generator.c
index 167ec60..2327825 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -177,6 +177,65 @@ static int write_idle_timeout(FILE *f, const char *where, 
const char *opts) {
 return 0;
 }
 
+static int write_requires_after(FILE *f, const char *opts) {
+_cleanup_strv_free_ char **names = NULL, **units = NULL;
+_cleanup_free_ char *res = NULL;
+char **s;
+int r;
+
+assert(f);
+assert(opts);
+
+r = fstab_extract_values(opts, x-systemd.requires, names);
+if (r  0)
+return log_warning_errno(r, Failed to parse options: %m);
+if (r == 0)
+return 0;
+
+STRV_FOREACH(s, names) {
+char *x;
+
+r = unit_name_mangle_with_suffix(*s, UNIT_NAME_NOGLOB, 
.mount, x);
+if (r  0)
+return log_error_errno(r, Failed to generate unit 
name: %m);
+r = strv_push(units, x);
+if (r  0)
+log_oom();
+}
+
+if (units) {
+res = strv_join(units,  );
+if (!res)
+return log_oom();
+fprintf(f, After=%1$s\nRequires=%1$s\n, res);
+}
+
+return 0;
+}
+
+static int write_requires_mounts_for(FILE *f, const char *opts) {
+_cleanup_strv_free_ char **paths = NULL;
+_cleanup_free_ char *res = NULL;
+int r;
+
+assert(f);
+assert(opts);
+
+r = fstab_extract_values(opts, x-systemd.requires-mounts-for, 
paths);
+if (r  0)
+   

[systemd-devel] [PATCH] fstab-generator: add x-systemd.requires and x-systemd.requires-mounts-for

2015-05-15 Thread Karel Zak
Currently we have no way how to specify dependencies between fstab
entries (or another units) in the /etc/fstab. It means that users are
forced to bypass fstab and write .mount units manually.

The patch introduces new systemd fstab options:

x-systemd.requires=PATH

 - to specify dependence an another mount (PATH is translated to unit name)

x-systemd.requires=UNIT

 - to specify dependence on arbitrary UNIT

x-systemd.requires-mounts-for=PATH ...

 - to specify dependence on another paths, implemented by
   RequiresMountsFor=. The option may be specified more than once.

For example two bind mounts where B depends on A:

 /mnt/test/A/mnt/test/A nonebind,defaults
 /mnt/test/A/mnt/test/B nonebind,x-systemd.requires=/mnt/test/A

More complex example with overlay FS where one mount point depends on
low and upper directories:

 /dev/sdc1   /mnt/lowext4 defaults
 /dev/sdc2   /mnt/high   ext4 defaults
 overlay /mnt/merged overlay  
lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work,x-systemd.requires-mounts-for=/mnt/low,x-systemd.requires-mounts-for=mnt/high

References: https://bugzilla.redhat.com/show_bug.cgi?id=812826
---
v3:
 - add generic fstab_extract_values() to fstab-util.c
 - completely rely on unit_name_mangle_with_suffix()
v2:
 - rename x-systemd.after to x-systemd.requires
 - allow to specify x-systemd.requires-mounts-for= more than once
 - propagate errors
 - fix some typos

 man/systemd.mount.xml | 20 +++
 src/fstab-generator/fstab-generator.c | 63 +++
 src/shared/fstab-util.c   | 35 +++
 src/shared/fstab-util.h   |  2 ++
 4 files changed, 120 insertions(+)

diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
index 862f42e..58ad6a6 100644
--- a/man/systemd.mount.xml
+++ b/man/systemd.mount.xml
@@ -139,6 +139,26 @@
 variablelist class='fstab-options'
 
   varlistentry
+termoptionx-systemd.requires=/option/term
+
+listitemparaConfigures varnameAfter=/varname and 
varnameRequires=/varname dependency
+between the mount and another mount or systemd unit. The argument is 
absolute path to
+another mount point or unit name. See varnameAfter=/varname and 
varnameRequires=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+  /varlistentry
+
+  varlistentry
+termoptionx-systemd.requires-mounts-for=/option/term
+
+listitemparaConfigures varnameRequiresMountsFor=/varname 
dependency between the mount and
+another mount. The argument must be absolute path. This option may be 
specified more than once.
+See varnameRequiresMountsFor=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+   /varlistentry
+
+  varlistentry
 termoptionx-systemd.automount/option/term
 
 listitemparaAn automount unit will be created for the file
diff --git a/src/fstab-generator/fstab-generator.c 
b/src/fstab-generator/fstab-generator.c
index 167ec60..a162489 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -177,6 +177,51 @@ static int write_idle_timeout(FILE *f, const char *where, 
const char *opts) {
 return 0;
 }
 
+static int write_requires_after(FILE *f, const char *opts) {
+_cleanup_free_ char *arg = NULL, *unit = NULL;
+int r;
+
+assert(f);
+assert(opts);
+
+r = fstab_filter_options(opts, x-systemd.requires\0, NULL, arg, 
NULL);
+if (r  0)
+return log_warning_errno(r, Failed to parse options: %m);
+if (r == 0)
+return 0;
+
+r = unit_name_mangle_with_suffix(arg, UNIT_NAME_NOGLOB, .mount, 
unit);
+if (r  0)
+return log_error_errno(r, Failed to generate unit name: %m);
+
+fprintf(f, After=%1$s\nRequires=%1$s\n, unit);
+
+return 0;
+}
+
+static int write_requires_mounts_for(FILE *f, const char *opts) {
+_cleanup_strv_free_ char **paths = NULL;
+_cleanup_free_ char *res = NULL;
+int r;
+
+assert(f);
+assert(opts);
+
+r = fstab_extract_values(opts, x-systemd.requires-mounts-for, 
paths);
+if (r  0)
+return log_warning_errno(r, Failed to parse options: %m);
+if (r == 0)
+return 0;
+
+res = strv_join(paths,  );
+if (!res)
+return log_oom();
+
+fprintf(f, RequiresMountsFor=%s\n, res);
+
+return 0;
+}
+
 static int add_mount(
 const char *what,
 const char *where,
@@ -251,6 +296,15 @@ static int add_mount(
 if (post  !noauto  !nofail  !automount)
 fprintf(f, Before=%s\n, post);
 
+if (!automount  opts) {
+ 

[systemd-devel] [PATCH v2] fstab-generator: add x-systemd.requires and x-systemd.requires-mounts-for

2015-05-14 Thread Karel Zak
Currently we have no way how to specify dependencies between fstab
entries (or another units) in the /etc/fstab. It means that users are
forced to bypass fstab and write .mount units manually.

The patch introduces new systemd fstab options:

x-systemd.requires=PATH

 - to specify dependence an another mount (PATH is translated to unit name)

x-systemd.requires=UNIT

 - to specify dependence on arbitrary UNIT

x-systemd.requires-mounts-for=PATH ...

 - to specify dependence on another paths, implemented by
   RequiresMountsFor=. The option may be specified more than once.

For example two bind mounts where B depends on A:

 /mnt/test/A/mnt/test/A nonebind,defaults
 /mnt/test/A/mnt/test/B nonebind,x-systemd.requires=/mnt/test/A

More complex example with overlay FS where one mount point depends on
low and upper directories:

 /dev/sdc1   /mnt/lowext4 defaults
 /dev/sdc2   /mnt/high   ext4 defaults
 overlay /mnt/merged overlay  
lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work,x-systemd.requires-mounts-for=/mnt/low,x-systemd.requires-mounts-for=mnt/high

References: https://bugzilla.redhat.com/show_bug.cgi?id=812826
---

v2:
 - rename x-systemd.after to x-systemd.requires
 - allow to specify x-systemd.requires-mounts-for= more than once
 - propagate errors
 - fix some typos

 man/systemd.mount.xml | 20 +
 src/fstab-generator/fstab-generator.c | 83 +++
 2 files changed, 103 insertions(+)

diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
index 862f42e..58ad6a6 100644
--- a/man/systemd.mount.xml
+++ b/man/systemd.mount.xml
@@ -139,6 +139,26 @@
 variablelist class='fstab-options'
 
   varlistentry
+termoptionx-systemd.requires=/option/term
+
+listitemparaConfigures varnameAfter=/varname and 
varnameRequires=/varname dependency
+between the mount and another mount or systemd unit. The argument is 
absolute path to
+another mount point or unit name. See varnameAfter=/varname and 
varnameRequires=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+  /varlistentry
+
+  varlistentry
+termoptionx-systemd.requires-mounts-for=/option/term
+
+listitemparaConfigures varnameRequiresMountsFor=/varname 
dependency between the mount and
+another mount. The argument must be absolute path. This option may be 
specified more than once.
+See varnameRequiresMountsFor=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+   /varlistentry
+
+  varlistentry
 termoptionx-systemd.automount/option/term
 
 listitemparaAn automount unit will be created for the file
diff --git a/src/fstab-generator/fstab-generator.c 
b/src/fstab-generator/fstab-generator.c
index 167ec60..29517e7 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -177,6 +177,71 @@ static int write_idle_timeout(FILE *f, const char *where, 
const char *opts) {
 return 0;
 }
 
+static int write_requires_after(FILE *f, const char *opts) {
+_cleanup_free_ char *arg = NULL, *unit = NULL;
+int r;
+
+assert(f);
+assert(opts);
+
+r = fstab_filter_options(opts, x-systemd.requires\0, NULL, arg, 
NULL);
+if (r  0)
+return log_warning_errno(r, Failed to parse options: %m);
+if (r == 0)
+return 0;
+
+if (*arg == '/') {
+r = unit_name_mangle_with_suffix(arg, UNIT_NAME_NOGLOB, 
.mount, unit);
+if (r  0)
+return log_error_errno(r, Failed to generate unit 
name: %m);
+} else
+unit = arg;
+
+fprintf(f, After=%1$s\nRequires=%1$s\n, unit);
+
+if (unit == arg)
+unit = NULL;
+
+return 0;
+}
+
+#define REQUIRES_MOUNTS_OPTx-systemd.requires-mounts-for=
+
+static int write_requires_mounts_for(FILE *f, const char *opts) {
+_cleanup_free_ char **optsv = NULL, **paths = NULL, *res = NULL;
+char **s;
+
+assert(f);
+assert(opts);
+
+optsv = strv_split(opts, ,);
+if (!optsv)
+return log_oom();
+
+STRV_FOREACH(s, optsv) {
+char *arg;
+
+if (!startswith(*s, REQUIRES_MOUNTS_OPT))
+continue;
+arg = *s + strlen(REQUIRES_MOUNTS_OPT);
+if (!*arg)
+return log_warning(Failed to parse option  
REQUIRES_MOUNTS_OPT);
+if (!paths)
+paths = strv_new(arg, NULL);
+else
+strv_push(paths, arg);
+}
+
+if (paths) {
+res = strv_join(paths,  );
+

Re: [systemd-devel] [PATCH v2] fstab-generator: add x-systemd.requires and x-systemd.requires-mounts-for

2015-05-14 Thread Karel Zak
On Thu, May 14, 2015 at 01:27:40PM +0200, Karel Zak wrote:
 +static int write_requires_mounts_for(FILE *f, const char *opts) {
 +_cleanup_free_ char **optsv = NULL, **paths = NULL, *res = NULL;

 _cleanup_strv_free_ **optsv = NULL, **paths = NULL;

 Do I need to resend the patch? ;-)

Karel

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


Re: [systemd-devel] [PATCH] fstab-generator: add x-systemd.{after, requires-mounts-for}=

2015-05-13 Thread Karel Zak
On Wed, May 13, 2015 at 06:35:58AM +0300, Andrei Borzenkov wrote:
 В Tue, 12 May 2015 20:37:15 +0200
 Karel Zak k...@redhat.com пишет:
 
  On Tue, May 12, 2015 at 07:29:33PM +0300, Andrei Borzenkov wrote:
   В Tue, 12 May 2015 18:04:50 +0200
   Karel Zak k...@redhat.com пишет:
   
Currently we have no way how to specify dependencies between fstab
entries (or another units) in the /etc/fstab. It means that users are
forced to bypass fstab and write .mount units manually.

   
   Actually we have.
   
   mkdir -p /etc/systemd/system/path-to-mount-point.mount.d
   cat  /etc/systemd/system/path-to-mount-point.mount.d/deps.conf  EOF
   [Unit]
   After=xxx
   Before=xxx
   Wants=xxx
   Requires=xxx
   EOF
  
  You miss the point -- keep all in fstab.
  
 
 I admit I do. Why? We want to keep in fstab bits and pieces that are
 common with other utilities. Which other tool needs to know systemd
 dependencies?

 Did you read the reference in the patch? It's not about systemd
 dependences, but about dependences between mount points. The fstab
 has been originally (by mount -a) serialized during boot. Now it's
 parallelized and in some cases it's bad thing and without extra
 configuration systemd is not able to understand the dependencies in
 fstab. It's admins' nightmare to require additional file somewhere in 
 /etc/systemd to fix systemd fstab interpretation.

 BTW, we already have x-systemd stuff in fstab...

Karel


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


[systemd-devel] [PATCH] fstab-generator: add x-systemd.{after, requires-mounts-for}=

2015-05-12 Thread Karel Zak
Currently we have no way how to specify dependencies between fstab
entries (or another units) in the /etc/fstab. It means that users are
forced to bypass fstab and write .mount units manually.

Years ago Lennart suggested to add

x-systemd.after=PATH

 - to specify dependence an another mount (PATH is translated to PATH.mount)

x-systemd.after=UNIT

 - to specify dependence on arbitrary UNIT

The x-systemd.after= is implemented by After= and Requires=.

x-systemd.requires-mounts-for=PATH ...

 - to specify dependence on another paths, implemented by
   RequiresMountsFor=.

For example two bind mounts where B depends on A:

 /mnt/test/A/mnt/test/A nonebind,defaults
 /mnt/test/A/mnt/test/B nonebind,x-systemd.after=/mnt/test/A

More complex example with overlay FS where one mount point depends on
low and upper directories:

 /dev/sdc1   /mnt/lowext4 defaults
 /dev/sdc2   /mnt/high   ext4 defaults
 overlay /mnt/merged overlay  
lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work,x-systemd.requires-mounts-for=/mnt/low\040/mnt/high

References: https://bugzilla.redhat.com/show_bug.cgi?id=812826
Signed-off-by: Karel Zak k...@redhat.com
---
 man/systemd.mount.xml | 21 +++
 src/fstab-generator/fstab-generator.c | 49 +++
 2 files changed, 70 insertions(+)

diff --git a/man/systemd.mount.xml b/man/systemd.mount.xml
index 862f42e..34614cb 100644
--- a/man/systemd.mount.xml
+++ b/man/systemd.mount.xml
@@ -139,6 +139,27 @@
 variablelist class='fstab-options'
 
   varlistentry
+termoptionx-systemd.after=/option/term
+
+listitemparaConfigures varnameAfter=/varname and 
varnameRequires=/varname dependence
+between the mount and another mount or systemd unit. The argument is 
absolute path to
+another mount point or unit name. See varnameAfter=/varname and 
varnameRequires=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+  /varlistentry
+
+  varlistentry
+termoptionx-systemd.requires-mounts-for=/option/term
+
+listitemparaConfigures varnameRequiresMountsFor=/varname 
dependence between the mount and
+another mount. The argument is a space-separated list of absolute 
paths. Note
+that filename/etc/fstab/filename format requires to escape space 
as \040.
+See varnameRequiresMountsFor=/varname in
+
citerefentryrefentrytitlesystemd.unit/refentrytitlemanvolnum5/manvolnum/citerefentry
+for details./para/listitem
+   /varlistentry
+
+  varlistentry
 termoptionx-systemd.automount/option/term
 
 listitemparaAn automount unit will be created for the file
diff --git a/src/fstab-generator/fstab-generator.c 
b/src/fstab-generator/fstab-generator.c
index 167ec60..a5f13fd 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -177,6 +177,45 @@ static int write_idle_timeout(FILE *f, const char *where, 
const char *opts) {
 return 0;
 }
 
+static int write_requires_after(FILE *f, const char *opts) {
+_cleanup_free_ char *arg = NULL, *unit = NULL;
+int r;
+
+r = fstab_filter_options(opts, x-systemd.after\0, NULL, arg, NULL);
+if (r  0)
+return log_warning_errno(r, Failed to parse options: %m);
+if (r == 0)
+return 0;
+
+if (*arg == '/') {
+r = unit_name_from_path(arg, .mount, unit);
+if (r  0)
+return log_error_errno(r, Failed to generate unit 
name: %m);
+} else
+unit = arg;
+
+fprintf(f, After=%1$s\nRequires=%1$s\n, unit);
+
+if (unit == arg)
+unit = NULL;
+
+return 0;
+}
+
+static int write_requires_mounts_for(FILE *f, const char *opts) {
+_cleanup_free_ char *arg;
+int r;
+
+r = fstab_filter_options(opts, x-systemd.requires-mounts-for\0, 
NULL, arg, NULL);
+if (r  0)
+return log_warning_errno(r, Failed to parse options: %m);
+if (r == 0)
+return 0;
+
+fprintf(f, RequiresMountsFor=%s\n, arg);
+return 0;
+}
+
 static int add_mount(
 const char *what,
 const char *where,
@@ -251,6 +290,11 @@ static int add_mount(
 if (post  !noauto  !nofail  !automount)
 fprintf(f, Before=%s\n, post);
 
+if (!automount  opts) {
+ write_requires_after(f, opts);
+ write_requires_mounts_for(f, opts);
+}
+
 if (passno != 0) {
 r = generator_write_fsck_deps(f, arg_dest, what, where, 
fstype);
 if (r  0)
@@ -315,6 +359,11 @@ static int add_mount(
 Before=%s\n,
 post);
 
+if (opts

Re: [systemd-devel] [PATCH] fstab-generator: add x-systemd.{after, requires-mounts-for}=

2015-05-12 Thread Karel Zak
On Tue, May 12, 2015 at 07:29:33PM +0300, Andrei Borzenkov wrote:
 В Tue, 12 May 2015 18:04:50 +0200
 Karel Zak k...@redhat.com пишет:
 
  Currently we have no way how to specify dependencies between fstab
  entries (or another units) in the /etc/fstab. It means that users are
  forced to bypass fstab and write .mount units manually.
  
 
 Actually we have.
 
 mkdir -p /etc/systemd/system/path-to-mount-point.mount.d
 cat  /etc/systemd/system/path-to-mount-point.mount.d/deps.conf  EOF
 [Unit]
 After=xxx
 Before=xxx
 Wants=xxx
 Requires=xxx
 EOF

You miss the point -- keep all in fstab.

Karel

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


Re: [systemd-devel] [PATCH] automount: add expire support

2015-04-14 Thread Karel Zak
On Sun, Apr 12, 2015 at 10:33:54PM +0200, Jan Luca Naumann wrote:
 I'm not a systemd-developer so I want to ask you if it is possible to
 add a hook for execute something after the unmount (for example to
 delete the mount directory)?

 well, /proc/mount and /proc/self/mountinfo are poll-able, so you do
 not need systemd to listen for the changes.

findmnt --first-only --poll=umount /mnt/foo
rmdir /mnt/foo


 Karel

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


Re: [systemd-devel] [PATCH] path_is_mount_point: handle false positive on some fs

2015-03-11 Thread Karel Zak
On Tue, Mar 10, 2015 at 04:53:38PM +0100, Lennart Poettering wrote:
 Note that the st_dev thing is the traditional way to detect whether
 one crosses a file system boundary. It's used for this by tools like
 cp, find,  We slightly enhance this by using name_to_handle_at(),
 so that we can also detect bind mounts from file systems onto
 themselves. Now, if overlayfs breaks the same file system logic of all
 other tools, I am not convinced that systemd should not be broken by
 it too.. It sounds surprising that we should work around this in
 systemd, but not in all other tools. 
 
 Or to turn this around: instead of patching systemd the better idea
 would probably be to teach overlayfs name_to_handle_at() support, so

 +1

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


Re: [systemd-devel] [PATCH] path_is_mount_point: handle false positive on some fs

2015-03-10 Thread Karel Zak
On Mon, Mar 09, 2015 at 11:27:09AM +0100, Didier Roche wrote:
 Also we could on the longer term maybe getting the whole path_is_mount_point()
 logic into libmount from util-linux, using mnt_get_mountpoint() (but this
 one only use st_dev comparison presently)?

 mnt_table_find_mountpoint()

 
http://ftp.kernel.org/pub/linux/utils/util-linux/v2.26/libmount-docs/libmount-Table-of-filesystems.html#mnt-table-find-mountpoint

Karel

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


Re: [systemd-devel] [PATCH] Re: fstab mounts get unmounted during boot (.device unit bouncing?) -- solution

2015-02-23 Thread Karel Zak
On Thu, Feb 12, 2015 at 05:33:26PM +0100, Martin Pitt wrote:
 \o/ looking forward to let /etc/mtab die a bit more :-)

util-linux v2.26 (released last week) provides 
 
--enable-libmount-force-mountinfo

configure option to make mtab's grave more robust.

Karel


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


Re: [systemd-devel] [PATCH] Re: fstab mounts get unmounted during boot (.device unit bouncing?) -- solution

2015-02-12 Thread Karel Zak
On Thu, Feb 12, 2015 at 10:40:15AM +0100, Martin Pitt wrote:
 So explicitly specify the file that we actually want to parse.
 
 [1] first boot after a distro upgrade, or a package bug, or administrators
 configuring it explicitly for some reason
 
 https://launchpad.net/bugs/1419623
 ---
  src/core/mount.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/core/mount.c b/src/core/mount.c
 index f3977e6..61fd526 100644
 --- a/src/core/mount.c
 +++ b/src/core/mount.c
 @@ -1566,7 +1566,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, 
 bool set_flags) {
  if (!tb || !itr)
  return log_oom();
  
 -r = mnt_table_parse_mtab(tb, NULL);
 +r = mnt_table_parse_mtab(tb, /proc/self/mountinfo);


This is bad solution. It resolves the issue, but forces libmount to
not read /run/mount/utab.

It would be better to ignore this problem for now, I'll very probably
add a new build-system option to disable libmount mtab parsing at all.
The heuristic which libmount uses to decide between mtab and mountinfo
is unnecessary in mainstream distros.

Karel

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


Re: [systemd-devel] [PATCH] Re: fstab mounts get unmounted during boot (.device unit bouncing?) -- solution

2015-02-12 Thread Karel Zak
On Thu, Feb 12, 2015 at 12:25:33PM +0100, Karel Zak wrote:
 On Thu, Feb 12, 2015 at 10:40:15AM +0100, Martin Pitt wrote:
  So explicitly specify the file that we actually want to parse.
  
  [1] first boot after a distro upgrade, or a package bug, or administrators
  configuring it explicitly for some reason
  
  https://launchpad.net/bugs/1419623
  ---
   src/core/mount.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/src/core/mount.c b/src/core/mount.c
  index f3977e6..61fd526 100644
  --- a/src/core/mount.c
  +++ b/src/core/mount.c
  @@ -1566,7 +1566,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, 
  bool set_flags) {
   if (!tb || !itr)
   return log_oom();
   
  -r = mnt_table_parse_mtab(tb, NULL);
  +r = mnt_table_parse_mtab(tb, /proc/self/mountinfo);
 
 
 This is bad solution. It resolves the issue, but forces libmount to
 not read /run/mount/utab.
 
 It would be better to ignore this problem for now, I'll very probably
 add a new build-system option to disable libmount mtab parsing at all.
 The heuristic which libmount uses to decide between mtab and mountinfo
 is unnecessary in mainstream distros.

I will also improve mnt_table_parse_mtab() to check if we read the
filesystems from kernel (from /proc) and if yes than it will always
read /run/mount/utab too. The result will be more robust for people
who use libmount with mtab parsing code.

Karel

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


Re: [systemd-devel] [PATCH] Re: fstab mounts get unmounted during boot (.device unit bouncing?) -- solution

2015-02-12 Thread Karel Zak
On Thu, Feb 12, 2015 at 03:38:13PM +0100, Lennart Poettering wrote:
 If I am right then as soon as you fixed libmount so that the whole
 handling of /etc/mtab can be turned off, then you will make that the
 default in Fedora, and no changes to systemd will be necessary at all,
 correct?

 Correct.

Karel


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


Re: [systemd-devel] [PATCH] Re: fstab mounts get unmounted during boot (.device unit bouncing?) -- solution

2015-02-12 Thread Karel Zak
On Thu, Feb 12, 2015 at 12:01:13PM +0100, Lennart Poettering wrote:
 And the stuff from /run is always merged into it, regardless which
 file is read?

 No, if you specify any filename and the file exists than it does not
 read from /run, I have fixed this mistake


https://github.com/karelzak/util-linux/commit/60d29f827b94097fb718dcb02fad6ccb571bdb2b

 so don't use Martin's patch on systems with util-linux  2.26 (now
 -rc2, stable next week).

Karel

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


Re: [systemd-devel] [PATCH] cdrom_id: unmount media on --eject-media if media mounted

2015-01-16 Thread Karel Zak
On Thu, Jan 15, 2015 at 03:42:28PM +0100, Martin Pitt wrote:
 ... which leads me to the question: why don't we just call the actual
 eject program? Just to avoid that dependency?

 BTW, eject is maintained in util-linxu now, and it's based on
 libmount and sysfs stuff we have in util-linux (and systemd already
 depends on util-linux).

Karel

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-18 Thread Karel Zak
On Wed, Dec 17, 2014 at 08:04:38PM +0100, Lennart Poettering wrote:
  This is important details, because if you use epoll file descriptor 
  in another epoll then you're correctly notified on the top-level epoll, 
  but you lost information about which underneath file descriptor is active 
  -- then it was impossible to verify the inotify IN_MOVED_TO utab
  event.
 
 Hmm? Not following. The top-level epoll will get an event telling you
 that which low-level epoll is triggered. Then, you read an event from
 that which tells you precisely which actual file has been triggered...

Yes, was my original idea, then followed by frustration ;-) 

It seems it the hierarchy of epolls works only if all the file
descriptors are with EPOLLIN. I had /proc/self/mountinfo with EPOLLPRI
only (because with EPOLLIN it generates events all time as I don't
read the file content).

Today I played with it a little bit more and I found that possible
solution is to use EPOLLPRI | EPOLLIN | EPOLLET for the /proc/self/mountinfo.

Ideas?

   Karel


PS. if anyone wants to play with it then below is test program, just
copy and past to test.c

 $ make test
 $ touch AAA BBB
 $ ./test AAA BBB

 and cat AAA or mount something on another terminal



#include stdio.h
#include stdlib.h
#include err.h
#include sys/epoll.h
#include sys/inotify.h
#include fcntl.h
#include sys/stat.h
#include fcntl.h

static int get_inotify(const char *filename)
{
int fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);

if (inotify_add_watch(fd, filename, IN_CLOSE_NOWRITE)  0)
err(EXIT_FAILURE, %s: add watch failed, filename);
return fd;
}

static void clean_inotify_buf(int fd)
{
char buf[BUFSIZ];
while (read(fd, buf, sizeof(buf))  0); /* non-blocking */
}

int main(int argc, char **argv)
{
int a, b, c;
int low_efd, high_efd;
struct epoll_event ev;

/* low epoll */
low_efd = epoll_create1(EPOLL_CLOEXEC);
if (low_efd  0)
err(EXIT_FAILURE, failed to create epoll);

ev.events = EPOLLPRI | EPOLLIN;
a = ev.data.fd = get_inotify(argv[1]);
if (epoll_ctl(low_efd, EPOLL_CTL_ADD, a, ev)  0)
err(EXIT_FAILURE, failed to add %s to low-epoll, argv[1]);

ev.events = EPOLLPRI | EPOLLIN;
b = ev.data.fd = get_inotify(argv[2]);
if (epoll_ctl(low_efd, EPOLL_CTL_ADD, b, ev)  0)
err(EXIT_FAILURE, failed to add %s to low-epoll, argv[2]);

ev.events = EPOLLPRI | EPOLLIN | EPOLLET;
c = ev.data.fd = open(/proc/self/mountinfo, O_RDONLY | O_CLOEXEC);
if (epoll_ctl(low_efd, EPOLL_CTL_ADD, c, ev)  0)
err(EXIT_FAILURE, failed to add mountinfo to low-epoll);

/* high epoll */
high_efd = epoll_create1(EPOLL_CLOEXEC);
if (high_efd  0)
err(EXIT_FAILURE, failed to create high-epoll);

ev.events = EPOLLPRI | EPOLLIN;
ev.data.fd = low_efd;
if (epoll_ctl(high_efd, EPOLL_CTL_ADD, low_efd, ev)  0)
err(EXIT_FAILURE, failed to add to high-epoll);

fprintf(stderr,   top=%d\n, high_efd);
fprintf(stderr, |\n);
fprintf(stderr,   low=%d\n, low_efd);
fprintf(stderr, /   |   \\\n);
fprintf(stderr,   A=%d  B=%d   C=%d\n\n, a, b, c);

do {
struct epoll_event events[1];
int n;

fprintf(stderr, Wainting for event...\n);
n = epoll_wait(high_efd, events, 1, -1);
if (n  0)
err(EXIT_FAILURE, high-epoll wait failed);
if (!n)
continue;

fprintf(stderr, *** has high event (fd=%d)\n, 
events[0].data.fd);
do {
n = epoll_wait(low_efd, events, 1, 0);
if (n  0)
err(EXIT_FAILURE, low-epoll wait failed);
else if (n) {
int fd = events[0].data.fd;
fprintf(stderr,*** has low event 
(fd=%d)\n, fd);
if (fd == a || fd == b)
clean_inotify_buf(fd);
} else
break;  /* no event */
} while (1);
clean_inotify_buf(a);
clean_inotify_buf(b);
} while (1);


}

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-17 Thread Karel Zak
On Fri, Dec 12, 2014 at 08:11:54PM +0100, Lennart Poettering wrote:
  I guess it's enough to add the 'fd' to systmed sd_event_add_io() and
  call mnt_table_parse_mtab() when a change is detected. (As already
  implemeted in the original Chris' patch.)
 
 Karel, if I got this right, then the new monitor stuff will only wrap
 inotify on utab, right? I think it would be useful if it would also
 abstract notifications via /proc/self/mountinfo in it. To make the
 interface easy for this and to be able to just hand out a single fd,
 this would mean creating an epoll fd inside the lib, then adding the
 inotify fd for utab to it, and then on top the EPOLLPRI watch on
 /proc/self/mountinfo.
 
 This way apps would get the full set of notifications via your
 library, without knowing what's going on underneath, and userspace
 notifications and kernel notifications would come the same way. 

OK, implemented (util-linux monitor branch on github).

But I have changed the userspace monitor to care about
/run/mount/utab.lock file. It's better than the original Chris idea
(monitor all /run/mount directory for utab rename changes).  This new
solution is without possible false positives. 

This is important details, because if you use epoll file descriptor 
in another epoll then you're correctly notified on the top-level epoll, 
but you lost information about which underneath file descriptor is active 
-- then it was impossible to verify the inotify IN_MOVED_TO utab event.

The another advantage is that the event is triggered really after utab
update (the update is covered by flock, and close() means unlock).

Now:

 your-epoll
 |
  library-epoll-FD
/\
 mountinfo-FD   utab.lock-inotify-FD


Note that after notification it's necessary to cleanup (drain) inotify
bufferes, so I have added mnt_monitor_event_cleanup().

Example:

  mn = mnt_new_monitor();
  mnt_monitor_enable_userspace(mn, TRUE);
  mnt_monitor_enable_kernel(mn, TRUE);

  fd = mnt_monitor_get_fd(mn);

  ...add 'fd' to your epoll...

  n = epoll_wait(your_efd, events, 1, -1);

  ...

  if (events[0].data.fd == fd) {
mnt_monitor_event_cleanup(mn);

printf(libmount notification\n);
...parse mount tables...
  }
  ...
  mnt_unref_monitor(mn);


 The API also provides mnt_monitor_wait() for users who don't want to
 own epoll, but this is irrelevant for systemd.

Karel

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-12 Thread Karel Zak
On Fri, Dec 12, 2014 at 08:11:54PM +0100, Lennart Poettering wrote:
 On Fri, 05.12.14 15:54, Karel Zak (k...@redhat.com) wrote:
  I guess it's enough to add the 'fd' to systmed sd_event_add_io() and
  call mnt_table_parse_mtab() when a change is detected. (As already
  implemeted in the original Chris' patch.)
 
 Karel, if I got this right, then the new monitor stuff will only wrap
 inotify on utab, right?

Right.

 I think it would be useful if it would also
 abstract notifications via /proc/self/mountinfo in it. To make the

I have had plan to add mnt_monitor_kernel_get_fd().

 interface easy for this and to be able to just hand out a single fd,
 this would mean creating an epoll fd inside the lib, then adding the
 inotify fd for utab to it, and then on top the EPOLLPRI watch on
 /proc/self/mountinfo.

 This way apps would get the full set of notifications via your
 library, without knowing what's going on underneath, and userspace
 notifications and kernel notifications would come the same way. 

I don't want provide only high-level abstraction, sometimes it's
useful for developers to have access to low-level things (for example
sometimes utab monitoring is unnecessary overkill). 

It's also possible that in future there will be more things to monitor
(mountinfo in another namespaces, FS specific things, ...etc).

Maybe the API should be extended to something like:

  mnt_monitor_enable_userspace(mn, TRUE);
  mnt_monitor_enable_kernel(mn, TRUE);

  fd = mnt_monitor_get_fd(mn);

where 'fd' is the top level file descriptor to monitor all enabled
things.

Hmm... OK, next week ;-)

Karel

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-10 Thread Karel Zak
On Wed, Dec 10, 2014 at 01:53:09AM +0100, Lennart Poettering wrote:
 On Tue, 09.12.14 12:30, Karel Zak (k...@redhat.com) wrote:
 
  On Mon, Dec 08, 2014 at 08:10:08PM +0100, Lennart Poettering wrote:
   Any idea when you intend to realease this new API in a release or even
   in a stable one?
  
   I'd like to have v2.26-rc1 this month.
  
 
 Hmm, OK, then I'll release 218 with the current direct inotify

or you can release it without this feature :-) 

It's all about mount -o _netdev executed from command line and it's 
unsupported by systemd for years -- I think we can wait one release.

Karel

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-09 Thread Karel Zak
On Mon, Dec 08, 2014 at 08:10:08PM +0100, Lennart Poettering wrote:
 Any idea when you intend to realease this new API in a release or even
 in a stable one?

 I'd like to have v2.26-rc1 this month.

Karel

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-05 Thread Karel Zak
On Fri, Dec 05, 2014 at 01:46:06AM +0100, Lennart Poettering wrote:
 With such an API you have the liberty to change later on what
 precisely you expose there. The fact that you watch a file would be
 entirely opaque, it could one day be a pipe or socket, or even an fd
 on some kernel fd, where you just tell us the kind of events you want
 the user code to listen on.
 
 This is how we wrap a lot of our own APIs, to allow integration into
 arbitrary main loops, without restricting us to decide how precisely
 the event is generated.
 
 Does this make sense?

Yep.

 Would love to get an API in place for this in libmount, because I
 don't really want to release systemd with the current code.

Implemented.

I have added struct libmnt_monitor to make this new interface easy to
extend and usable for more resources (I'll probably also add mountinfo
fd for findmnt(8), but this is irrelevant for systemd;-)

All you need is:

mn = mnt_new_monitor();
fd = mnt_monitor_userspace_get_fd(mn, NULL);/* utab monitor fd */

mnt_monitor_get_events(mn, fd, ev.events); /* EPOLLIN ... */

efd = epoll_create1(EPOLL_CLOEXEC);
epoll_ctl(efd, EPOLL_CTL_ADD, fd, ev);


n = epoll_wait(efd, events, 1, -1);
id (n == 1  mnt_monitor_is_changed(mn, fd) == 1)
printf(%s: change detected\n, mnt_monitor_get_filename(mn, 
fd));


mnt_unref_monitor(mn);
close(efd);


I guess it's enough to add the 'fd' to systmed sd_event_add_io() and
call mnt_table_parse_mtab() when a change is detected. (As already
implemeted in the original Chris' patch.)



usable example:

https://github.com/karelzak/util-linux/blob/master/libmount/src/monitor.c#L345


Karel

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-01 Thread Karel Zak
On Fri, Nov 28, 2014 at 09:27:43PM +0100, Lennart Poettering wrote:
 On Fri, 28.11.14 20:50, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:
 
  On Sun, Nov 23, 2014 at 08:33:41PM -0800, Chris Leech wrote:
   This adds auto detection for iSCSI and some FCoE drivers and treats
   mounts to file-systems on those devices as remote-fs.
   
   Signed-off-by: Chris Leech cle...@redhat.com
  No need for this.
  
  I now pushed patches 1-4 with some small changes here and there.
  Since libmount is not optional, I removed if from the version string.
  
  This patch I didn't push: this seems like something that would be better
  done through udev rules, by setting some tags. Then systemd could simply
  check for the presence of a tag on the device without having any
  special knowledge about iscsi and firends.
 
 Honestly, I am really not sure I like this patch.
 
 One one hand we now have a hard dep on libmount. Which I figure is
 mostly OK. However, what I find really weird about this is that even
 though libmount is supposed to abstract access to the utab away, it
 doesn't sufficiently: we still hardcode the utab path now so that we
 can watch it. I mean, either we use an abstracted interface or we
 don't. THis really smells to me as either libmount should provide some
 form of inotify iface to utab, or we should parse utab directly. If
 libmount is the only and official API for utab, then we should
 that. If the utab file however is API too, then we can well go ahead
 and parse it directly.

I'd like to keep the utab file private. The whole libmount API is
abstraction and completely hides the difference between original
/etc/mtab and new /run/mount/utab.

The original Chris' purpose for the patches has been _netdev, it
means to improve detection of dependence between filesystem and
network. I still believe that the right way is to check for network
block devices than rely on crazy _netdev userspace mount option.

Wouldn't be enough to use Chris' iSCSI and FCoE auto detection?

Or we can add udev rule to have NET_DEVBLK tag in udevdb, or maybe we
can ask kernel developers to add /sys/block/sdb/network (as we already
have removable in /sys).

Chris, why do you want both ways (utab and the auto detection)? 

IMHO it would be really nice to completely kill _netdev in systemd
universe ;-) It's legacy from shell init scripts.


Anyway, if you still want to read userspace mount options than I can
add something like:

 mnt_inotify_mtab_add_watch()
 mnt_inotify_mtab_rm_watch()
 mnt_inotify_mtab_changed()

to hide all the paths and private mtab/utab stuff.

 THe new code looks also buggy to me. For example, am I missing
 something or is nobody creating /run/mount? I mean, we need to make
 sure that it exists before we can install an inotify watch on it.

yep, it should be hidden within libmount

 Also, it leaves the cescape() calls in for what we read from libmount,
 which makes a lot of alarm bells ring in my head: doesn't libmount do
 that on its own?

sure, libmount encodes/decodes all when read/write the files.

Karel

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


Re: [systemd-devel] [PATCH v2 5/5] mount: auto-detect iSCSI and FCoE as requiring network

2014-12-01 Thread Karel Zak
On Mon, Dec 01, 2014 at 02:28:33PM +0100, Zbigniew Jędrzejewski-Szmek wrote:
  Wouldn't be enough to use Chris' iSCSI and FCoE auto detection?
 Please see previous discussion... Detecting network might not be trivial
 if the devices are layered and there's a network-requiring device somewhere
 lower in the stack.

 Good point. (It would be possible to analyze whole stack by slave/holders
 relations, but I agree it's too complex and probably too fragile.)

  Anyway, if you still want to read userspace mount options than I can
  add something like:
  
   mnt_inotify_mtab_add_watch()
   mnt_inotify_mtab_rm_watch()
   mnt_inotify_mtab_changed()
  
  to hide all the paths and private mtab/utab stuff.
 Maybe something more like what journal client code does here:
 
  mnt_mtab_get_fd() - epoll fd
  mnt_mtab_get_events() - EPOLLIN|EPOLLPRI
  mnt_mtab_process() - information what changed

 Hmm.. utab is optional and very often does not exist, and library
 uses rename(2) to do atomic update of the file. This is reason why
 Chris have used inotify for /run/mount directory (and Lennart asked
 for inotify API). I have doubts you can use epoll to monitor 
 directories, epoll is about I/O monitoring.

Karel

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


Re: [systemd-devel] [RFC 4/4] add remote-fs dependencies if needed after change

2014-11-19 Thread Karel Zak
On Thu, Nov 06, 2014 at 09:11:03PM -0800, Chris Leech wrote:
 It it not working for -o remount,_netdev.  But that looks like a
 libmount issue in that the ROOT field is not being set in utab on a
 remount, so if the initial mount did not require a utab entry then
 remount options never get merge in properly in mnt_table_parse_mtab

 Fixed in util-linux git tree. Thanks.

Karel

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


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-11-07 Thread Karel Zak
On Thu, Nov 06, 2014 at 09:10:51PM -0800, Chris Leech wrote:
   Not sure, maybe it's possible to detect this by scsi info in /sys.
 
 I took a look at what lsscsi is doing to guess at transport type.  iSCSI
 is kind of ugly, FCoE is really ugly, and for both of those there exists
 a variety of drivers with varying levels of dependence on the networking
 layer.  It would be nice to work on getting some of the more common
 works working automatically, but _netdev seems like a nice failsafe.

BTW, in lsblk(8) we have TRANS column (lsblk -S, function get_transport()) 
to report scsi transport type and it uses /sys, but I have no clue how 
reliable it's.

Karel

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


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-31 Thread Karel Zak
On Thu, Oct 30, 2014 at 03:04:59PM -0700, Chris Leech wrote:
 On Thu, Oct 30, 2014 at 12:10:16PM +0100, Karel Zak wrote:
  On Tue, Oct 28, 2014 at 02:29:35AM +0100, Lennart Poettering wrote:
   On Mon, 27.10.14 14:10, Chris Leech (cle...@redhat.com) wrote:
   
So for any mounts to remote block devices (unlike remote file system
protocols which are detected by the fs name), unless there is an fstab
entry at the time fstab-generator is run they get treated like local fs
mounts and connectivity to the storage target may be disrupted before
unmounting (possibly resulting in file system errors).

I'm currently at a loss for how to handle this, other than to claim that
if filesystems are going to be left mounted they should be added to
fstab and a daemon-reload is required.
   
   IIRC mount nowadays stores the full mount option string, including all
   the userspace-only options in /run. We could either read those
   directly from there in systemd, or we could make systemd make use of
   libmount to get that information.
   
  _netdev is information about device rather than about filesystem.
  Would be possible to have this info (this is iSCSI) in udev db? 
 
 Yes, the _netdev option is ugly.  For iSCSI specifically, we'd have to
 trace the block device back to the scsi_host, then match that up with an
 iscsi_host from the transport class.  Or come up with some change to
 make that process easier.  And it would need to work for dm/md device
 over the actually scsi device.

 It would be really better to have within systemd a generic function
 is_net_blkdev() than rely on external fragile configuration. I have
 doubts that anyone uses -o _netdev on command line when manually
 mounts filesystem.
  
 Not sure, maybe it's possible to detect this by scsi info in /sys.

Karel


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


Re: [systemd-devel] [PATCH v3] Bootchart: use /proc/pid/mountinfo for root bdev

2014-10-31 Thread Karel Zak
On Fri, Oct 31, 2014 at 07:51:59AM +0300, Timofey Titovets wrote:
 2014-10-31 3:06 GMT+03:00 Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl:
  On Thu, Oct 30, 2014 at 05:45:53PM +0300, Timofey Titovets wrote:
  Good time of day, list.
  I have try to fix Fixme in svg.c:
  /* FIXME: this works only in the simple case */
 
  By default function try to get only root=/dev/*
  I also attach patch. Thanks.
 
  v2:
Rewrited with use fstab_node_to_udev_node() and
  canonicalize_file_name() functions.
  v3:
Rewrited for parsing /proc/self/mountinfo
 
  Please test it, i'm can't test because i not have /proc/schedstat
  file (custom kernel)
 
  I use  0  for searching root device its correct?

  findmnt -o TARGET,SOURCE,ID

don't forget that mount IDs are sequential numbers and we usually don't mount 
the real root as the first thing (for example /sys, /proc, /dev are mounted 
more early in initrd).

  For test:
  [$]: grep  0  /proc/self/mountinfo
  No:
 
  13 1 179:53 / / rw,noatime shared:1 - ext4 /dev/root rw,data=ordered
 
  Why not check field 5 for /?
 
 To be honest - I don't know how write it prettily _
 read file with fscanf like:
 fscanf(fd, %s %s %s %s %s %s %s - %s %s %s\n, ...) //Looks ugly.
 
 Then, perhaps can i search 'shared:1 '  entry ?

somewhere in systemd code is mountinfo parser.. or see
https://github.com/karelzak/util-linux/blob/master/libmount/src/tab_parse.c#L124

it seems you also want to read:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/proc.txt#n1589


Karel

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


Re: [systemd-devel] [PATCH] manager: do not print anything while passwords are being queried

2014-10-30 Thread Karel Zak
On Tue, Oct 28, 2014 at 03:28:32PM +0100, Lennart Poettering wrote:
 On Tue, 28.10.14 15:00, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:
 
  On Mon, Oct 27, 2014 at 06:37:21PM +0100, Lennart Poettering wrote:
   On Sun, 26.10.14 05:37, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) 
   wrote:
   
https://bugs.freedesktop.org/show_bug.cgi?id=73942
   
   So in really old systemd versions I had a concept in place of never
   printing to the console if there was a controlling process on it. The
   kernel's concept of a controlling process we used as a somewhat
   natural synchronization on the tty. However, this functionality has
   pretty much been lost. 
   
   I am not entirely sure what happened between all the reworks there,
   but maybe we should just resurrect that scheme? Suppressing output on
   the console if there's a controlling process would not just
   automatically avoid mixing password queries with getty login prompts,
   but also all other cases where some process wants exclusive ownership
   of the tty.
   
   Using the controlling tty for this would be somewhat nice, as all
   users of the tty would just work with it. Another idea could be to use
   BSD locks on the /dev/console device node. Everybody with access on
   the tty could take one of the logs. We would even have R/W locks then,
   where the status output would just take a read lock, while things like
   gettys and the password stuff would take a full write lock.
  I don't get this r/w distinction. In either case access has to
  be exclusive.
 
 Well, so, on the console it is fine if five clients write messages at
 the same time (as long as they print full lines at a time). However,
 only one client should read fro it at the same time, as otherwise it's
 pretty much random which component will actually get the input.
 
 We can use the BSD LOCK_SH vs. LOCK_EX bits for this. LOCK_SH is for
 everything which wants to just print a status message, LOCK_EX is for
 everything which wants to also read input. The weird bit of course is
 that in this case the writers take shared locks and the readers
 exclusive locks, even though classic R/W locks are of course the other
 way round...
 
   I am slightly leaning towards the BSD lock solution I must say. In
   particular as it is compatible with the story we kinda want to push
   people using /dev/ttyS* towards, who really should use BSD locks too,
   instead of the awful LCK.. files...
 
 One question remains though: which part shall take the LOCK_EX locks?
 I figure this should be agetty. 
 
 Karel, can we convince you to take a LOCK_EX BSD file lock on the tty
 devices agetty opens? 

in agetty and sulogin we already have code to detect possible collisions with
plymouth (implemented by Werner, CC:). The plymounth uses exotic TIOCGLCKTRMIOS
and TIOCSLCKTRMIOS ioctls to lock the tty configuration.

Maybe we can use the same concept, it means lock by TIOCSLCKTRMIOS if we wait 
for user's response.

I have no strong opinion about the lock type (flock or the tty ioctls), but 
I'd like to use the same concept (locks) for all tty components (agetty, 
plymouth and systemd-ask-password) without exceptions.

Karel

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


Re: [systemd-devel] remote-fs ordering, iSCSI and _netdev

2014-10-30 Thread Karel Zak
On Tue, Oct 28, 2014 at 02:29:35AM +0100, Lennart Poettering wrote:
 On Mon, 27.10.14 14:10, Chris Leech (cle...@redhat.com) wrote:
 
  So for any mounts to remote block devices (unlike remote file system
  protocols which are detected by the fs name), unless there is an fstab
  entry at the time fstab-generator is run they get treated like local fs
  mounts and connectivity to the storage target may be disrupted before
  unmounting (possibly resulting in file system errors).
  
  I'm currently at a loss for how to handle this, other than to claim that
  if filesystems are going to be left mounted they should be added to
  fstab and a daemon-reload is required.
 
 IIRC mount nowadays stores the full mount option string, including all
 the userspace-only options in /run. We could either read those
 directly from there in systemd, or we could make systemd make use of
 libmount to get that information.
 
_netdev is information about device rather than about filesystem.
Would be possible to have this info (this is iSCSI) in udev db? 

You know, all userpsace mount options suck, it's always fragile to
maintain mount options in userspace (due to namespaces, ...)

 Karel, what are the details there? Would it be OK if we read the files
 in /run directly to augment whatever we got from /proc/self/mountinfo?

I'd like to keep /run/mount/utab as private libmount file. It would be
better to use mnt_table_parse_mtab() libmount function to get parsed
mountinfo + userspace mount options.

IMHO you can implement it as optional feature #ifdef HAVE_LIBMOUNT to
optionally use mnt_table_parse_mtab() from libmount rather than directly
parse /proc/self/mountinfo.

Karel

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


Re: [systemd-devel] [PATCH] swap: introduce Discard property

2014-10-24 Thread Karel Zak
On Fri, Oct 03, 2014 at 07:16:55AM +0200, Jan Synacek wrote:
 Karel Zak k...@redhat.com writes:
  Karel, any chance you can add a -o option to swapon?
 
   No problem, added to TODO. I'll implement it next week.

Implemented, it's in util-linux git tree, will be in v2.26.

 Would you please let me know when that patch makes it to the package in
 rawhide? I would then fix the code I wrote to support it. Thank you.

Probably in December.

Karel


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


[systemd-devel] [PATCH] fsck: re-enable fsck -l

2014-10-22 Thread Karel Zak
The -l (lock) has been temporary disabled due to conflict with
udev (https://bugs.freedesktop.org/show_bug.cgi?id=79576)

The problem is fixed since util-linux v2.25 (Jul 2014).
---
 README  |  3 ++-
 src/fsck/fsck.c | 13 -
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/README b/README
index e0edd41..8f7a96e 100644
--- a/README
+++ b/README
@@ -129,8 +129,9 @@ REQUIREMENTS:
 During runtime, you need the following additional
 dependencies:
 
-util-linux = v2.19 (requires fsck -l, agetty -s),
+util-linux = v2.19 required for agetty -s
   v2.21 required for tests in test/
+  v2.25 required for fsck -l
 dbus = 1.4.0 (strictly speaking optional, but recommended)
 sulogin (from util-linux = 2.22 or sysvinit-tools, optional but 
recommended,
  required for tests in test/)
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index dfe97bc..70a5918 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -320,16 +320,11 @@ int main(int argc, char *argv[]) {
 cmdline[i++] = -T;
 
 /*
- * Disable locking which conflict with udev's event
- * ownershipi, until util-linux moves the flock
- * synchronization file which prevents multiple fsck running
- * on the same rotationg media, from the disk device
- * node to a privately owned regular file.
- *
- * https://bugs.freedesktop.org/show_bug.cgi?id=79576#c5
- *
- * cmdline[i++] = -l;
+ * Since util-linux v2.25 fsck uses /run/fsck/diskname.lock files.
+ * The previous versions use flock for the device and conflict with
+ * udevd, see https://bugs.freedesktop.org/show_bug.cgi?id=79576#c5
  */
+cmdline[i++] = -l;
 
 if (!root_directory)
 cmdline[i++] = -M;
-- 
1.9.3

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


Re: [systemd-devel] [PATCH] swap: introduce Discard property

2014-10-02 Thread Karel Zak
On Thu, Oct 02, 2014 at 03:32:54PM +0200, Lennart Poettering wrote:
 On Thu, 25.09.14 09:54, Jan Synacek (jsyna...@redhat.com) wrote:
 
  Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl writes:
   On Wed, Sep 24, 2014 at 02:29:05PM +0200, Jan Synacek wrote:
   Process possible discard values from /etc/fstab.
   Hm, wouldn't it be enough to simply pass through the options like with
   mounts, using the Options= option? This might be less work and be more
   flexible.
  
   Zbyszek
  
  Swap options are special in that they're processed and used by the
  swapon(8) command. You cannot pass swapon -o options, as you can to
  ordinary mounts. And how many options for swapon, that at the same time
  can be specified in /etc/fstab, do we really care about? I'm not sure.
 
 But isn't this something we can fix in swapon?
 
 I mean, swapon has the code to parse /etc/fstab and its options column
 anyway, it shouldn't be too hard to extend it to also take the string
 from the command line as parameter to -o?
 
 I'd really prefer if we'd try to stay close to fstab on this one, and
 instead of introducing individual new switches for the various
 options, try to stay compatible with fstab's native syntax.
 
 Karel, any chance you can add a -o option to swapon?

 No problem, added to TODO. I'll implement it next week.

Karel

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


Re: [systemd-devel] [PATCH] swap: introduce Discard property

2014-10-01 Thread Karel Zak
On Mon, Sep 29, 2014 at 06:52:12PM +0200, Zbigniew Jędrzejewski-Szmek wrote:
 On Mon, Sep 29, 2014 at 08:35:04PM +0400, Andrei Borzenkov wrote:
  В Mon, 29 Sep 2014 17:16:25 +0200
  Zbigniew Jędrzejewski-Szmek zbys...@in.waw.pl пишет:
  
   
   The problem with reading but back discards settings remains.
   
  
  Seems like the most natural solution is to extend /proc/swaps. The only
  place where these flags are printed right now is in dmesg during swapon.

I have talked about this issue with Lukas (CC:) who is working on
discard stuff in kernel. I hope we will see any solution :-)

 Yeah, but how can you extend /proc/swaps in a backwards compatible way?
 Like many kernel interfaces, it was designed with no thought towards
 extensibility. A new file would have to be created (/proc/swapinfo?).

Frankly, the /proc concept is broken. It designed as human readable
kernel interface (e.g. cat /proc/mounts), but it's horrible as
interface to distribute information to userspace.

It's painful that kernel provides information by formatted files where
is necessary to care about backward compatibility. The better thing is
sysfs concept where is attribute (info) per file. It's easy to extend,
easy to parse (let's imagine /proc/swaps/sda1/{discard,priority,...}
files :)

Karel

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


[systemd-devel] [PATCH 2/2] bootchart: ask for --rel when failed to initialize graph start time

2014-07-31 Thread Karel Zak
We always read system uptime before log start time. So the uptime
should be always smaller number, except it includes system suspend
time. It seems better to ask for --rel and exit() than try to be
smart and try to recovery from this situation or generate huge
messy graphs.
---
 src/bootchart/bootchart.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index 909ef46..22c66ba 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -350,6 +350,14 @@ int main(int argc, char *argv[]) {
 
 log_uptime();
 
+if (graph_start  0.0) {
+fprintf(stderr,
+Failed to setup graph start time.\n\nThe system 
uptime 
+probably includes time that the system was suspended. 

+Use --rel to bypass this issue.\n);
+exit (EXIT_FAILURE);
+}
+
 has_procfs = access(/proc/vmstat, F_OK) == 0;
 
 LIST_HEAD_INIT(head);
-- 
1.9.3

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


[systemd-devel] [PATCH 1/2] bootchart: don't parse /proc/uptime, use CLOCK_BOOTTIME

2014-07-31 Thread Karel Zak
* systemd-bootchart always parses /proc/uptime, although the
  information is unnecessary when --rel specified

* use /proc/uptime is overkill, since Linux 2.6.39 we have
  clock_gettime(CLOCK_BOOTTIME, ...). The backend on kernel side is
  get_monotonic_boottime() in both cases.

* main() uses if (graph_start = 0.0) to detect that /proc is
  available.

  This is fragile solution as graph_start is always smaller than zero
  on all systems after suspend/resume (e.g. laptops), because in this
  case the system uptime includes suspend time and uptime is always
  greater number than monotonic time. For example right now difference
  between uptime and monotonic time is 37 hours on my laptop.

  Note that main() calls log_uptime() (to parse /proc/uptime) for each
  sample when it believes that /proc is not available. So on my laptop
  systemd-boochars spends all live with /proc/uptime parsing +
  nanosleep(), try

strace  /usr/lib/systemd/systemd-bootchart

  to see the never ending loop.

  This patch uses access(/proc/vmstat, F_OK) to detect procfs.
---
 man/systemd-bootchart.xml |  4 +++-
 src/bootchart/bootchart.c | 11 +++
 src/bootchart/store.c | 29 -
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/man/systemd-bootchart.xml b/man/systemd-bootchart.xml
index e19bbc1..150ca48 100644
--- a/man/systemd-bootchart.xml
+++ b/man/systemd-bootchart.xml
@@ -131,7 +131,9 @@
 not graph the time elapsed since boot
 and before systemd-bootchart was
 started, as it may result in extremely
-large graphs.  /para/listitem
+large graphs. The time elapsed since boot
+might also include any time that the system
+was suspended./para/listitem
 /varlistentry
 /variablelist
 /refsect1
diff --git a/src/bootchart/bootchart.c b/src/bootchart/bootchart.c
index cbfc28d..909ef46 100644
--- a/src/bootchart/bootchart.c
+++ b/src/bootchart/bootchart.c
@@ -310,6 +310,7 @@ int main(int argc, char *argv[]) {
 time_t t = 0;
 int r;
 struct rlimit rlim;
+bool has_procfs = false;
 
 parse_conf();
 
@@ -349,6 +350,8 @@ int main(int argc, char *argv[]) {
 
 log_uptime();
 
+has_procfs = access(/proc/vmstat, F_OK) == 0;
+
 LIST_HEAD_INIT(head);
 
 /* main program loop */
@@ -385,11 +388,11 @@ int main(int argc, char *argv[]) {
 parse_env_file(/usr/lib/os-release, NEWLINE, 
PRETTY_NAME, build, NULL);
 }
 
-/* wait for /proc to become available, discarding samples */
-if (graph_start = 0.0)
-log_uptime();
-else
+if (has_procfs)
 log_sample(samples, sampledata);
+else
+/* wait for /proc to become available, discarding 
samples */
+has_procfs = access(/proc/vmstat, F_OK) == 0;
 
 sample_stop = gettime_ns();
 
diff --git a/src/bootchart/store.c b/src/bootchart/store.c
index e071983..cedcba8 100644
--- a/src/bootchart/store.c
+++ b/src/bootchart/store.c
@@ -57,27 +57,22 @@ double gettime_ns(void) {
 return (n.tv_sec + (n.tv_nsec / 10.0));
 }
 
-void log_uptime(void) {
-_cleanup_fclose_ FILE *f = NULL;
-char str[32];
-double uptime;
-
-f = fopen(/proc/uptime, re);
-
-if (!f)
-return;
-if (!fscanf(f, %s %*s, str))
-return;
-
-uptime = strtod(str, NULL);
+static double gettime_up(void) {
+struct timespec n;
 
-log_start = gettime_ns();
+clock_gettime(CLOCK_BOOTTIME, n);
+return (n.tv_sec + (n.tv_nsec / 10.0));
+}
 
-/* start graph at kernel boot time */
+void log_uptime(void) {
 if (arg_relative)
-graph_start = log_start;
-else
+graph_start = log_start = gettime_ns();
+else {
+double uptime = gettime_up();
+
+log_start = gettime_ns();
 graph_start = log_start - uptime;
+}
 }
 
 static char *bufgetline(char *buf) {
-- 
1.9.3

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


Re: [systemd-devel] lastlog and friends

2014-07-30 Thread Karel Zak
On Tue, Jul 29, 2014 at 09:28:42PM +0200, Lennart Poettering wrote:
 On Tue, 29.07.14 14:43, Karel Zak (k...@redhat.com) wrote:
 
  
  
   systemd TODO:
  
  - Replace utmp, wtmp, btmp, and lastlog completely with journal
  
  
   Can someone elaborate and provide more details, ideas, .. ?
 
 Basically, we just want to have a nice tool that can dump data similar
 to lastlog or last to stdout, originating from the journal.

in util-linux 2.25 (f21, and backported to rhel6 and rhel7) we have
introduced lslogins. It's mostly motived by requests from classic
admis (RH customers) who after migration to Linux complains that all
unixes have logins command.

It's designed like lsblk(8), so it's easy to extend, and it's possible
add another sources for data. Now it reads info from libc
(getpwent()), utmp, wtmp, lastlog and also from journal to get last
user's messages.

$ sudo ./lslogins kzak
m
Username:   kzak
UID:1000
Gecos field:Karel Zak,Home Office,123   
Home directory: /home/kzak  
Shell:  /bin/bash   
No login:   no  
Password is locked: no  
Password not required:  no  
Login by password disabled: no  
Primary group:  kzak
GID:1000
Supplementary groups:   test,mock   
Supplementary group IDs:1001,988
Last login: Jul29/09:30 
Last terminal:  pts/5   
Last hostname:  localhost   
Failed login:   Jul29/18:22 
Failed login terminal:  :0  
Hushed: no  
Password expiration warn interval:  7   
Password changed:   2013-Jan16  
Maximum change time:9   
Running processes:  51  

Last logs:
Jul 30 09:35:01 gnome-session[1516]:and actually has type UTF8_STRING format 8 
n_items 0.
Jul 30 09:35:01 gnome-session[1516]:This is most likely an application bug, not 
a window manager bug.
Jul 30 09:35:01 gnome-session[1516]:The window has title=mutt 
class=terminology name=mutt


$ sudo ./lslogins --system-accs
UID USER   PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS
988 uuidd 001UUID generator helper 
daemon
989 geoclue   001User for geoclue
990 unbound   001Unbound DNS resolver
991 lightdm   001
992 nm-openconnect001NetworkManager user for 
OpenConnect
993 openvpn   001OpenVPN
994 radvd 001radvd user
995 pulse 001PulseAudio System Daemon
996 colord101User for colord
997 chrony101
998 saslauth  001Saslauthd user
999 polkitd   101User for polkitd

etc..

   The current lastlog is sparse file and it's difficult to use for backup 
   programs or integrity checkers, etc. So requests from users/customers
   are pretty common.
   
   The idea (from someone from RH) is to have very simple and tiny
   library that provides unified API for different backends (classic
   lastlog, systemd journal, etc.) to keep applications portable.
   Something like:
  
 https://github.com/marmolak/liblastlog2
  
   Frankly, I'd like to see something more than only lastlog, but also
   utmp, wtmp support.
 
 Honestly, this sounds like something awfully peripheral to deserve a
 library of its own. 

Yes, I have many doubts too... 

 Also, a library whose primary purpose is to be abstraction glue to
 support one backend that is supposed to be the backend of the future and
 one that is really something that should go away sounds like a bad
 idea. I mean, what would the benefit be?  Eventually people should just

The primary goal for the library was to replace the current ugly lastlog
file format with a better format.

Karel

-- 
 Karel Zak  k...@redhat.com
 http://karelzak.blogspot.com

[systemd-devel] lastlog and friends

2014-07-29 Thread Karel Zak


 systemd TODO:

- Replace utmp, wtmp, btmp, and lastlog completely with journal


 Can someone elaborate and provide more details, ideas, .. ?


 The current lastlog is sparse file and it's difficult to use for backup 
 programs or integrity checkers, etc. So requests from users/customers
 are pretty common.
 
 The idea (from someone from RH) is to have very simple and tiny
 library that provides unified API for different backends (classic
 lastlog, systemd journal, etc.) to keep applications portable.
 Something like:

   https://github.com/marmolak/liblastlog2

 Frankly, I'd like to see something more than only lastlog, but also
 utmp, wtmp support.
 
 Note that I'm not involved in the project, but as login(1), last(1),
 ...  maintainer I'd like to see a public discussion about this topic.


 Maybe all we need for things like lastlog and wtmp is journald and then 
 a few #ifdef in applications like login(1), who(1) or PAM. Maybe it
 would be better than add an extra abstraction layer (by any library).
 Not sure, too many question :-)


Karel

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


Re: [systemd-devel] lastlog and friends

2014-07-29 Thread Karel Zak
On Tue, Jul 29, 2014 at 02:51:37PM +0200, Reindl Harald wrote:
   Maybe all we need for things like lastlog and wtmp is journald and then 
   a few #ifdef in applications like login(1), who(1) or PAM. Maybe it
   would be better than add an extra abstraction layer (by any library).
   Not sure, too many question :-)
 
 please keep in mind that on servers Storage=volatile and forward
 to classic rsyslog is common and that won't change - so whatever
 you read from journal are only recent entries which won't survive
 a reboot

 That's why I'm asking, I guess that behind the TODO item is any idea
 which has to be implement in on journal side. I'd like to know the
 long-term goal to avoid some future misunderstanding/flames :-)

Karel

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


[systemd-devel] [PATCH] always check asprintf return code

2014-07-25 Thread Karel Zak
There is a small number of the places in sources where we don't check
asprintf() return code and assume that after error the function
returns NULL pointer via the first argument. That's wrong, after
error the content of pointer is undefined.
---
 src/core/unit-printf.c  |  8 +---
 src/cryptsetup/cryptsetup.c | 11 ---
 src/journal/coredump.c  |  5 ++---
 src/journal/journalctl.c| 16 +++-
 src/run/run.c   | 16 
 src/shared/install.c| 15 +--
 src/systemctl/systemctl.c   | 14 --
 src/tty-ask-password-agent/tty-ask-password-agent.c |  5 +++--
 8 files changed, 54 insertions(+), 36 deletions(-)

diff --git a/src/core/unit-printf.c b/src/core/unit-printf.c
index 5bd30f0..8ac2081 100644
--- a/src/core/unit-printf.c
+++ b/src/core/unit-printf.c
@@ -208,7 +208,9 @@ static int specifier_user_name(char specifier, void *data, 
void *userdata, char
 if (r  0)
 return -ENODATA;
 
-asprintf(printed, UID_FMT, uid);
+r = asprintf(printed, UID_FMT, uid);
+if (r  0)
+return -ENOMEM;
 }
 }
 
@@ -230,8 +232,8 @@ static int specifier_user_name(char specifier, void *data, 
void *userdata, char
 
 if (specifier == 'u')
 printed = strdup(username);
-else
-asprintf(printed, UID_FMT, uid);
+else (asprintf(printed, UID_FMT, uid)  0)
+return -ENOMEM;
 }
 
 if (!printed)
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index a67d85e..67dc88f 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -549,13 +549,18 @@ int main(int argc, char *argv[]) {
 description = NULL;
 }
 
+k = 0;
 if (mount_point  description)
-asprintf(name_buffer, %s (%s) on %s, description, 
argv[2], mount_point);
+k = asprintf(name_buffer, %s (%s) on %s, 
description, argv[2], mount_point);
 else if (mount_point)
-asprintf(name_buffer, %s on %s, argv[2], 
mount_point);
+k = asprintf(name_buffer, %s on %s, argv[2], 
mount_point);
 else if (description)
-asprintf(name_buffer, %s (%s), description, 
argv[2]);
+k = asprintf(name_buffer, %s (%s), description, 
argv[2]);
 
+if (k  0) {
+log_oom();
+goto finish;
+}
 name = name_buffer ? name_buffer : argv[2];
 
 k = crypt_init(cd, argv[3]);
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 182c2b1..9f28eed 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -591,9 +591,8 @@ int main(int argc, char* argv[]) {
 }
 
 if (sd_pid_get_owner_uid(pid, owner_uid) = 0) {
-asprintf(core_owner_uid, COREDUMP_OWNER_UID= UID_FMT, 
owner_uid);
-
-if (core_owner_uid)
+if (asprintf(core_owner_uid, COREDUMP_OWNER_UID= UID_FMT,
+ owner_uid)  0)
 IOVEC_SET_STRING(iovec[j++], core_owner_uid);
 }
 
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 7aedbf0..5a59a3a 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -746,11 +746,17 @@ static int add_matches(sd_journal *j, char **args) {
 }
 } else
 t = strappend(_EXE=, path);
-} else if (S_ISCHR(st.st_mode))
-asprintf(t, _KERNEL_DEVICE=c%u:%u, 
major(st.st_rdev), minor(st.st_rdev));
-else if (S_ISBLK(st.st_mode))
-asprintf(t, _KERNEL_DEVICE=b%u:%u, 
major(st.st_rdev), minor(st.st_rdev));
-else {
+} else if (S_ISCHR(st.st_mode)) {
+if (asprintf(t, _KERNEL_DEVICE=c%u:%u,
+ major(st.st_rdev),
+ minor(st.st_rdev))  0)
+return -ENOMEM;
+} else if (S_ISBLK(st.st_mode)) {
+if (asprintf(t, _KERNEL_DEVICE=b%u:%u,
+ major(st.st_rdev),
+

[systemd-devel] [PATCH 1/2] tools: add script to detect repeating words in docs

2014-07-23 Thread Karel Zak
 - all programlisting sections from input files are ignored
 - it's possible to white-list wanted repeats by KNOWN_REPEATS[] in the script
 - the script is based on checkmans.sh from util-linux project
 - it's integrated to build-sys, just type make check-repwords, for example:

$ make check-repwords
  GEN  check-repwords
warning: man/coredump.conf.xml has repeating words: on
warning: man/sd_bus_message_append_array.xml has repeating words: of
warning: man/systemctl.xml has repeating words: on
warning: man/systemd.journal-fields.xml has repeating words: with
warning: man/systemd-journal-remote.xml has repeating words: is
warning: man/sysusers.d.xml has repeating words: be
---
 Makefile.am |  7 
 tools/check-repwords.sh | 97 +
 2 files changed, 104 insertions(+)
 create mode 100755 tools/check-repwords.sh

diff --git a/Makefile.am b/Makefile.am
index 3fb3703..7ee0264 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5918,6 +5918,13 @@ check-includes: $(top_srcdir)/tools/check-includes.pl
 EXTRA_DIST += \
$(top_srcdir)/tools/check-includes.pl
 
+.PHONY: check-repwords
+check-repwords: $(top_srcdir)/tools/check-repwords.sh
+   $(AM_V_GEN) $(top_srcdir)/tools/check-repwords.sh man/*.xml
+
+EXTRA_DIST += \
+   $(top_srcdir)/tools/check-repwords.sh
+
 # Stupid test that everything purported to be exported really is
 define generate-sym-test
$(AM_V_at)$(MKDIR_P) $(dir $@)
diff --git a/tools/check-repwords.sh b/tools/check-repwords.sh
new file mode 100755
index 000..f2aa327
--- /dev/null
+++ b/tools/check-repwords.sh
@@ -0,0 +1,97 @@
+#!/bin/bash
+#
+# Check all files specified on command line for repeating words
+#
+# Copyright (C) 2014 Karel Zak k...@redhat.com
+# based on util-linux checkmans.sh from Sami Kerola kerol...@iki.fi
+#
+
+set -e # exit on errors
+set -o pipefail# exit if pipe writer fails
+set -u # disallow usage of unset variables
+set -C # disallow redirection file overwriting
+SCRIPT_INVOCATION_SHORT_NAME=$(basename ${0})
+trap 'echo ${SCRIPT_INVOCATION_SHORT_NAME}: exit on error; exit 1' ERR
+
+usage() {
+   echo Usage: ${0} [-vVh] file ...
+   echo  -v  verbose messaging
+   echo  -h  print this help and exit
+}
+
+VERBOSE='false'
+while getopts vh OPTIONS; do
+   case ${OPTIONS} in
+   v)
+   VERBOSE='true'
+   ;;
+   h)
+   usage
+   exit 0
+   ;;
+   *)
+   usage
+   exit 1
+   esac
+done
+
+shift $(( OPTIND - 1 ))
+
+declare -a REPEATS
+declare -A KNOWN_REPEATS
+
+### white list
+# Note that all text between programlisting /programlisting tags is 
ingored.
+#
+# For exmaple to ignore 'bar bar' in the file foo.xml define:
+# KNOWN_REPEATS[foo.xml]='bar'
+
+
+remove_repeats()
+{
+   set +u
+   for KN in ${KNOWN_REPEATS[${I##*/}]}; do
+   if [ ${KN} = ${REPEATS[$1]} ]; then
+   if $VERBOSE; then
+   echo info: ${I} ignore repeat: ${REPEATS[$1]}
+   fi
+   unset REPEATS[$1]
+   fi
+   done
+   set -u
+}
+
+COUNT_ERRORS=0
+
+for I in $*; do
+   I_ERR=0
+   if ${VERBOSE}; then
+   echo testing: ${I}
+   fi
+   REPEATS=( $( cat ${I} | col -b | \
+   sed  -e 's/\s\+/\n/g;
+/^$/d;
+/programlisting/,/\/programlisting/d' | \
+   awk 'BEGIN { p= } { if (0  length($0)) { if (p == $0) { 
print } } p = $0 }') )
+
+   if [ 0 -lt ${#REPEATS[@]} ]; then
+   ITER=${#REPEATS[@]}
+   while [ -1 -lt ${ITER} ]; do
+   remove_repeats ${ITER}
+   # The 'let' may cause exit on error.
+   # When ITER == 0 - let returns 1, bash bug?
+   let ITER=${ITER}-1 || true
+   done
+   if [ 0 -lt ${#REPEATS[@]} ]; then
+   echo warning: ${I} has repeating words: ${REPEATS[@]}
+   fi
+   fi
+
+   let COUNT_ERRORS=$COUNT_ERRORS+$I_ERR || true
+done
+
+if [ ${COUNT_ERRORS} -ne 0 ]; then
+   exit 1
+fi
+
+exit 0
-- 
1.9.3

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


Re: [systemd-devel] [PATCH] rules: add by-parttypeuuid rule for GPT labeled partitions

2014-05-13 Thread Karel Zak
On Mon, May 12, 2014 at 05:18:56PM +0200, Kay Sievers wrote:
  I just looked up libudev and it looks like there is even a pyudev wrapper,
  so that could indeed work better.  I take it that queries via
  udev_enumerate for (say) ID_PART_ENTRY_TYPE=x are efficient?
 
 Sure, filter for block devices and this or other GPT properties. The
 libudev API will just find the devices is /sys and read the database
 files in tmpfs /run and, it will not talk to any devices, so it should
 perform pretty well.

 and on command line lsblk(8) reads the info from udev db, so you can
 use:

 $ lsblk -o+PARTTYPE
 NAME   MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT PARTTYPE
 sda  8:00 149.1G  0 disk
 ├─sda1   8:10  1000M  0 part  /boot  
c12a7328-f81f-11d2-ba4b-00a0c93ec93b
 ├─sda2   8:20 2G  0 part 
ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
 ├─sda3   8:30   9.7G  0 part  [SWAP] 
0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
 ├─sda4   8:40  34.2G  0 part  /  
ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
 ├─sda5   8:50  63.2G  0 part  /home  
ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
 └─sda6   8:60  39.1G  0 part 
ebd0a0a2-b9e5-4433-87c0-68b6b72699c7


(well, this is from git tree, will be in v2.25 :-)

Karel

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


Re: [systemd-devel] [PATCH] fstab-generator: local-fs.target waits for nofail mounts

2014-04-09 Thread Karel Zak
On Fri, Apr 04, 2014 at 05:30:03PM -0400, Vivek Goyal wrote:
 What happens if nofail is specified and device is present and there
 are file system errors. Will fsck continue with boot or drop user into
 a shell during boot and force to fix file system failures?

fsck cares about nofail option only if the device does not exist --
it's evaluated before FS check. 

Note that fsck(8) itself does not check filesystems, and fsck.type 
helpers does not have a clue about nofail at all.

Karel

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


[systemd-devel] [PATCH 1/2] build-sys: move python helpers to tools directory

2014-02-10 Thread Karel Zak
Note that make-man-rules.py is missing in EXTRA_DIST=, this patch
fixes this mistake too.
---
 Makefile.am   |  13 +-
 make-directive-index.py   | 320 --
 make-man-index.py | 136 --
 make-man-rules.py | 113 ---
 tools/make-directive-index.py | 320 ++
 tools/make-man-index.py   | 136 ++
 tools/make-man-rules.py   | 113 +++
 tools/xml_helper.py   |  41 ++
 xml_helper.py |  41 --
 9 files changed, 617 insertions(+), 616 deletions(-)
 delete mode 100755 make-directive-index.py
 delete mode 100755 make-man-index.py
 delete mode 100644 make-man-rules.py
 create mode 100755 tools/make-directive-index.py
 create mode 100755 tools/make-man-index.py
 create mode 100644 tools/make-man-rules.py
 create mode 100644 tools/xml_helper.py
 delete mode 100644 xml_helper.py

diff --git a/Makefile.am b/Makefile.am
index 4f5e036..e3c1145 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -610,16 +610,16 @@ XML_GLOB = $(wildcard $(top_srcdir)/man/*.xml 
$(top_builddir)/man/*.xml)
 NON_INDEX_XML_FILES = $(filter-out man/systemd.index.xml,$(XML_FILES))
 SOURCE_XML_FILES = $(filter-out 
man/systemd.directives.xml,$(NON_INDEX_XML_FILES))
 
-update-man-list: make-man-rules.py $(XML_GLOB)
+update-man-list: $(top_srcdir)/tools/make-man-rules.py $(XML_GLOB)
$(AM_V_GEN)$(PYTHON) $^  $(top_srcdir)/Makefile-man.tmp
$(AM_V_at)mv $(top_srcdir)/Makefile-man.tmp 
$(top_srcdir)/Makefile-man.am
@echo Makefile-man.am has been regenerated
 
-man/systemd.index.xml: make-man-index.py $(NON_INDEX_XML_FILES)
+man/systemd.index.xml: $(top_srcdir)/tools/make-man-index.py 
$(NON_INDEX_XML_FILES)
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(PYTHON) $ $@ $(filter-out $,$^)
 
-man/systemd.directives.xml: make-directive-index.py $(SOURCE_XML_FILES)
+man/systemd.directives.xml: $(top_srcdir)/tools/make-directive-index.py 
$(SOURCE_XML_FILES)
$(AM_V_at)$(MKDIR_P) $(dir $@)
$(AM_V_GEN)$(PYTHON) $ $@ $(filter-out $,$^)
 
@@ -641,9 +641,10 @@ EXTRA_DIST += \
$(HTML_FILES) \
$(HTML_ALIAS) \
$(man_MANS) \
-   make-man-index.py \
-   make-directive-index.py \
-   xml_helper.py
+   tools/make-man-index.py \
+   tools/make-directive-index.py \
+   tools/make-man-rules.py \
+   tools/xml_helper.py
 
 # 
--
 noinst_LTLIBRARIES += \
diff --git a/make-directive-index.py b/make-directive-index.py
deleted file mode 100755
index 2ff304f..000
--- a/make-directive-index.py
+++ /dev/null
@@ -1,320 +0,0 @@
-#  -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
-#
-#  This file is part of systemd.
-#
-#  Copyright 2012-2013 Zbigniew J??drzejewski-Szmek
-#
-#  systemd is free software; you can redistribute it and/or modify it
-#  under the terms of the GNU Lesser General Public License as published by
-#  the Free Software Foundation; either version 2.1 of the License, or
-#  (at your option) any later version.
-#
-#  systemd is distributed in the hope that it will be useful, but
-#  WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-#  Lesser General Public License for more details.
-#
-#  You should have received a copy of the GNU Lesser General Public License
-#  along with systemd; If not, see http://www.gnu.org/licenses/.
-
-import sys
-import collections
-import re
-from xml_helper import *
-from copy import deepcopy
-
-TEMPLATE = '''\
-refentry id=systemd.directives conditional=HAVE_PYTHON
-
-refentryinfo
-titlesystemd.directives/title
-productnamesystemd/productname
-
-authorgroup
-author
-contribDeveloper/contrib
-firstnameZbigniew/firstname
-surnameJ??drzejewski-Szmek/surname
-emailzbys...@in.waw.pl/email
-/author
-/authorgroup
-/refentryinfo
-
-refmeta
-refentrytitlesystemd.directives/refentrytitle
-manvolnum7/manvolnum
-/refmeta
-
-refnamediv
-refnamesystemd.directives/refname
-refpurposeIndex of configuration directives/refpurpose
-/refnamediv
-
-refsect1
-titleUnit directives/title
-
-paraDirectives for configuring units, used in unit
-files./para
-
-variablelist id='unit-directives' /
-/refsect1
-
-refsect1
-titleOptions on the kernel command line/title
-
-paraKernel boot options for configuring the behaviour of the
-   

[systemd-devel] [PATCH 2/2] build-sys: add check-includes build target and script

2014-02-10 Thread Karel Zak
---
 Makefile.am |  8 
 tools/check-includes.pl | 23 +++
 2 files changed, 31 insertions(+)
 create mode 100755 tools/check-includes.pl

diff --git a/Makefile.am b/Makefile.am
index e3c1145..09a827b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4937,6 +4937,14 @@ CLEANFILES += \
 check-api-unused: defined undefined exported
( cat exported undefined ) | sort -u  | diff -u - defined | grep ^+ | 
grep -v ^+++ | cut -c2-
 
+.PHONY: check-includes
+check-includes: $(top_srcdir)/tools/check-includes.pl
+   $(AM_V_GEN) find * -name '*.[hcS]' -type f -print | sort -u \
+   | xargs $(top_srcdir)/tools/check-includes.pl
+
+EXTRA_DIST += \
+   $(top_srcdir)/tools/check-includes.pl
+
 # Stupid test that everything purported to be exported really is
 
 define generate-sym-test
diff --git a/tools/check-includes.pl b/tools/check-includes.pl
new file mode 100755
index 000..bf23929
--- /dev/null
+++ b/tools/check-includes.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+#
+# checkincludes: Find files included more than once in (other) files.
+# Copyright abandoned, 2000, Niels Kristian Bech Jensen n...@image.dk.
+
+foreach $file (@ARGV) {
+   open(FILE, $file) or die Cannot open $file: $!.\n;
+
+   my %includedfiles = ();
+
+   while (FILE) {
+   if (m/^\s*#\s*include\s*[](\S*)[]/o) {
+   ++$includedfiles{$1};
+   }
+   }
+   foreach $filename (keys %includedfiles) {
+   if ($includedfiles{$filename}  1) {
+   print $file: $filename is included more than once.\n;
+   }
+   }
+
+   close(FILE);
+}
-- 
1.8.5.3

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


Re: [systemd-devel] remove duplicate includes

2014-01-21 Thread Karel Zak
On Wed, Nov 20, 2013 at 10:54:15PM +0100, Lennart Poettering wrote:
 On Tue, 19.11.13 02:33, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:
 
  
  On Mon, Nov 18, 2013 at 02:48:14PM +0100, Karel Zak wrote:
   A few trivial patches... the duplications found by
   https://raw.github.com/karelzak/util-linux/master/tools/checkincludes.pl
  Wow. Applied in one big fell swoop.
 
 I'd be happy to also apply a patch that adds that tool to our tree so
 that we can easily rerun it again...

 Do you want the script in the top level directory? .. in util-linux
 we usually use tools/ subdirectory for such things.
 
 It seems that in systemd source tree it would be possible to move
 things like make-directive-index.py, make-man-index.py,
 make-man-rules.py and xml_helper.py to the subdirectory too.
 
Karel

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


Re: [systemd-devel] Hard-coded /bin/mount in systemd

2013-11-27 Thread Karel Zak
On Wed, Nov 27, 2013 at 04:41:27PM +0100, Kay Sievers wrote:
 We support exactly two configurations:
 the (conceptually pointless and confusing) legacy split-/user with
 /bin/mount, and the one proper single /usr, where /bin must be a
 symlink to /usr/bin.

BTW, it's not about systemd only. The same is valid for 
/sbin/{mount,fsck,mkfs}.fs helpers, agetty where we call /bin/login,
etc. etc.

 Nothing else is interesting to support, matters or makes sense in any
 way. In both supported configurations /bin/mount works just fine.
 
 In the very long run, we will get rid of the split-/usr support and at
 that point just hard-code things like /usr/bin/mount; there is no need
 really for a configuration switch here.

Yep.

Karel

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


[systemd-devel] remove duplicate includes

2013-11-18 Thread Karel Zak
A few trivial patches... the duplications found by
https://raw.github.com/karelzak/util-linux/master/tools/checkincludes.pl

Karel

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


[systemd-devel] [PATCH 05/10] nss-myhostname: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/nss-myhostname/netlink.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/nss-myhostname/netlink.c b/src/nss-myhostname/netlink.c
index 47a41f5..d61ecdf 100644
--- a/src/nss-myhostname/netlink.c
+++ b/src/nss-myhostname/netlink.c
@@ -31,7 +31,6 @@
 #include limits.h
 #include arpa/inet.h
 #include unistd.h
-#include inttypes.h
 #include stdlib.h
 
 #include ifconf.h
-- 
1.8.3.1

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


[systemd-devel] [PATCH 03/10] sysctl: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/sysctl/sysctl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 67c7872..449e0ca 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -30,7 +30,6 @@
 #include log.h
 #include strv.h
 #include util.h
-#include strv.h
 #include hashmap.h
 #include path-util.h
 #include conf-files.h
-- 
1.8.3.1

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


[systemd-devel] [PATCH 10/10] backlight: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/backlight/backlight.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 9ec29f7..bf76703 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -24,7 +24,6 @@
 #include fileio.h
 #include libudev.h
 #include udev-util.h
-#include util.h
 
 static struct udev_device *find_pci_or_platform_parent(struct udev_device 
*device) {
 struct udev_device *parent;
-- 
1.8.3.1

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


[systemd-devel] [PATCH 04/10] shared: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/shared/label.c | 1 -
 src/shared/util.c  | 1 -
 2 files changed, 2 deletions(-)

diff --git a/src/shared/label.c b/src/shared/label.c
index 5c7cc1c..4a26ba9 100644
--- a/src/shared/label.c
+++ b/src/shared/label.c
@@ -20,7 +20,6 @@
 ***/
 
 #include errno.h
-#include sys/stat.h
 #include unistd.h
 #include malloc.h
 #include sys/socket.h
diff --git a/src/shared/util.c b/src/shared/util.c
index b77d010..deb74c4 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -41,7 +41,6 @@
 #include stdarg.h
 #include sys/inotify.h
 #include sys/poll.h
-#include libgen.h
 #include ctype.h
 #include sys/prctl.h
 #include sys/utsname.h
-- 
1.8.3.1

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


[systemd-devel] [PATCH 01/10] udev: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/udev/mtd_probe/probe_smartmedia.c | 1 -
 src/udev/v4l_id/v4l_id.c  | 4 
 2 files changed, 5 deletions(-)

diff --git a/src/udev/mtd_probe/probe_smartmedia.c 
b/src/udev/mtd_probe/probe_smartmedia.c
index feadb50..a007cce 100644
--- a/src/udev/mtd_probe/probe_smartmedia.c
+++ b/src/udev/mtd_probe/probe_smartmedia.c
@@ -26,7 +26,6 @@
 #include fcntl.h
 #include unistd.h
 #include stdint.h
-#include stdlib.h
 #include mtd_probe.h
 
 static const uint8_t cis_signature[] = {
diff --git a/src/udev/v4l_id/v4l_id.c b/src/udev/v4l_id/v4l_id.c
index 8dcb645..d5463b2 100644
--- a/src/udev/v4l_id/v4l_id.c
+++ b/src/udev/v4l_id/v4l_id.c
@@ -18,11 +18,7 @@
 #include string.h
 #include ctype.h
 #include stdlib.h
-#include stdio.h
-#include stdlib.h
-#include string.h
 #include unistd.h
-#include errno.h
 #include fcntl.h
 #include getopt.h
 #include sys/types.h
-- 
1.8.3.1

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


[systemd-devel] [PATCH 02/10] systemctl: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/systemctl/systemctl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 737cd67..54479db 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -65,7 +65,6 @@
 #include spawn-polkit-agent.h
 #include install.h
 #include logs-show.h
-#include path-util.h
 #include socket-util.h
 #include fileio.h
 #include bus-util.h
-- 
1.8.3.1

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


[systemd-devel] [PATCH 09/10] core: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/core/shutdown.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index b5eb8b1..bcf2eec 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -24,7 +24,6 @@
 #include sys/reboot.h
 #include linux/reboot.h
 #include sys/wait.h
-#include sys/types.h
 #include sys/stat.h
 #include sys/mount.h
 #include sys/syscall.h
-- 
1.8.3.1

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


[systemd-devel] [PATCH 07/10] libudev: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/libudev/libudev-device-private.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/libudev/libudev-device-private.c 
b/src/libudev/libudev-device-private.c
index cba08d2..cb4947f 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -24,7 +24,6 @@
 #include stdbool.h
 #include unistd.h
 #include fcntl.h
-#include string.h
 #include sys/stat.h
 
 #include libudev.h
-- 
1.8.3.1

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


[systemd-devel] [PATCH 08/10] journal: remove duplicate includes

2013-11-18 Thread Karel Zak
---
 src/journal/journalctl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index a509104..c44be74 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -48,7 +48,6 @@
 #include fileio.h
 #include build.h
 #include pager.h
-#include logs-show.h
 #include strv.h
 #include journal-internal.h
 #include journal-def.h
-- 
1.8.3.1

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


Re: [systemd-devel] is mounting subvolumes with a read-only root subvolume allowed?

2013-11-14 Thread Karel Zak
On Fri, Nov 15, 2013 at 12:32:10AM +0100, Zbigniew Jędrzejewski-Szmek wrote:
 Hi,
 I have a box with / and /home being subvolumes from the same btrfs filesystem.
 
 /etc/fstab:
 UUID=c0686...  /  btrfs subvol=root,x-systemd.device-timeout=0 1 1
 UUID=c0686...  /home  btrfs subvol=home,x-systemd.device-timeout=0 1 1
 ...
 
 / is initially mounted readonly by the initramfs, and then after switching
 to the real system, /home is attempted to be mounted in parallel with /
 being remounted rw. If remounting rw happens first, boot proceeds. If
 mounting /home is attempted to realy, it fails.
 
 $ /bin/mount /home
 mount: /dev/mapper/luks-765... is already mounted or /home busy
/dev/mapper/luks-765... is already mounted on /
 $ /bin/mount -o remount,rw /
 $ /bin/mount /home
 $
 
 So, is this expected that the other subvolume must be mounted rw?

 This is known and pretty stupid issue:
 http://www.spinics.net/lists/linux-btrfs/msg25502.html

 ... but it seems that btrfs guys are fine with this feature.

Karel

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


Re: [systemd-devel] [PATCH] SMACK: assign * label to /tmp when using SMACK.

2013-11-12 Thread Karel Zak
On Tue, Nov 12, 2013 at 03:16:17PM +0100, Karel Zak wrote:
 On Fri, Nov 01, 2013 at 09:19:27AM -0700, Kok, Auke-jan H wrote:
  On Fri, Nov 1, 2013 at 12:57 AM, Karel Zak k...@redhat.com wrote:
   On Thu, Oct 31, 2013 at 01:20:18PM -0700, Kok, Auke-jan H wrote:
 BTW, for SELinux we remove selinux specific mount options in
 userspace (in mount(8)) if the kernel does not support selinux.
   
 It help us to make command line or fstab setting independent on the
 current kernel features.
   
 Maybe we can use the same for SMACK, is there any way how to
 determine that the system uses SMACK? (/proc/something or so...).
 -- for selinux we check for /sys/fs/selinux or /selinux.
  
   Ohh yes that would be so nice.
  
   You've got your choice for detecting smack, but I like
   stat(/sys/fs/smackfs) == 0 the best so far. You can parse
   /proc/filesystems for smackfs too, but that's obviously more complex.
   This method works with 3.9 and above, as that's when we made sysfs
   hold the mount point for smackfs.
  
   I assume we're talking about this code here:
  
   https://github.com/karelzak/util-linux/blob/master/libmount/src/context_mount.c#L181
  
Yes, the se_rem code (with SELinux is it tricky, because old
kernels don't support selinux options remount, options duplication is
problem etc.. I guess that for SMACK it will be less complex :-).
  
Do you have somewhere list of the smack mount options? I'll prepare
the patch.
  
  Yes, the authoritative documentation is the code:
  
  https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/security/smack/smack.h#n143
 
 
  OK, implemented:
  
 https://github.com/karelzak/util-linux/commit/b8095d25bae0588dfce8a62169f6db5496cf45c5

 Oh, there is a typo in the /sys/fs/smackfs path, fixed. Sorry.

Karel

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


Re: [systemd-devel] [PATCH] SMACK: assign * label to /tmp when using SMACK.

2013-11-01 Thread Karel Zak
On Thu, Oct 31, 2013 at 01:20:18PM -0700, Kok, Auke-jan H wrote:
   BTW, for SELinux we remove selinux specific mount options in
   userspace (in mount(8)) if the kernel does not support selinux.
 
   It help us to make command line or fstab setting independent on the
   current kernel features.
 
   Maybe we can use the same for SMACK, is there any way how to
   determine that the system uses SMACK? (/proc/something or so...).
   -- for selinux we check for /sys/fs/selinux or /selinux.
 
 Ohh yes that would be so nice.
 
 You've got your choice for detecting smack, but I like
 stat(/sys/fs/smackfs) == 0 the best so far. You can parse
 /proc/filesystems for smackfs too, but that's obviously more complex.
 This method works with 3.9 and above, as that's when we made sysfs
 hold the mount point for smackfs.
 
 I assume we're talking about this code here:
 
 https://github.com/karelzak/util-linux/blob/master/libmount/src/context_mount.c#L181

 Yes, the se_rem code (with SELinux is it tricky, because old
 kernels don't support selinux options remount, options duplication is
 problem etc.. I guess that for SMACK it will be less complex :-). 
 
 Do you have somewhere list of the smack mount options? I'll prepare
 the patch.
 
 BTW, the options should be also documented in mount.8 man page :-)

Karel


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


Re: [systemd-devel] [PATCH] SMACK: assign * label to /tmp when using SMACK.

2013-10-31 Thread Karel Zak
On Tue, Oct 29, 2013 at 01:27:07PM +0100, Lennart Poettering wrote:
 On Tue, 29.10.13 16:02, WaLyong Cho (walyong@samsung.com) wrote:
 
   Hmm, here's an idea: there has been a long standig feature request to
   add a configurable boolean to mount unit files that controls
   /bin/mount's -s switch. Let's say we call it
   SloppyOptions=yes/no, or so. Then, we could set this for this unit
   file and apply the rest of the patch and things should work, and where
   they don't we can easily reassign to the kernel to respect the -s flag
   properly.
  
   Doing a patch that allows -s to be controlled should be fairly easy,
   would be happy to merge a patch for that!
   ahhh I hadn't even seen -s in /bin/mount yet, so I can see this
   helping out a lot.
  
   I'd be okay with a solution like that, it would certainly simplify
   things a lot, but we need to be careful not to overload mount options
   with all sorts of nonstandard options - it will make problems harder
   to debug and for some of these security enabled systems we will most
   likely want to actually _not_ use -s. After all, we want to make sure
   we're actually booting with properly setup Smack options e.g. a typo
   in 'nodev,nosuid,nexec' could be disastrous. (typo deliberate).
  
   Auke
  
  I am not sure we can use the -s option. First I tried that in my fedora
  machine.
  
  # mount -t tmpfs -s -o mode=1777,strictatime,smackfsroot=* tmpfs /test
  mount: wrong fs type, bad option, bad superblock on tmpfs,
 missing codepage or helper program, or other error
  
 In some cases useful info is found in syslog - try
 dmesg | tail or so.
  
  # dmesg
  [  752.222803] tmpfs: Bad mount option smackfsroot
 
 Hmm, it appears that libmount/util-linux actually appears to ignore the
 sloppy mount option entirely. Adding kzak to CC. Karel, what's going on
 here? Does -s have any use at all? 

 The -s is supported by mount.nfs only. It has never been implemented
 for anything else. There is no kernel mount flag for this option.

 Can we make it work for us?

 Add MS_SLOPPY to kernel :-)


Karel

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


Re: [systemd-devel] [PATCH] SMACK: assign * label to /tmp when using SMACK.

2013-10-31 Thread Karel Zak
On Tue, Oct 29, 2013 at 01:27:07PM +0100, Lennart Poettering wrote:
 On Tue, 29.10.13 16:02, WaLyong Cho (walyong@samsung.com) wrote:
 
   Hmm, here's an idea: there has been a long standig feature request to
   add a configurable boolean to mount unit files that controls
   /bin/mount's -s switch. Let's say we call it
   SloppyOptions=yes/no, or so. Then, we could set this for this unit
   file and apply the rest of the patch and things should work, and where
   they don't we can easily reassign to the kernel to respect the -s flag
   properly.
  
   Doing a patch that allows -s to be controlled should be fairly easy,
   would be happy to merge a patch for that!
   ahhh I hadn't even seen -s in /bin/mount yet, so I can see this
   helping out a lot.
  
   I'd be okay with a solution like that, it would certainly simplify
   things a lot, but we need to be careful not to overload mount options
   with all sorts of nonstandard options - it will make problems harder
   to debug and for some of these security enabled systems we will most
   likely want to actually _not_ use -s. After all, we want to make sure
   we're actually booting with properly setup Smack options e.g. a typo
   in 'nodev,nosuid,nexec' could be disastrous. (typo deliberate).
  
   Auke
  
  I am not sure we can use the -s option. First I tried that in my fedora
  machine.
  
  # mount -t tmpfs -s -o mode=1777,strictatime,smackfsroot=* tmpfs /test


 BTW, for SELinux we remove selinux specific mount options in
 userspace (in mount(8)) if the kernel does not support selinux.

 It help us to make command line or fstab setting independent on the
 current kernel features.
 
 Maybe we can use the same for SMACK, is there any way how to
 determine that the system uses SMACK? (/proc/something or so...).
 -- for selinux we check for /sys/fs/selinux or /selinux.

 It would be easer than play nasty games with -s.

Karel

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


Re: [systemd-devel] [PATCH] make fsck fix mode a kernel command line option

2013-10-07 Thread Karel Zak
On Tue, Sep 10, 2013 at 04:55:19PM +0100, Colin Guthrie wrote:
 'Twas brillig, and Tom Gundersen at 10/09/13 13:45 did gyre and gimble:
  On Tue, Sep 10, 2013 at 2:31 PM, Jan Engelhardt jeng...@inai.de wrote:
 
  On Tuesday 2013-09-10 13:52, Dave Reisner wrote:
  the FUSE program knows
  nothing about the systemd-specific nofail or x-*.

 We have nofail since 2007 in mount(8) (by patch from Suse:-),
 since 2009 in fsck(8) and since 2010 in swapon(8).

 Note that mount(8) does not strip nofail when call mount.type
 helpers.

  This should only be a problem if you directly use the FUSE mount helper.
  If you instead invoke mount with -t fuse.$fusetype, then this isn't an
  issue. mount(8) *does* understand these options and nicely strips them
  out before invoking the specific mount helper for you.
 
  If it were so that mount stripped them, I would not be reporting it,
  would I. Or maybe that is a feature of a future util-linux?
 
  # grep /mnt /etc/fstab
  /srv/www /mnt fuse.bindfs 
  auto,nofail,group=company,perms=g+rw,create-for-group=www,create-with-perms=g+r:go-w
   0 0
  # mount /mnt
  fuse: unknown option `nofail'
  # rpm -q util-linux
  util-linux-2.21.2-10.2.1.x86_64

 hmm... we have 2.24-rc1 now ;-)

  Hm, I thought that feature was part of 2.21... or perhaps your distro
  is still not using the libmount based mount?

 BTW, v2.24 is probably last release with old deprecated non-libmount
 based mount(8).

 I suspect this issue (libmount based mount) as this is what hit us a
 while back (I think our problem there was not using libmount in
 nfs-utils rather than mount itself, but my memory is fuzzy and I could
 be getting this wrong)

 It's really really bad idea to use old deprecated mount(8) on system
 with systemd. The old mount code is completely frozen in last years, 
 no new features at all...

Karel

-- 
 Karel Zak  k...@redhat.com
 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 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  k...@redhat.com
 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 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  k...@redhat.com
 http://karelzak.blogspot.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] units: cleanup agetty command line

2013-06-04 Thread Karel Zak
On Mon, Jun 03, 2013 at 06:00:45PM +0100, Colin Guthrie wrote:
 'Twas brillig, and Karel Zak at 03/06/13 13:28 did gyre and gimble:
   * term type is optional (default is 'linux' for virtual terminals
 and 'vt102' for serial lines)
 
 It may no longer matter (especially if the fix mentioned by Michael in
 comment 1 of the bug quoted below is now merged) but FYI the linux
 term type was specified explicitly due to agetty not respecting TERM env
 var:

 agetty has been never designed in this way
 
 commit 2161de72c517d34d1ceb9b4c1a300f0b54ce5a9c
 Author: Michal Schmidt mschm...@redhat.com
 Date:   Mon Oct 29 21:59:34 2012 +0100
 
 units: agetty overrides TERM
 
 Environment=TERM=... has no effect on agetty who sets it by itself. To
 really set TERM to a specified value, it has to be given on the command
 line.
 
 https://bugzilla.redhat.com/show_bug.cgi?id=870622
 
 
 From comment 1:
 Furthermore, I believe there's a bug in agetty. It attempts to detect
 the distinction between the vc and a serial line and set TERM
 accordingly, but it does not work as expected. I will send Karel a fix.

 ... hmm, I don't remember any discussion.
 
 Add term name to the command line is very poor workaround, distinction
 between the vc and a serial line is critical thing for agetty as it
 modifies many settings on the line.

Karel

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


[systemd-devel] [PATCH] units: cleanup agetty command line

2013-06-03 Thread Karel Zak
 * baud rate is optional and unnecessary for virtual terminals
 * term type is optional (default is 'linux' for virtual terminals
   and 'vt102' for serial lines)
 * long options are more user-friendly

... all this is supported since util-linux v2.20 (Aug 2011).

Signed-off-by: Karel Zak k...@redhat.com
---
 units/getty@.service.m4| 2 +-
 units/serial-getty@.service.m4 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/units/getty@.service.m4 b/units/getty@.service.m4
index 083eb97..f32ca99 100644
--- a/units/getty@.service.m4
+++ b/units/getty@.service.m4
@@ -27,7 +27,7 @@ ConditionPathExists=/dev/tty0
 
 [Service]
 # the VT is cleared by TTYVTDisallocate
-ExecStart=-/sbin/agetty --noclear %I 38400 linux
+ExecStart=-/sbin/agetty --noclear %I
 Type=idle
 Restart=always
 RestartSec=0
diff --git a/units/serial-getty@.service.m4 b/units/serial-getty@.service.m4
index 60d7737..5e16963 100644
--- a/units/serial-getty@.service.m4
+++ b/units/serial-getty@.service.m4
@@ -22,7 +22,7 @@ Before=getty.target
 IgnoreOnIsolate=yes
 
 [Service]
-ExecStart=-/sbin/agetty -s %I 115200,38400,9600 vt102
+ExecStart=-/sbin/agetty --keep-baud %I 115200,38400,9600
 Type=idle
 Restart=always
 RestartSec=0
-- 
1.8.1.4

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


Re: [systemd-devel] [v2] udev: Expose new ISO9660 props from libblkid

2013-02-18 Thread Karel Zak
On Sat, Feb 16, 2013 at 05:40:18PM +0100, Kay Sievers wrote:
 On Sat, Feb 16, 2013 at 4:45 PM, Zbigniew Jędrzejewski-Szmek
 zbys...@in.waw.pl wrote:
  On Wed, Feb 13, 2013 at 05:39:54AM +0200, Zeeshan Ali (Khattak) wrote:
 
  +} else if (streq(name, SYSTEM_ID))
  +udev_builtin_add_property(dev, test, ID_FS_SYSTEM_ID, 
  value);
  +
  +else if (streq(name, PUBLISHER_ID))
  +udev_builtin_add_property(dev, test, 
  ID_FS_PUBLISHER_ID, value);
  +
  +else if (streq(name, APPLICATION_ID))
  +udev_builtin_add_property(dev, test, 
  ID_FS_APPLICATION_ID, value);
  +
  +else if (streq(name, BOOT_SYSTEM_ID))
  +udev_builtin_add_property(dev, test, 
  ID_FS_BOOT_SYSTEM_ID, value);
 
  iiuc, those strings are under the control of the FS creator.
  Shouldn't they be treated like e.g. LABEL and passed through
  blkid_safe_string and blkid_encode_string?
 
 Yeah, they need to. I can do that when I merge it.
 
 I still need to check with Karel first, because I think that doesn't
 look like something we should export for iso9660 from libblkid:
ID_FS_UUID=2012-05-22-20-55-32-00
 

 commit 05a9d5120c10ffc21f21db09eec685a7258b2fb4
 Author: Andreas Vogel andreas.vo...@anvo-it.de
 Date:   Wed Mar 21 13:43:35 2012 +0100

 libblkid: generate pseudo-UUID for ISO9660 image file
 
 The UUID is generated from the modification date in the ISO volume
 descriptor. As GRUB 2 is using this definition for the pseudo UUID for
 ISO9660 files libblkid would be perfectly compatible with GRUB 2.


 It would not cause much trouble, but it really is no UUID in any usual
 sense, and probably not very useful to export as a symlink in /dev.

 I guess it's relatively safe to use this pseudo UUID. And
 it is not the first ugly UUID (see FAT) or HFS (UUID based on md5).
 
Karel

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


Re: [systemd-devel] systemd-fsck change fsck arguments to -a - -y

2013-02-18 Thread Karel Zak
On Wed, Feb 13, 2013 at 03:32:46AM +0100, Lennart Poettering wrote:
   Hmm, I wonder if -a or -y is the way to go. Karel, as util-linux/fsck
   maintainer, do you have an opinion whether we should use -a or -y for
   automatic, non-interactive fscking? Is -a obsolete and -y the future?
  
   This is gray zone... there is not explicit standard or conclusion
   that -a (or -p) or -y is supported by all fsck.type checkers.
   
   Anyway, it seems that -a is supported on more places.

 I did small investigation and result:

 extN: -a -y

 reaiser: -a -y

 vfat: -a -y

 minix:  -a

 cramfs: I'm going to improve fsck.cramfs to accept -a and -y

 xfs: fsck.xfs is dummy shell script, does nothing, accepts everything:-)

 btrfs: has --repair, it seems like synonym for -a (I'll ask for more
details at btrfs lists)

 ntfs (-3g): does not support options at all

 
Karel


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


Re: [systemd-devel] systemd-fsck change fsck arguments to -a - -y

2013-02-18 Thread Karel Zak
On Mon, Feb 18, 2013 at 11:52:31AM +0100, Karel Zak wrote:
 On Wed, Feb 13, 2013 at 03:32:46AM +0100, Lennart Poettering wrote:
Hmm, I wonder if -a or -y is the way to go. Karel, as util-linux/fsck
maintainer, do you have an opinion whether we should use -a or -y for
automatic, non-interactive fscking? Is -a obsolete and -y the future?
   
This is gray zone... there is not explicit standard or conclusion
that -a (or -p) or -y is supported by all fsck.type checkers.

Anyway, it seems that -a is supported on more places.
 
  I did small investigation and result:
 
  extN: -a -y
 
  reaiser: -a -y
 
  vfat: -a -y
 
  minix:  -a
 
  cramfs: I'm going to improve fsck.cramfs to accept -a and -y
 
  xfs: fsck.xfs is dummy shell script, does nothing, accepts everything:-)
 
  btrfs: has --repair, it seems like synonym for -a (I'll ask for more
 details at btrfs lists)

 update (after git clone): 

fsck.btrfs accepts and silently ignores -a

 Karel

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


Re: [systemd-devel] systemd-fsck change fsck arguments to -a - -y

2013-02-11 Thread Karel Zak
On Fri, Feb 08, 2013 at 12:38:55AM +0100, Lennart Poettering wrote:
  diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
  index 058f34d..b1938c7 100644
  --- a/src/fsck/fsck.c
  +++ b/src/fsck/fsck.c
  @@ -321,9 +321,10 @@ int main(int argc, char *argv[]) {
   }
   
   cmdline[i++] = /sbin/fsck;
  -cmdline[i++] = -a;
  +//cmdline[i++] = -a;
   cmdline[i++] = -T;
   cmdline[i++] = -l;
  +cmdline[i++] = -y;
   
 
 Hmm, I wonder if -a or -y is the way to go. Karel, as util-linux/fsck
 maintainer, do you have an opinion whether we should use -a or -y for
 automatic, non-interactive fscking? Is -a obsolete and -y the future?

 This is gray zone... there is not explicit standard or conclusion
 that -a (or -p) or -y is supported by all fsck.type checkers.
 
 Anyway, it seems that -a is supported on more places.

Karel


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


Re: [systemd-devel] when will mount / df get fixed?

2012-10-01 Thread Karel Zak
On Sat, Sep 29, 2012 at 07:36:54PM +0200, Reindl Harald wrote:
 you missunderstood me
 
 that all mount are in the output is OK
 BUT all the years there was a hint taht it is a bind-mount
 since systemd/F15 there is no difference

 There is no difference. The bind is an operation, not a special
 state of any mountpoint. Nowhere in the system is information that
 the mountpoint has been created by bind -- the kernel does not
 see any difference between the original and bind mount. It's just
 another reference to the same object (device).

mount /dev/sda1 /mnt1
mount /dev/sda1 /mnt2

 is exactly the same as:

mount /dev/sda1 /mnt1
mount --bind /mnt1 /mnt2


 We should not care about bind flag in mtab (or another place) at
 all. The solution is to de-duplicate df(1) output.


 It's fine to blame systemd guys for all the bad things in the World,
 but kill the original mtab concept was planned independently on
 systemd.

Karel

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


Re: [systemd-devel] [PATCH 1/5] build-sys: move common libraries to separate Makefile

2012-06-19 Thread Karel Zak
On Tue, Jun 19, 2012 at 10:31:30AM +0200, Lennart Poettering wrote:
 [1] I mean, seriously, we made the clear decision to have only a single
 makefile and avoid recursive make and now with splitting this stuff up
 you undo that half-way.

Note that
include Makefile-udev.am

does not mean recursive make, the result is one Makefile. It's split
of *automake* files.

Karel

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


Re: [systemd-devel] [PATCH] fstab-generator: ignore devices with fstype ignore

2012-06-18 Thread Karel Zak
On Mon, Jun 18, 2012 at 03:16:07PM +0200, Kay Sievers wrote:
 On Mon, Jun 18, 2012 at 5:07 AM, Dave Reisner dreis...@archlinux.org wrote:
  This is a valid field as documented by fstab(5). In line with mount(8)'s
  behavior when iterating through /etc/fstab, the generator should skip
  this entry entirely.
 
 Hmm, shouldn't we rather remove the over-loading of the fstype in
 util-linux instead of adding that to systemd.

 +1

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


Re: [systemd-devel] [RFC] link against util-linux for fstab parsing

2012-02-18 Thread Karel Zak
On Fri, Feb 17, 2012 at 04:47:51PM -0500, Dave Reisner wrote:
 +tb = mnt_new_table();
 +if (!tb) {
 +return -ENOMEM;
 +}
  
 -while ((me = getmntent(f))) {
 -char *where, *what;
 -int k;
 +mnt_cache = mnt_new_cache();
 +if (!mnt_cache) {
 +r = -ENOMEM;
 +goto finish;
 +}

 The cache is completely unnecessary here as you don't search in the
 table (fstab).

  
 -if (!(what = fstab_node_to_udev_node(me-mnt_fsname))) {
 -r = -ENOMEM;
 -goto finish;
 -}
 +mnt_table_set_cache(tb, mnt_cache);
  
 -if (!(where = strdup(me-mnt_dir))) {
 -free(what);
 -r = -ENOMEM;
 -goto finish;
 -}
 +r = mnt_table_parse_fstab(tb, /etc/fstab);

 Please, use mnt_table_parse_fstab(tb, NULL); The filename is there to
 overwrite library default.

  finish:
 +if (tb)
 +mnt_free_table(tb);
 +if (mnt_cache)
 +mnt_free_cache(mnt_cache);

 like libc free() all mnt_free_* functions accept NULL.


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


Re: [systemd-devel] [PATCH ] Adding /etc/fstab.d/*.fstab support

2012-01-20 Thread Karel Zak
On Fri, Jan 20, 2012 at 02:46:21PM +0100, Kay Sievers wrote:
 If we go for advanced storage handling, we might need to invent
 something that can carry real metadata and assembly instructions

 This is my plan this year (with DM people), and I think that assembly
 information for block devices don't have to be stored on the same
 place like filesystems description.

Karel

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


Re: [systemd-devel] [PATCH ] Adding /etc/fstab.d/*.fstab support

2012-01-20 Thread Karel Zak
On Fri, Jan 20, 2012 at 02:28:14PM +0100, Kay Sievers wrote:
 On Fri, Jan 20, 2012 at 07:52, Masatake YAMATO yam...@redhat.com wrote:
  mount command in the latest version of util-linux(2.21-rc1[1])
  supports /etc/fstab.d; mount command reads /etc/fstab.d/*.fstab
  files as if they are written in /etc/fstab.
 
  The benefits of .d mechanism are explained in [2][3].
 
  With this patch, systemd can handle /etc/fstab.d/*.fstab.
 
 That's an absolute mis-feature, that needs to be removed. I'm all
 against supporting that, it breaks tons of stuff, and must not happen.

 Note, I have started a discussion about this topic on lists where we
 usually announce util-linux release:

https://lkml.org/lkml/2012/1/20/104

 We will see...


Karel

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


Re: [systemd-devel] Considering fuse+sshfs mounts as network

2012-01-11 Thread Karel Zak
On Wed, Jan 11, 2012 at 09:24:51AM +, Colin Guthrie wrote:
 I've got some users with fuse based sshfs mounts in their fstab which is
 messing up their boot.
 
 Obviously they can add noauto but then their argument is that they do
 want them to be automatically mounted... I'm sure there are other ways
 to solve this, but by the same token, there already exists a whitelist
 in the code to consider certain filesystems as network and I was
 wondering if we could extend this to fuse+sshfs too?
 
 Would something like this be accepted if it was tidied up (and actually
 tested!)?:
 
 commit 488b5ba5f8fcb368185fabd14c32c3e12cf90c0b
 Author: Colin Guthrie co...@mageia.org
 Date:   Mon Jan 9 11:14:15 2012 +
 
 mount: Consider some fuse mounts as network (sshfs)
 
 diff --git a/src/mount.c b/src/mount.c
 index f72c50a..15163d3 100644
 --- a/src/mount.c
 +++ b/src/mount.c
 @@ -285,8 +285,22 @@ static bool mount_is_network(MountParameters *p) {
  if (mount_test_option(p-options, _netdev))
  return true;
 
 -if (p-fstype  fstype_is_network(p-fstype))
 -return true;
 +if (p-fstype) {
 +if (p-what  streq(p-fstype, fuse)) {
^^^
 +char *fstype;
 +if (asprintf(fstype, fuse@%s, p-what) = 0) {
 +fstype[strcspn(fstype, #)] = 0;

 +if (fstype_is_network(fstype)) {
 +free(fstype);
 +return true;
 +}
 +free(fstype);
 +}

man fstab:

  mount(8) and umount(8) support filesystem subtypes. The subtype is
  defined by '.subtype' suffix. For example 'fuse.sshfs'. It's
  recommended to use subtype notation rather  than add any prefix to
  the first fstab field (for example 'sshfs#example.com' is deprecated).


Note that this feature has been requested by fuse developers, because
with this notation we can support subtype specific
/sbin/mount.type[.subtype] helpers. The 'sshfs#example.com' is
horrible hack.

Karel

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


Re: [systemd-devel] PATCH: do not run fsck on tmpfs mountpoint

2011-11-02 Thread Karel Zak
On Wed, Nov 02, 2011 at 12:55:56PM +0100, Lennart Poettering wrote:
 On Wed, 02.11.11 12:15, Kay Sievers (kay.siev...@vrfy.org) wrote:
 
  
  On Wed, Nov 2, 2011 at 11:21, Frederic Crozat fcro...@suse.com wrote:
   Le mardi 01 novembre 2011 à 16:54 +0100, Lennart Poettering a écrit :
   On Thu, 27.10.11 16:19, Frederic Crozat (fcro...@suse.com) wrote:
  
You really don't want to fsck a tmpfs, even if passno is non-null (it
was causing many issue, forcing system to go to emergency).
  
   Hmm, I wonder if this is the right fix. I wonder what fsck -a does if it
   finds a passno != 0 for an entry where /sbin/fsck.xxx. If that fails on
   it we should probably do so too. If it silently ignores passno != 0
   where the fsck is missing then we probably should implement a similar
   logic. However doing an explicit check for tmpfs sounds wrong to me:
   there are other fs where fsck makes little sense, and we would have to
   either check them all or none?
  
   I've just checked fsck code :
   - it has a list of ignore filesystems :
  
  Please let's not start copying that stuff, fsck is hardly an example
  how things should be done today. Such lists can never be up-to-date,
  and they are not today.
  
  I guess, if such broken configs should be supported, which I'm really
  not sure about, fsck itself should be made to find that out and return
  successful without doing anything. Such things should not be guarded
  in systemd with just another static blacklist.
 
 I agree here, I think such a blacklist should not be copied from
 fsck. The issue should be fixed in util-linux I guess, not in systemd.
 
 Karel, can we convince you to add an option for fsck that checks the
 existing blacklists, much like -a would do it? Than wed simply pass that
 option when invoking fsck and everything would be fine.

 I think we can use the blacklist always, add a new option seems like
 overkill.  If the list makes sense for -a then the same list should
 be usable for non-all mode too.

Karel

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


Re: [systemd-devel] PATCH: do not run fsck on tmpfs mountpoint

2011-11-02 Thread Karel Zak
On Wed, Nov 02, 2011 at 03:39:37PM +0100, Kay Sievers wrote:
 On Wed, Nov 2, 2011 at 15:27, Karel Zak k...@redhat.com wrote:
  On Wed, Nov 02, 2011 at 12:15:29PM +0100, Kay Sievers wrote:
  On Wed, Nov 2, 2011 at 11:21, Frederic Crozat fcro...@suse.com wrote:
   Le mardi 01 novembre 2011 à 16:54 +0100, Lennart Poettering a écrit :
   On Thu, 27.10.11 16:19, Frederic Crozat (fcro...@suse.com) wrote:
  
You really don't want to fsck a tmpfs, even if passno is non-null (it
was causing many issue, forcing system to go to emergency).
  
   Hmm, I wonder if this is the right fix. I wonder what fsck -a does if it
   finds a passno != 0 for an entry where /sbin/fsck.xxx. If that fails on
   it we should probably do so too. If it silently ignores passno != 0
   where the fsck is missing then we probably should implement a similar
   logic. However doing an explicit check for tmpfs sounds wrong to me:
   there are other fs where fsck makes little sense, and we would have to
   either check them all or none?
  
   I've just checked fsck code :
   - it has a list of ignore filesystems :
 
  Please let's not start copying that stuff, fsck is hardly an example
  how things should be done today. Such lists can never be up-to-date,
  and they are not today.
 
  I guess, if such broken configs should be supported, which I'm really
  not sure about, fsck itself should be made to find that out and return
  successful without doing anything. Such things should not be guarded
  in systemd with just another static blacklist.
 
  Not sure if there are valid use cases, maybe we are able to skip all
  mounts which are not backed by a device, where major(s.st_rdev) == 0?
 
   Unfortunately major(s.st_rdev) is probably useless, try to mount any
   btrfs device :-)
 
 Yeah, it was about fsck only, not mount. :)

 Hmm... I'm talking about fsck, try to mount btrfs and check major(st.st_dev)
 for the mountpoint.

   BTW, in systemd/src/fsck.c I see:
 
         /* Virtual root devices don't need an fsck */
         if (major(st.st_dev) == 0)
               return 0;
 
   it means that btrfs root will be interpreted as a virtual device :-)
 
 Oh, why do we run into the issues with tmpfs then?

 This code is used for system root (/).

Karel

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


Re: [systemd-devel] /run DoS

2011-05-09 Thread Karel Zak
On Sun, Apr 03, 2011 at 11:45:51PM +0200, Kay Sievers wrote:
 2011/4/3 Lennart Poettering mzerq...@0pointer.de:
  On Sun, 03.04.11 23:28, Michał Piotrowski (mkkp...@gmail.com) wrote:
 
   But for /dev/shm I see no quick fix... do you?
 
  Unfortunately not. No one foresaw that quota support on tmpfs will
  someday be useful :)
 
  
   I think we should fix either both or should wait for the proper fix by
   the kernel.
 
  Can you temporarily fix one?
 
  Well, of course we could.
 
  But, think about it, what does this help? The vulnerability doesn't go
  away by doing this, and we'd have a temporary hack in there, that we'd
  have to remove later on again.
 
 Systems who might run into problems with /dev/shm, can just add limits
 to /etc/fstab, and systemd will re-mount it and apply them.
 
 There should really be a _proper_ solution some day, be it quota or
 something else. We have way too many /tmp-like dirs, where users can
 just leave their crap behind and cause problems. This is really
 nothing new with systemd.

 Wouldn't be possible to use namespaces (pam_namespace ?) and after
 user login create any private tmpfs (with explicitly defined size)?

 This allows to use the same path (e.g. /run/user) for all users, make
 the content of the directory invisible for other users and
 effectively control resources. All this is supported by kernel ;-)

Karel

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


Re: [systemd-devel] [PATCH 2/2] Adding binary to shutdown the system

2010-10-06 Thread Karel Zak
On Wed, Oct 06, 2010 at 02:05:44AM -0300, Gustavo Sverzut Barbieri wrote:
 +/* umount all mountpoints, swaps, and loopback devices */
 +retries = FINALIZE_ATTEMPTS;
 +while (need_umount || need_swapoff || need_loop_detach) {
 +if (need_umount) {
 +log_info(Unmounting Filesystems);
 +r = umount_all();
 +if (r == 0)
 +need_umount = false;
 +else
 +log_warning(Not all filesystems unmounted);
 +}
 +
 +if (need_swapoff) {
 +log_info(Disabling Swaps);
 +r = swapoff_all();
 +if (r == 0)
 +need_swapoff = false;
 +else
 +log_warning(Not all swaps are off );
 +}

 it's probably better to call swapoff_all before umount_all (hint:
 Linux supports swap-area in regular files).

 +if (need_loop_detach) {
 +log_info(Umounting and Detaching Loopback Devices);
 +r = loopback_detach_all();
 +if (r == 0)
 +need_loop_detach = false;
 +else
 +log_warning(Not all loop devices detached);
 +}
 +
 +if (need_umount || need_swapoff || need_loop_detach) {
 +retries--;
 +
 +if (retries = FINALIZE_CRITICAL_ATTEMPTS) {
 +log_warning(Approaching critical level to 
 finalize filesystem and devices, try to kill all processes.);
 +rescue_send_signal(SIGTERM);
 +rescue_send_signal(SIGKILL);
 +}
 +
 +if (retries  0)
 +log_info(Action still required, %d tries 
 left, retries);
 +else {
 +log_error(Tried enough but still action 
 required need_umount=%d, need_swapoff=%d, need_loop_detach=%d, need_umount, 
 need_swapoff, need_loop_detach);
 +r = -EBUSY;
 +goto error;
 +}
 +}
 +}

 what about
 
exec( swapoff -a );
exec( umount -a );


Karel

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


Re: [systemd-devel] Compiling in a sandbox

2010-07-09 Thread Karel Zak
On Fri, Jul 09, 2010 at 12:02:13AM +0200, Lennart Poettering wrote:
 A thinkable alternative would be if we could extract this information
 directly from the ELF file, without having to execute it. That would
 probably be useful when cross-building systemd. But I am not aware of
 any somewhat standard tool to extract data fields from ELF
 files. Anyone?

 man readelf  
 
 and if I good remember autotools use also objdump.

Karel

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