From: Leonid Krivoshein <klark.devel@gmail.com>
To: devel@lists.altlinux.org
Subject: Re: [devel] udevless информация о блочных устройствах
Date: Sun, 16 Jun 2019 00:40:46 +0300
Message-ID: <64b93087-47cb-11fc-adf0-ec662e38afe1@gmail.com> (raw)
In-Reply-To: <5ce6f6cb-01ec-1270-8f1d-215ce7148f0f@gmail.com>
Сам же себе и отвечу:
15.06.2019 19:53, Leonid Krivoshein пишет:
> [...] Раньше я так и делал, получая часть информации через sysfs, а
> другую часть -- через blkid, blockdev, итп, на что требуется root.
> Поэтому и озадачился сабжем. Хотелось бы написать основной код,
> работающий без рутовых привилегий. Но вопрос в том, возможно ли это на
> системах без udev.
>
Никто эти файлы напрямую не парсит. В сишном коде используются:
1) libudev (при HAVE_LIBUDEV), в основном:
udev_device_new_from_subsystem_sysname() и udev_device_get_property_value(),
2) а в качестве fallback -- libblkid, в основном:
blkid_new_probe_from_filename() и blkid_probe_lookup_value().
При этом, для второго варианта сначала проверяется: getuid() == 0.
Для меня это значит два варианта решения: забить на тех, "кто ходит без
костылей" (не использует udev), ибо их единицы, либо написать для них
такой код, который будет выполняться с привилегиями root.
--
Best regards,
Leonid Krivoshein.
next prev parent reply other threads:[~2019-06-15 21:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-15 15:23 Leonid Krivoshein
2019-06-15 15:48 ` Alexey V. Vissarionov
2019-06-15 16:44 ` Leonid Krivoshein
2019-06-15 16:29 ` Alexey Gladkov
2019-06-15 16:53 ` Leonid Krivoshein
2019-06-15 21:40 ` Leonid Krivoshein [this message]
2019-06-16 12:10 ` Alexey Gladkov
2019-06-16 18:00 ` Leonid Krivoshein
2019-06-17 8:25 ` Alexey Gladkov
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=64b93087-47cb-11fc-adf0-ec662e38afe1@gmail.com \
--to=klark.devel@gmail.com \
--cc=devel@lists.altlinux.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
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git