Re: [systemd-devel] Switch root slowness

2014-10-31 Thread Jan Synacek
Lennart Poettering lenn...@poettering.net writes:
 On Thu, 30.10.14 14:35, Lennart Poettering (lenn...@poettering.net) wrote:
 I wish there was a way how we could use getrandom() in a way like
 /dev/urandom, where we can pull out the non-initialized data
 anyway. In absence of that we can just fallback to /dev/urandom on
 EAGAIN I guess, and always pass GRND_NONBLOCK.

 I have now implemented that. Please test!

 Lennart

It works now, thanks!

-- 
Jan Synacek
Software Engineer, Red Hat


signature.asc
Description: PGP signature
___
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] tests: add tests for fileio.c

2014-10-31 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Oct 30, 2014 at 10:34 PM, Ronny Chevalier
chevalier.ro...@gmail.com wrote:
 add tests for the following functions:
 - write_string_file_no_create
 - load_env_file_pairs
 ---
  src/test/test-fileio.c | 63 
 ++
  1 file changed, 63 insertions(+)

 diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
 index 7e7b4ac..a713abd 100644
 --- a/src/test/test-fileio.c
 +++ b/src/test/test-fileio.c
 @@ -331,6 +331,23 @@ static void test_write_string_file(void) {
  unlink(fn);
  }

 +static void test_write_string_file_no_create(void) {
 +char fn[] = /tmp/test-write_string_file_no_create-XX;
 +_cleanup_close_ int fd;
 +char buf[64] = {0};
 +
 +fd = mkostemp_safe(fn, O_RDWR);
 +assert_se(fd = 0);
 +
 +
 assert_se(write_string_file_no_create(/a/file/which/does/not/exists/i/guess,
  boohoo)  0);
 +assert_se(write_string_file_no_create(fn, boohoo) == 0);
 +
 +assert_se(read(fd, buf, sizeof(buf)));
 +assert_se(streq(buf, boohoo\n));
 +
 +unlink(fn);
 +}
 +
  static void test_sendfile_full(void) {
  char in_fn[] = /tmp/test-sendfile_full-XX;
  char out_fn[] = /tmp/test-sendfile_full-XX;
 @@ -355,6 +372,50 @@ static void test_sendfile_full(void) {
  unlink(out_fn);
  }

 +static void test_load_env_file_pairs(void) {
 +char fn[] = /tmp/test-load_env_file_pairs-XX;
 +int fd;
 +int r;
 +_cleanup_fclose_ FILE *f = NULL;
 +_cleanup_strv_free_ char **l = NULL;
 +char **k, **v;
 +
 +fd = mkostemp_safe(fn, O_RDWR);
 +assert_se(fd = 0);
 +
 +r = write_string_file(fn,
 +NAME=\Arch Linux\\n
 +ID=arch\n
 +PRETTY_NAME=\Arch Linux\\n
 +ANSI_COLOR=\0;36\\n
 +HOME_URL=\https://www.archlinux.org/\\n;
 +SUPPORT_URL=\https://bbs.archlinux.org/\\n;
 +BUG_REPORT_URL=\https://bugs.archlinux.org/\\n;
 +);
 +assert_se(r == 0);
 +
 +f = fdopen(fd, r);
 +assert_se(f);
 +
 +r = load_env_file_pairs(f, fn, NULL, l);
 +assert_se(r = 0);
 +
 +assert_se(strv_length(l) == 14);
 +STRV_FOREACH_PAIR(k, v, l) {
 +assert_se(STR_IN_SET(*k, NAME, ID, PRETTY_NAME, 
 ANSI_COLOR, HOME_URL, SUPPORT_URL, BUG_REPORT_URL));
 +printf(%s=%s\n, *k, *v);
 +if (streq(*k, NAME)) assert_se(streq(*v, Arch Linux));
 +if (streq(*k, ID)) assert_se(streq(*v, arch));
 +if (streq(*k, PRETTY_NAME)) assert_se(streq(*v, Arch 
 Linux));
 +if (streq(*k, ANSI_COLOR)) assert_se(streq(*v, 0;36));
 +if (streq(*k, HOME_URL)) assert_se(streq(*v, 
 https://www.archlinux.org/;));
 +if (streq(*k, SUPPORT_URL)) assert_se(streq(*v, 
 https://bbs.archlinux.org/;));
 +if (streq(*k, BUG_REPORT_URL)) assert_se(streq(*v, 
 https://bugs.archlinux.org/;));
 +}
 +
 +unlink(fn);
 +}
 +
  int main(int argc, char *argv[]) {
  log_parse_environment();
  log_open();
 @@ -366,7 +427,9 @@ int main(int argc, char *argv[]) {
  test_capeff();
  test_write_string_stream();
  test_write_string_file();
 +test_write_string_file_no_create();
  test_sendfile_full();
 +test_load_env_file_pairs();

  return 0;
  }
 --
 2.1.3

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


Re: [systemd-devel] [PATCH] remove references of readahead

2014-10-31 Thread Tom Gundersen
Applied. Thanks!

Tom

On Wed, Oct 29, 2014 at 2:38 PM, Ronny Chevalier
chevalier.ro...@gmail.com wrote:
 ---
  .gitignore | 1 -
  README | 1 -
  TODO   | 7 ---
  3 files changed, 9 deletions(-)

 diff --git a/.gitignore b/.gitignore
 index 0b71f09..14f1691 100644
 --- a/.gitignore
 +++ b/.gitignore
 @@ -101,7 +101,6 @@
  /systemd-quotacheck
  /systemd-random-seed
  /systemd-rc-local-generator
 -/systemd-readahead
  /systemd-remount-api-vfs
  /systemd-remount-fs
  /systemd-reply-password
 diff --git a/README b/README
 index 99b66a8..1440367 100644
 --- a/README
 +++ b/README
 @@ -30,7 +30,6 @@ AUTHOR:

  LICENSE:
  LGPLv2.1+ for all code
 -- except sd-readahead.[ch] which is MIT
  - except src/shared/MurmurHash2.c which is Public Domain
  - except src/shared/siphash24.c which is CC0 Public Domain
  - except src/journal/lookup3.c which is Public Domain
 diff --git a/TODO b/TODO
 index b07d664..abe89b7 100644
 --- a/TODO
 +++ b/TODO
 @@ -646,13 +646,6 @@ Features:

  * and a dbus call to generate target from current state

 -* readahead:
 -  - drop /.readahead on bigger upgrades with yum
 -  - move readahead files into /var (look for them with .path units?)
 -  - readahead: use BTRFS_IOC_DEFRAG_RANGE instead of BTRFS_IOC_DEFRAG ioctl, 
 with START_IO
 -  - readahead: when bumping /sys readahead variable save mtime and compare 
 later to detect changes
 -  - readahead: make use of EXT4_IOC_MOVE_EXT, as used by 
 http://e4rat.sourceforge.net/
 -
  * GC unreferenced jobs (such as .device jobs)

  * write blog stories about:
 --
 2.1.2

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


Re: [systemd-devel] [PATCH] tests: add tests for strv.c

2014-10-31 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Oct 30, 2014 at 10:34 PM, Ronny Chevalier
chevalier.ro...@gmail.com wrote:
 add tests for:
 - strv_find_startswith
 - strv_push_prepend
 - strv_consume_prepend
 ---
  src/test/test-strv.c | 39 +++
  1 file changed, 39 insertions(+)

 diff --git a/src/test/test-strv.c b/src/test/test-strv.c
 index bbfe306..915fa46 100644
 --- a/src/test/test-strv.c
 +++ b/src/test/test-strv.c
 @@ -113,6 +113,22 @@ static void test_strv_find_prefix(void) {
  assert_se(!strv_find_prefix((char **)input_table_multiple, onee));
  }

 +static void test_strv_find_startswith(void) {
 +char *r;
 +
 +r = strv_find_startswith((char **)input_table_multiple, o);
 +assert_se(r  streq(r, ne));
 +
 +r = strv_find_startswith((char **)input_table_multiple, one);
 +assert_se(r  streq(r, ));
 +
 +r = strv_find_startswith((char **)input_table_multiple, );
 +assert_se(r  streq(r, one));
 +
 +assert_se(!strv_find_startswith((char **)input_table_multiple, 
 xxx));
 +assert_se(!strv_find_startswith((char **)input_table_multiple, 
 onee));
 +}
 +
  static void test_strv_join(void) {
  _cleanup_free_ char *p = NULL, *q = NULL, *r = NULL, *s = NULL, *t = 
 NULL;

 @@ -416,6 +432,27 @@ static void test_strv_from_stdarg_alloca(void) {
  test_strv_from_stdarg_alloca_one(STRV_MAKE_EMPTY, NULL);
  }

 +static void test_strv_push_prepend(void) {
 +_cleanup_strv_free_ char **a = NULL;
 +
 +a = strv_new(foo, bar, three, NULL);
 +
 +assert_se(strv_push_prepend(a, strdup(first)) = 0);
 +assert_se(streq(a[0], first));
 +assert_se(streq(a[1], foo));
 +assert_se(streq(a[2], bar));
 +assert_se(streq(a[3], three));
 +assert_se(!a[4]);
 +
 +assert_se(strv_consume_prepend(a, strdup(first2)) = 0);
 +assert_se(streq(a[0], first2));
 +assert_se(streq(a[1], first));
 +assert_se(streq(a[2], foo));
 +assert_se(streq(a[3], bar));
 +assert_se(streq(a[4], three));
 +assert_se(!a[5]);
 +}
 +
  int main(int argc, char *argv[]) {
  test_specifier_printf();
  test_strv_foreach();
 @@ -423,6 +460,7 @@ int main(int argc, char *argv[]) {
  test_strv_foreach_pair();
  test_strv_find();
  test_strv_find_prefix();
 +test_strv_find_startswith();
  test_strv_join();

  test_strv_quote_unquote(input_table_multiple, \one\ \two\ 
 \three\);
 @@ -462,6 +500,7 @@ int main(int argc, char *argv[]) {
  test_strv_extend();
  test_strv_extendf();
  test_strv_from_stdarg_alloca();
 +test_strv_push_prepend();

  return 0;
  }
 --
 2.1.3

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


Re: [systemd-devel] [PATCH 1/4] shared: add missing includes

2014-10-31 Thread Tom Gundersen
Applied all four. Thanks!

Tom

On Thu, Oct 30, 2014 at 10:32 PM, Ronny Chevalier
chevalier.ro...@gmail.com wrote:
 ---
  src/shared/copy.h| 3 +++
  src/shared/locale-util.h | 4 
  2 files changed, 7 insertions(+)

 diff --git a/src/shared/copy.h b/src/shared/copy.h
 index 0bf2598..6b93107 100644
 --- a/src/shared/copy.h
 +++ b/src/shared/copy.h
 @@ -21,6 +21,9 @@
along with systemd; If not, see http://www.gnu.org/licenses/.
  ***/

 +#include stdbool.h
 +#include sys/types.h
 +
  int copy_file(const char *from, const char *to, int flags, mode_t mode);
  int copy_tree(const char *from, const char *to, bool merge);
  int copy_bytes(int fdf, int fdt, off_t max_bytes);
 diff --git a/src/shared/locale-util.h b/src/shared/locale-util.h
 index d7a3e4f..e48aa3d 100644
 --- a/src/shared/locale-util.h
 +++ b/src/shared/locale-util.h
 @@ -21,6 +21,10 @@
along with systemd; If not, see http://www.gnu.org/licenses/.
  ***/

 +#include stdbool.h
 +
 +#include macro.h
 +
  typedef enum LocaleVariable {
  /* We don't list LC_ALL here on purpose. People should be
   * using LANG instead. */
 --
 2.1.3

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


Re: [systemd-devel] [PATCH] shared: fix typo

2014-10-31 Thread Tom Gundersen
Applied. Thanks!

Tom

On Thu, Oct 30, 2014 at 10:34 PM, Ronny Chevalier
chevalier.ro...@gmail.com wrote:
 ---
  src/shared/capability.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/src/shared/capability.c b/src/shared/capability.c
 index d2b9013..0226542 100644
 --- a/src/shared/capability.c
 +++ b/src/shared/capability.c
 @@ -228,7 +228,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t 
 keep_capabilities) {
   * which we want to avoid. */

  if (setresgid(gid, gid, gid)  0) {
 -log_error(Failed change group ID: %m);
 +log_error(Failed to change group ID: %m);
  return -errno;
  }

 @@ -244,7 +244,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t 
 keep_capabilities) {

  r = setresuid(uid, uid, uid);
  if (r  0) {
 -log_error(Failed change user ID: %m);
 +log_error(Failed to change user ID: %m);
  return -errno;
  }

 --
 2.1.3

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


Re: [systemd-devel] [PATCH] shared/install: avoid prematurely rejecting missing units

2014-10-31 Thread Dave Reisner
On Fri, Oct 31, 2014 at 04:04:53AM +0100, Zbigniew Jędrzejewski-Szmek wrote:
 On Thu, Oct 30, 2014 at 08:28:14PM -0400, Dave Reisner wrote:
  f7101b7368df copied some logic to prevent enabling masked units, but
  also added a check which causes attempts to enable templated units to
  fail. Since we know the logic beyond this check will properly handle
  units which truly do not exist, we can rely on the unit file state
  comparison to suffice for expressing the intent of f7101b7368df.
  
  ref: https://bugs.archlinux.org/task/42616
  ---
  This seems to me like the right thing to do, but I'm not so familiar with
  this code...
 
 I verified that your fix works. Can you add a comment in the code which
 explains why state is not checked though? It should help with future
 modifications.
 
 Zbyszek
 

Thanks! Added a comment and pushed.

  
   src/shared/install.c | 5 -
   1 file changed, 5 deletions(-)
  
  diff --git a/src/shared/install.c b/src/shared/install.c
  index 035b44c..3ad5362 100644
  --- a/src/shared/install.c
  +++ b/src/shared/install.c
  @@ -1621,11 +1621,6 @@ int unit_file_enable(
   UnitFileState state;
   
   state = unit_file_get_state(scope, root_dir, *i);
  -if (state  0) {
  -log_error(Failed to get unit file state for %s: 
  %s, *i, strerror(-state));
  -return state;
  -}
  -
   if (state == UNIT_FILE_MASKED || state == 
  UNIT_FILE_MASKED_RUNTIME) {
   log_error(Failed to enable unit: Unit %s is 
  masked, *i);
   return -ENOTSUP;
  -- 
  2.1.3
  ___
  systemd-devel mailing list
  systemd-devel@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
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 Timofey Titovets
2014-10-31 11:57 GMT+03:00 Karel Zak k...@redhat.com:

 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

Thanks Karel, Really big thanks.


 Karel

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



-- 
Have a nice day,
Timofey.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2014-10-31 Thread Timofey Titovets

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 rewrite to parse /proc/self/mountinfo
This only support root device like /dev/???*
I can't support LVM/Luks  etc, i'm not using these setups.

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

v4:
Again rewrited.
Search / in 5th column and
parse get name of bdev from 10th column

Not tested while boot process, code in separate binary file working good.

From 97d259c38da3a32569e30bfaf7df56c062c570a6 Mon Sep 17 00:00:00 2001
From: Timofey Titovets nefelim...@gmail.com
Date: Fri, 31 Oct 2014 15:43:30 +0300
Subject: [PATCH] Bootchart: use /proc/pid/mountinfo for root bdev

---
 src/bootchart/svg.c | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index faf377e..2e9c039 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -151,6 +151,22 @@ static void svg_header(void) {
 svg(]]\n   /style\n/defs\n\n);
 }

+void get_rootbdev(char *rootbdev) {
+FILE *file = fopen(/proc/self/mountinfo, r);
+char mnt_point[PATH_MAX];
+char mnt_source[PATH_MAX];
+char t[256]; // Trash
+while (file  strcmp(mnt_point, /)  !feof(file)){
+fscanf(file, %s %s %s %s %s %s %s %s %s %s %s,
+   t,t,t,t,
+   mnt_point,  t,t,t,t,
+   mnt_source, t);
+}
+if(!strcmp(mnt_point, /))
+strncpy(rootbdev, mnt_source[5], 3);
+fclose(file);
+}
+
 static void svg_title(const char *build) {
 char cmdline[256] = ;
 char filename[PATH_MAX];
@@ -159,7 +175,6 @@ static void svg_title(const char *build) {
 char model[256] = Unknown;
 char date[256] = Unknown;
 char cpu[256] = Unknown;
-char *c;
 FILE *f;
 time_t t;
 int fd, r;
@@ -174,12 +189,10 @@ static void svg_title(const char *build) {
 fclose(f);
 }

-/* extract root fs so we can find disk model name in sysfs */
-/* FIXME: this works only in the simple case */
-c = strstr(cmdline, root=/dev/);
-if (c) {
-strncpy(rootbdev, c[10], 3);
-rootbdev[3] = '\0';
+f = fopen(/proc/self/mountinfo, r);
+if (f) {
+fclose(f);
+get_rootbdev(rootbdev);
 sprintf(filename, block/%s/device/model, rootbdev);
 fd = openat(sysfd, filename, O_RDONLY);
 f = fdopen(fd, r);
--
2.1.3


From 97d259c38da3a32569e30bfaf7df56c062c570a6 Mon Sep 17 00:00:00 2001
From: Timofey Titovets nefelim...@gmail.com
Date: Fri, 31 Oct 2014 15:43:30 +0300
Subject: [PATCH] Bootchart: use /proc/pid/mountinfo for root bdev

---
 src/bootchart/svg.c | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/bootchart/svg.c b/src/bootchart/svg.c
index faf377e..2e9c039 100644
--- a/src/bootchart/svg.c
+++ b/src/bootchart/svg.c
@@ -151,6 +151,22 @@ static void svg_header(void) {
 svg(]]\n   /style\n/defs\n\n);
 }
 
+void get_rootbdev(char *rootbdev) {
+FILE *file = fopen(/proc/self/mountinfo, r);
+char mnt_point[PATH_MAX];
+char mnt_source[PATH_MAX];
+char t[256]; // Trash
+while (file  strcmp(mnt_point, /)  !feof(file)){
+fscanf(file, %s %s %s %s %s %s %s %s %s %s %s,
+   t,t,t,t,
+   mnt_point,  t,t,t,t,
+   mnt_source, t);
+}
+if(!strcmp(mnt_point, /))
+strncpy(rootbdev, mnt_source[5], 3);
+fclose(file);
+}
+
 static void svg_title(const char *build) {
 char cmdline[256] = ;
 char filename[PATH_MAX];
@@ -159,7 +175,6 @@ static void svg_title(const char *build) {
 char model[256] = Unknown;
 char date[256] = Unknown;
 char cpu[256] = Unknown;
-char *c;
 FILE *f;
 time_t t;
 int fd, r;
@@ -174,12 +189,10 @@ static void svg_title(const char *build) {
 fclose(f);
 }
 
-/* extract root fs so we can find disk model name in sysfs */
-/* FIXME: this works only in the simple case */
-c = strstr(cmdline, root=/dev/);
-if (c) {
-strncpy(rootbdev, c[10], 3);
-rootbdev[3] = '\0';
+f = fopen(/proc/self/mountinfo, r);
+if (f) {
+fclose(f);
+get_rootbdev(rootbdev);
 sprintf(filename, block/%s/device/model, rootbdev);
 fd = openat(sysfd, filename, O_RDONLY);
 f = fdopen(fd, r);
-- 
2.1.3

___

[systemd-devel] statelessy system

2014-10-31 Thread Łukasz Stelmach
Hello.

I am working to upgrade systemd in Tizen to v217 from v212. To verify
rpm packages we use rpmlint with some rules from opensuse[1]. For
whatever reason v217 package exceed allowed badness because it puts
config files (system.conf, journald.conf etc) in /etc/systemd. The check
[2] forbids putting anything in there and it seems to go along weel with
the sateless system goal of systemd.

My question: is v217 ready to run without /etc/systemd/*.conf and read
them from /usr/lib/systemd wher I (vendor) can put properly tailored files?

[1] https://github.com/openSUSE/rpmlint-checks
[2] https://github.com/openSUSE/rpmlint-checks/blob/master/CheckFilelist.py#L279

-- 
Łukasz Stelmach
Samsung RD Institute Poland
Samsung Electronics


pgpgAs47W425W.pgp
Description: PGP signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-31 Thread Fisher, Charles J. (Top Echelon)
-Original Message-


 How about:
 
 http://www.freedesktop.org/software/systemd/man/systemd.kill.html
 
 Would setting KillMode=process for the listener service have the required
 effect: on service stop, only kill the main process, leaving the child
 processes and cgroup running?

Yes, that probably will work around this problem. 

No, that's not how it works.

The listener is forked from the listener control utility, so a child process 
then spawns all database client children for all instances.

This is the procedure (at the risk of infuriating those with heightened 
sensitivities):




-bash-4.2$ export ORACLE_HOME=/home/oracle/Ora12c/db

-bash-4.2$ $ORACLE_HOME/bin/lsnrctl

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 31-OCT-2014 10:13:44

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Welcome to LSNRCTL, type help for information.

LSNRCTL

-bash-4.2$ ps -ef | grep lsnr
oracle   24564 24491  0 10:13 pts/000:00:00 
/home/oracle/Ora12c/db/bin/lsnrctl
oracle   24585 24534  0 10:15 pts/100:00:00 grep --color=auto lsnr

LSNRCTL start
Starting /home/oracle/Ora12c/db/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Log messages written to 
/home/oracle/Ora12c/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER

Alias LISTENER
Version   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date31-OCT-2014 10:15:34
Uptime0 days 0 hr. 0 min. 0 sec
Trace Level   off
Security  ON: Local OS Authentication
SNMP  OFF
Listener Log File 
/home/oracle/Ora12c/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL

-bash-4.2$ ps -ef | egrep '(lsnr|tns)'
root26 2  0 Oct30 ?00:00:00 [netns]
oracle   24564 24491  0 10:13 pts/000:00:00 
/home/oracle/Ora12c/db/bin/lsnrctl
oracle   24599 1  0 10:15 ?00:00:00 
/home/oracle/Ora12c/db/bin/tnslsnr LISTENER -inherit

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


Re: [systemd-devel] starting Oracle with systemd

2014-10-31 Thread Andrei Borzenkov
В Fri, 31 Oct 2014 11:20:02 -0400
Fisher, Charles J. (Top Echelon) charles.fis...@alcoa.com пишет:

 -Original Message-
 
 
  How about:
  
  http://www.freedesktop.org/software/systemd/man/systemd.kill.html
  
  Would setting KillMode=process for the listener service have the required
  effect: on service stop, only kill the main process, leaving the child
  processes and cgroup running?
 
 Yes, that probably will work around this problem. 
 
 No, that's not how it works.
 

What is that and what is it?

 The listener is forked from the listener control utility, so a child 
 process then spawns all database client children for all instances.
 

I know. So define service that starts listener, use lsnrctl start as
ExecStart, lsnrctl stop as ExecStop and set KillMode=process (or
none). What exactly does not work in this case?
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-31 Thread Reindl Harald



Am 31.10.2014 um 17:47 schrieb Fisher, Charles J. (Top Echelon):

From: Andrei Borzenkov [mailto:arvidj...@gmail.com]


I know. So define service that starts listener, use lsnrctl start as
ExecStart, lsnrctl stop as ExecStop and set KillMode=process (or
none). What exactly does not work in this case?


Reading this, none is the right choice, so the child connections don't die.

For some reason, the iptables didn't happen. Maybe it needs to be fully 
qualified.


yes it needs to be as any other path
the documentation is very clear here


[root@localhost system]# cat oracle-listener.service
[Unit]
Description=oracle listener
After=syslog.target

[Service]
Environment='ORACLE_HOME=/home/oracle/Ora12c/db'
ExecStart=/home/oracle/Ora12c/db/bin/lsnrctl start
ExecStop=/home/oracle/Ora12c/db/bin/lsnrctl stop
KillMode=none
ExecStartPost=iptables -I INPUT -p tcp --dport 1521 --syn -j ACCEPT
Type=forking
User=oracle
Group=dba

[Install]
WantedBy=multi-user.target

#This file should be placed in /etc/systemd/system
#enable for start at boot by: systemctl enable oracle-listener.service




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


Re: [systemd-devel] starting Oracle with systemd

2014-10-31 Thread Fisher, Charles J. (Top Echelon)
-Original Message-
From: systemd-devel [mailto:systemd-devel-boun...@lists.freedesktop.org] On 
Behalf Of Reindl Harald

  For some reason, the iptables didn't happen. Maybe it needs to be fully 
  qualified.

 yes it needs to be as any other path
 the documentation is very clear here

No, [unix] user oracle doesn't have permission to run iptables.

I either need to sudo something up, or put this elsewhere.

Letting different commands run with different uids/gids would be a nice feature.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] starting Oracle with systemd

2014-10-31 Thread Reindl Harald


Am 31.10.2014 um 18:06 schrieb Fisher, Charles J. (Top Echelon):

From: systemd-devel [mailto:systemd-devel-boun...@lists.freedesktop.org] On 
Behalf Of Reindl Harald


For some reason, the iptables didn't happen. Maybe it needs to be fully 
qualified.



yes it needs to be as any other path
the documentation is very clear here


No, [unix] user oracle doesn't have permission to run iptables.


but it needs to be full qualified anyways


I either need to sudo something up, or put this elsewhere.
Letting different commands run with different uids/gids would be a nice feature


PermissionsStartOnly=true exists and so you can have helper processes 
as root while restrict the main process - anything else is hardly 
maintainable with the now clear ini-style of a unit




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


Re: [systemd-devel] starting Oracle with systemd

2014-10-31 Thread Reindl Harald


Am 31.10.2014 um 18:10 schrieb Reindl Harald:

Am 31.10.2014 um 18:06 schrieb Fisher, Charles J. (Top Echelon):

From: systemd-devel
[mailto:systemd-devel-boun...@lists.freedesktop.org] On Behalf Of
Reindl Harald


For some reason, the iptables didn't happen. Maybe it needs to be
fully qualified.



yes it needs to be as any other path
the documentation is very clear here


No, [unix] user oracle doesn't have permission to run iptables.


but it needs to be full qualified anyways


I either need to sudo something up, or put this elsewhere.
Letting different commands run with different uids/gids would be a
nice feature


PermissionsStartOnly=true exists and so you can have helper processes
as root while restrict the main process - anything else is hardly
maintainable with the now clear ini-style of a unit


BTW: add such a firewall rule to a systemd-unit is a *very* bad 
attitude, if it is your personal service in /etc fine, but you must not 
do that anywhere else


ExecStartPost=iptables -I INPUT -p tcp --dport 1521 --syn -j ACCEPT

* who says that it should be reachable from everywhere
* who says it should be reachable on every interface
* who says that not firewalld or shorewall or something else
  does firewall managment on the machine and that this works
  hence in a different environment
* who configures iptables on that machine
* consider what harm are you doing to that person no understanding
  why a port is open while not in the global firewall defined
* even in your personal service it *does not* belog here
  it is called with every restart



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


[systemd-devel] [PATCH] sd-dhcp6-client: fix off-by-two error in DUID length

2014-10-31 Thread Dan Williams
The duid data passed by the caller does not include the DUID type,
but sd_dhcp6_client_set_duid() was treating it like it did.
---
 src/libsystemd-network/sd-dhcp6-client.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libsystemd-network/sd-dhcp6-client.c 
b/src/libsystemd-network/sd-dhcp6-client.c
index fa4f9b5..dbec1a2 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -200,19 +200,19 @@ int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, 
uint16_t type, uint8_t *du
 
 switch (type) {
 case DHCP6_DUID_LLT:
-if (duid_len = sizeof(client-duid.llt))
+if (duid_len = sizeof(client-duid.llt) - 2)
 return -EINVAL;
 break;
 case DHCP6_DUID_EN:
-if (duid_len != sizeof(client-duid.en))
+if (duid_len != sizeof(client-duid.en) - 2)
 return -EINVAL;
 break;
 case DHCP6_DUID_LL:
-if (duid_len = sizeof(client-duid.ll))
+if (duid_len = sizeof(client-duid.ll) - 2)
 return -EINVAL;
 break;
 case DHCP6_DUID_UUID:
-if (duid_len != sizeof(client-duid.uuid))
+if (duid_len != sizeof(client-duid.uuid) - 2)
 return -EINVAL;
 break;
 default:
@@ -222,7 +222,7 @@ int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, 
uint16_t type, uint8_t *du
 
 client-duid.raw.type = htobe16(type);
 memcpy(client-duid.raw.data, duid, duid_len);
-client-duid_len = duid_len;
+client-duid_len = duid_len + 2;  /* +2 for sizeof(type) */
 
 return 0;
 }
-- 
1.9.3


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


[systemd-devel] shutdown

2014-10-31 Thread Tom Deblauwe

Hello,

I'm using systemd, but can't seem to correctly shutdown. I have already:

- checked: reboot -f works
- enabled the debug-shell on vt9

So I was hoping to issue the systemctl list-jobs command from the 
debug shell, however, it didn't allow me to type in commands. The debug 
shell allows me to type something but it is as if the shell is not 
receiving that input. So I can't use the debug shell it seems.


So I decidec to execute journalctl -x -f while the sytem is running, 
and then do reboot. So I only see it gets to log Shutting down. but 
then nothing anymore.


Is there an option to do something similar to journalctl -f but then 
instead with systemctl list-jobs so I can see the reason for the waiting?


Or is my only option remaining to attach a serial cable?

I am using systemd 217.

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


[systemd-devel] Minimal Userland

2014-10-31 Thread Fisher, Charles J. (Top Echelon)
Posting just in case someone finds it of interest.

I did this on Oracle Linux 7.



mkdir /home/nifty
mkdir /home/nifty/bin
cp /your/busybox /home/nifty/bin
cd /home/nifty/bin
ln -s busybox sh
chroot /home/nifty
bin/busybox ls -l
#so far, so good, any system can do this
exit
./busybox --list | awk '{print ln -s busybox  $0}' | sh
mkdir /home/nifty/etc
touch /home/nifty/etc/os-release
cd /home/nifty
ln -s bin sbin
ln -s usr/bin bin
echo 'root::0:0:root:/root:/bin/sh'  /home/nifty/etc/passwd
echo 'console::respawn:/bin/getty 38400 /dev/console'  /home/nifty/etc/inittab
tar cf - /usr/share/zoneinfo | (cd /home/nifty; tar xvpf -)
systemd-nspawn -bD /home/nifty
#login to the new userland you just built
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Luks + lvm in initrd, tracking the issue

2014-10-31 Thread Luca Bruno
I've tracked down the issue a little.

sysroot.mount requires/after dev-vg-lv.device.

System start, dev-vg-lv is inactive.
vgchange -a y - dev-vg-lv active.
vgchange -a n - dev-vg-lv inactive.
At this point, unit-job of dev-vg-lv is NULL (sometimes also happens when
I don't run vgchange, but I still haven't been able to reproduce it).

When sysroot.mount is started, job_is_runnable[1] checks for AFTER
dependencies that have a non-NULL -job currently running. But dev-vg-lv is
inactive, thus sysroot.mount fails to start.

That also means the REQUIRES dependency of sysroot.mount to dev-vg-lv did
not trigger the start the dev-vg-lv.device.

Resuming: dev-vg-lv.device is inactive and has no job running, it's
required/after yet it's not started when sysroot.mount is started.

I have no deep knowledge of systemd internals to propose anything so I'd
appreciate some feedback :)

Best regards,

[1] http://lxr.devzen.net/source/xref/systemd/src/core/job.c#429
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Luks + lvm in initrd, complete scenario

2014-10-31 Thread Luca Bruno
Sorry for the spam. Further tracking down the issue. I think I've come to a
conclusion of the scenario:

S1.service requires/after D.device and S2.service
S1 is activating, thus starts D and S2
S2 starts, which activates D and deactivates D
A can now start because D has no job running [1], but D is not there
anymore.

Will try to create a couple of services to reproduce the problem.

Best regards,

[1] http://lxr.devzen.net/source/xref/systemd/src/core/job.c#429
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel