1. 30 Apr, 2013 1 commit
  2. 25 Apr, 2013 1 commit
  3. 19 Apr, 2013 2 commits
    • Zbigniew Jędrzejewski-Szmek's avatar
    • Harald Hoyer's avatar
      Reintroduce f_type comparison macro · bdd29249
      Harald Hoyer authored
      This reverts commit 4826f0b7.
      Because statfs.t_type can be int on some architecures, we have to cast
      the const magic to the type, otherwise the compiler warns about
      signed/unsigned comparison, because the magic can be 32 bit unsigned.
      statfs(2) man page is also wrong on some systems, because
      f_type is not __SWORD_TYPE on some architecures.
      The following program:
      int main(int argc, char**argv)
              struct statfs s;
              statfs(argv[1], &s);
      	printf("sizeof(f_type) = %d\n", sizeof(s.f_type));
      	printf("sizeof(__SWORD_TYPE) = %d\n", sizeof(__SWORD_TYPE));
      	printf("sizeof(long) = %d\n", sizeof(long));
      	printf("sizeof(int) = %d\n", sizeof(int));
      	if (sizeof(s.f_type) == sizeof(int)) {
      		printf("f_type = 0x%x\n", s.f_type);
      	} else {
                      printf("f_type = 0x%lx\n", s.f_type);
              return 0;
      executed on s390x gives for a btrfs:
      sizeof(f_type) = 4
      sizeof(__SWORD_TYPE) = 8
      sizeof(long) = 8
      sizeof(int) = 4
      f_type = 0x9123683e
  4. 18 Apr, 2013 4 commits
    • Harald Hoyer's avatar
      Revert f_type fixups · 4826f0b7
      Harald Hoyer authored
      This reverts commit a858b64d.
      This reverts commit aea275c4.
      This reverts commit fc6e6d24.
      This reverts commit c4073a27.
      This reverts commit cddf1480.
      This reverts commit 8c68a701.
      The constants are now casted to __SWORD_TYPE, which should resolve the
      compiler warnings about signed vs unsigned.
      After talking to Kay, we concluded:
      This should be fixed in the kernel, not worked around in userspace tools.
      Architectures cannot use int and expect magic constants lager than INT_MAX
      to work correctly. The kernel header needs to be fixed.
      Even coreutils cannot handle it:
        #define RAMFS_MAGIC  0x858458f6
        # stat -f -c%t /
        #define BTRFS_SUPER_MAGIC 0x9123683E
        # stat -f -c%t /mnt
      Although I found the perfect working macro to fix the thing :)
              __extension__ ({                                                \
                              bool _ret = false;                              \
                              switch(f) { case c: _ret=true; };               \
                              ( _ret );                                       \
    • Harald Hoyer's avatar
    • Harald Hoyer's avatar
      rename CMP_F_TYPE to F_TYPE_CMP · aea275c4
      Harald Hoyer authored
    • Harald Hoyer's avatar
      Add ugly CMP_F_TYPE() macro · fc6e6d24
      Harald Hoyer authored
      On some architectures (like s390x) the kernel has the type int for
      f_type, but long in userspace.
      Assigning the 32 bit magic constants from linux/magic.h to the 31 bit
      signed f_type in the kernel, causes f_type to be negative for some
      glibc extends the int to long for those architecures in 64 bit mode, so
      the negative int becomes a negative long, which cannot be simply
      compared to the original magic constant, because the compiler would
      automatically cast the constant to long.
      To workaround this issue, we also compare to the (int)MAGIC value in a
      macro. Of course, we could do #ifdef with the architecure, but it has to
      be maintained, and the magic constants are 32 bit anyway.
      Someday, when the int is unsigned or long for all architectures, we can
      remove this macro again. Until then, keep it as simple as it can be.
  5. 17 Apr, 2013 3 commits
  6. 16 Apr, 2013 3 commits
  7. 15 Apr, 2013 1 commit
  8. 11 Apr, 2013 1 commit
    • Zbigniew Jędrzejewski-Szmek's avatar
      errno is positive · bcb161b0
      Zbigniew Jędrzejewski-Szmek authored
      Make sure we compare errno against positive error codes.
      The ones in hwclock.c and install.c can have an impact, the
      rest are unlikely to be hit or in code that isn't widely
      Also check that errno > 0, to help gcc know that we are
      returning a negative error code.
  9. 08 Apr, 2013 2 commits
    • Lennart Poettering's avatar
    • Holger Hans Peter Freyther's avatar
      util: Avoid memory allocations for formatting paths · ab7d9b67
      Holger Hans Peter Freyther authored
      Avoid memory allocations to construct the path for files in the
      procfs. The procfs paths are way shorter than the PATH_MAX so we
      can use snprintf on a string located on the stack. This shows up
      as a win on x86 using the benchmark program below.
      $ make libsystemd-shared.la; gcc -O2 -Isrc/systemd/ -Isrc/ \
      	-o simple-perf-test simple-perf-test.c \
      	.libs/libsystemd-shared.a  -lrt
       #include "shared/util.h"
      void test_once(void) {
      	pid_t pid = getpid();
      	char *tmp = NULL;
      	get_process_comm(pid, &tmp);
      	tmp = NULL;
      	get_process_cmdline(pid, 0, 1, &tmp);
      	tmp = NULL;
      	get_process_exe(pid, &tmp);
      int main(int argc, char **argv)
      	int i;
      	for (i = 0; i < 50000; ++i)
  10. 05 Apr, 2013 2 commits
    • Zbigniew Jędrzejewski-Szmek's avatar
      Add _cleanup_globfree_ · c84a9488
      Zbigniew Jędrzejewski-Szmek authored
      Fixes a memleak in error path in exec_context_load_environment.
    • Zbigniew Jędrzejewski-Szmek's avatar
      Use initalization instead of explicit zeroing · b92bea5d
      Zbigniew Jędrzejewski-Szmek authored
      Before, we would initialize many fields twice: first
      by filling the structure with zeros, and then a second
      time with the real values. We can let the compiler do
      the job for us, avoiding one copy.
      A downside of this patch is that text gets slightly
      bigger. This is because all zero() calls are effectively
      $ size build/.libs/systemd
               text    data     bss     dec     hex filename
      before 897737  107300    2560 1007597   f5fed build/.libs/systemd
      after  897873  107300    2560 1007733   f6075 build/.libs/systemd
      … actually less than 1‰.
      A few asserts that the parameter is not null had to be removed. I
      don't think this changes much, because first, it is quite unlikely
      for the assert to fail, and second, an immediate SEGV is almost as
      good as an assert.
  11. 04 Apr, 2013 1 commit
  12. 02 Apr, 2013 3 commits
  13. 31 Mar, 2013 2 commits
  14. 30 Mar, 2013 1 commit
  15. 29 Mar, 2013 2 commits
    • Zbigniew Jędrzejewski-Szmek's avatar
      Always use errno > 0 to help gcc · 8333c77e
      Zbigniew Jędrzejewski-Szmek authored
      gcc thinks that errno might be negative, and functions could return
      something positive on error (-errno). Should not matter in practice,
      but makes an -O4 build much quieter.
    • Zbigniew Jędrzejewski-Szmek's avatar
      catalog: open up catalog internals · 844ec79b
      Zbigniew Jędrzejewski-Szmek authored
      In order to write tests for the catalog functions, they
      are made non-static and start taking a 'database' parameter,
      which is the name of a file with the preprocessed catalog
      This makes it possible to make test-catalog part of the
      normal test suite, since it now only operates on files
      in /tmp.
      Some more tests are added.
  16. 27 Mar, 2013 2 commits
    • Václav Pavlín's avatar
      shared: free dt (temporary dir name) on fail · f36a783c
      Václav Pavlín authored
      [zj: modified to not to try to rmdir() dir we haven't created.]
    • Zbigniew Jędrzejewski-Szmek's avatar
      Simplify the meaning of %s · 3baed193
      Zbigniew Jędrzejewski-Szmek authored
      The rules governing %s where just too complicated. First of
      all, looking at $SHELL is dangerous. For systemd --system,
      it usually wouldn't be set. But it could be set if the admin
      first started a debug shell, let's say /sbin/sash, and then
      launched systemd from it. This shouldn't influence how daemons
      are started later on, so is better ignored. Similar reasoning
      holds for session mode. Some shells set $SHELL, while other
      set it only when it wasn't set previously (e.g. zsh). This
      results in fragility that is better avoided by ignoring $SHELL
      With $SHELL out of the way, simplify things by saying that
      %s==/bin/sh for root, and the configured shell otherwise.
      get_shell() is the only caller, so it can be inlined.
      Fixes one issue seen with 'make check'.
  17. 25 Mar, 2013 1 commit
  18. 22 Mar, 2013 3 commits
  19. 20 Mar, 2013 4 commits
  20. 16 Mar, 2013 1 commit
    • Michal Sekletar's avatar
      core: reuse the same /tmp, /var/tmp and inaccessible dir · c17ec25e
      Michal Sekletar authored
      All Execs within the service, will get mounted the same
      /tmp and /var/tmp directories, if service is configured with
      PrivateTmp=yes. Temporary directories are cleaned up by service
      itself in addition to systemd-tmpfiles. Directory which is mounted
      as inaccessible is created at runtime in /run/systemd.