util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ruediger Meier <sweet_f_a@gmx.de>
To: util-linux@vger.kernel.org
Subject: Re: [PATCH 0/6] lib/path.c and lib/sys.c are friends (patches FOR TESTING ONLY)
Date: Mon, 3 Jul 2017 14:02:56 +0200	[thread overview]
Message-ID: <201707031402.56099.sweet_f_a@gmx.de> (raw)
In-Reply-To: <1499082781-16968-1-git-send-email-sweet_f_a@gmx.de>

BTW this is also available via github.

branch "path"
https://github.com/rudimeier/util-linux

On Monday 03 July 2017, Ruediger Meier wrote:
> From: Ruediger Meier <ruediger.meier@ga-group.nl>
>
> Karel Zak wrote on github:
> > BTW, see Documentation/TODO .
> >
> > .. lib/path.c and lib/sys.c should be friends and they need our
> > love :-)
> >
> > For lib/path.c should be probably nice to have handler, so we can
> > use *at() functions rather than compose paths for each request.
>
> Hi,
>
> I've put this this trivial but non-dangerous solution together.
> Using openat(), no cleanup yet, just to see how it looks.
>
> See
>  test_sysfs: usage: ./test_sysfs <sysroot> <devname>
>                                    ^^^^^
>
> and compare (maybe with stace)
>
>  $ ln -s  /  /tmp/sysroot
>  $ ./test_sysfs /tmp/sysroot /dev/sda
>  $ ./test_sysfs / /dev/sda
>  $ ./test_sysfs "" /dev/sda
>
> Note if sysroot is empty or not set at all, then the dirfd is ignored
> in all openat() functions. Thus in the default case shouldn't be any
> risk that the changes in path.c and sysfs.c can break anything. In
> theory we could use path_open() and friends system wide instead if
> open(). For now I've added some asserts to make sure that we are
> using path.h with absolute paths only.
>
> For the fun I've added option --sysroot to zramctl and lsblk. Don't
> know if it's useful yet. The strace of lsblk looks like that we
> should use path_open() functions at more places within libblkid.
>
> So everybody is invited to create some "sysroot" tests like we have
> for lsmem and lsblk already. Lets see whether if we can use this for
> something good.
>
> cu,
> Rudi
>
> Ruediger Meier (6):
>   path: use openat()
>   path: add some standard functions
>   path: never create path with prefix
>   sysfs: use path.h
>   zramctl: add --sysroot
>   lsblk: add --sysroot
>
>  include/path.h      |  15 ++++++
>  lib/path.c          | 152
> +++++++++++++++++++++++++++++++++++++++++++++------- lib/sysfs.c     
>    |  53 +++++++++++-------
>  misc-utils/lsblk.c  |  21 ++++++--
>  sys-utils/lscpu.c   |   5 +-
>  sys-utils/lsmem.c   |  11 ++--
>  sys-utils/zramctl.c |  13 ++++-
>  7 files changed, 214 insertions(+), 56 deletions(-)

      parent reply	other threads:[~2017-07-03 12:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-03 11:52 [PATCH 0/6] lib/path.c and lib/sys.c are friends (patches FOR TESTING ONLY) Ruediger Meier
2017-07-03 11:52 ` [PATCH 1/6] path: use openat() Ruediger Meier
2017-07-03 14:39   ` Karel Zak
2017-07-03 14:52     ` Karel Zak
2017-07-03 16:11       ` Ruediger Meier
2017-07-04  8:10         ` Karel Zak
2017-07-03 11:52 ` [PATCH 2/6] path: add some standard functions Ruediger Meier
2017-07-03 14:29   ` Karel Zak
2017-07-03 11:52 ` [PATCH 3/6] path: never create path with prefix Ruediger Meier
2017-07-03 11:52 ` [PATCH 4/6] sysfs: use path.h Ruediger Meier
2017-07-03 11:53 ` [PATCH 5/6] zramctl: add --sysroot Ruediger Meier
2017-07-03 11:53 ` [PATCH 6/6] lsblk: " Ruediger Meier
2017-07-03 12:02 ` Ruediger Meier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201707031402.56099.sweet_f_a@gmx.de \
    --to=sweet_f_a@gmx.de \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).