summaryrefslogtreecommitdiffstats
path: root/lib/sysfs.c
Commit message (Collapse)AuthorAgeFilesLines
* lib/sysfs: make dirent d_type usage more robustKarel Zak2014-03-041-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: fix scanf format string [coverity scan]Karel Zak2014-01-141-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: use O_CLOEXEC in libcommonKarel Zak2013-04-031-6/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: fix hctl buffer usage [coverity scan]Karel Zak2013-03-271-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: cleanup copyright headersKarel Zak2013-01-081-2/+4
| | | | | | | We use the code from include/ and lib/ on many places, so use public domain if possible or LGPL for code copied from libs. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: make readlink() usage more robustKarel Zak2012-10-231-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: add SCSI link functionsKarel Zak2012-10-231-2/+50
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: add functions for SCSI host attributesKarel Zak2012-10-231-0/+52
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/sysfs: add SCSI host:channel:target:lun supportKarel Zak2012-10-231-3/+39
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: fix sysfs_devname_to_devno for dm partitionsPeter Rajnoha2012-09-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Partitions mapped by device-mapper are not like real partitions where there's a /sys/block/<parent>/<name>/dev sysfs path. We need to look at /sys/block/<name>/dev like we do for any other non-partition devices. The mapped partition is not found otherwise. For example, this bug shows up in lsblk while specifying a device on command line while that device is a dm mapping over a partition: $lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 128M 0 disk `-test (dm-0) 253:0 0 128M 0 dm `-test1 (dm-1) 253:1 0 127M 0 part Before this patch: $lsblk /dev/mapper/test1 lsblk: dm-1: unknown device name With this patch: $lsblk /dev/mapper/test1 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT test1 (dm-1) 253:1 0 127M 0 part
* lib/sysfs: more robust sysfs_opendir() [coverity scan]Karel Zak2012-09-071-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: make sysfs_partno_to_devno better readableBernhard Voelker2012-08-141-7/+9
| | | | Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* lib/sysfs; add sysfs_partno_to_devno()Karel Zak2012-08-131-4/+53
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: expect p<N> suffix for partitionsKarel Zak2012-08-131-3/+6
| | | | | | | | | | ... so for example lsblk(8) will see partitioned loop devices loop0 7:0 0 80G 0 loop ├─loop0p1 259:0 0 100M 0 loop └─loop0p2 259:1 0 79.9G 0 loop Signed-off-by: Karel Zak <kzak@redhat.com>
* fix buffer overrun in some calls to sscanfKarel Zak2012-07-091-1/+1
| | | | | Reported-by: Sergei Antonov <saproj@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: use warn_unused_result for sysfs_init()Karel Zak2012-06-211-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: check if cxt->dir_path is NULL in sysfs_readlink()Cong Wang2012-06-211-0/+3
| | | | | | | | cxt->dir_path could be NULL, for example, when sysfs_init() fails, check this before calling readlink()/readlink_at(). Cc: Karel Zak <kzak@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
* sysfs: fix printf format warningsSami Kerola2012-06-111-1/+1
| | | | | | | | | sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned int *', but argument 3 has type 'int *' [-Wformat] sysfs.c:93:3: warning: format '%u' expects argument of type 'unsigned int *', but argument 4 has type 'int *' [-Wformat] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/sysfs: improve sysfs_is_partition_dirent()Karel Zak2012-03-291-2/+22
| | | | | | ... to work with absolute disk device path too. Signed-off-by: Karel Zak <kzak@redhat.com>
* sysfs: move blkid_devno_to_wholedisk to sysfs_devno_to_wholediskMichal Luscon2012-03-271-0/+129
| | | | Signed-off-by: Michal Luscon <mluscon@redhat.com>
* lsblk: add inverse tree support (-s)Peter Rajnoha2012-03-071-2/+3
| | | | | | | | | | | $ lsblk --inverse -o NAME /dev/dm-0 NAME luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e (dm-0) └─sda6 └─sda Signed-off-by: Peter Rajnoha <prajnoha@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: fix sysfs context usageKarel Zak2012-03-061-3/+3
| | | | | Reported-by: Elan Ruusamäe <glen@delfi.ee> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: fix handle leakKarel Zak2012-02-011-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: fix possible fd leak on errorKarel Zak2012-02-011-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: do not attempt to close(0) in sysfs_deinit()Petr Uzel2011-09-131-0/+1
| | | | | | | | | | | If the 'open' fails we 'goto err' which runs 'sysfs_deinit()' on a 'cxt' which hasn't been fully initialised. The 'dir_fd' is still 0, so sysfs_deinit calls "close(0)". Addresses: https://bugzilla.novell.com/show_bug.cgi?id=714151 Reported-by: Diego Ercolani <diego.ercolani@gmail.com> Analysed-by: Neil Brown <nfbrown@suse.com> Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* lib: [sysfs.c] fix compiler warnings [-Wsign-compare]Karel Zak2011-08-011-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sysfs: free used resourcesDavidlohr Bueso2011-07-261-0/+1
| | | | | | | In the sysfs lib example, we should be using sysfs_deinit() to free used resources and for correct usage. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* lib: [sysfs.c] fix double freeKarel Zak2011-05-301-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: cleanup lib/ testsKarel Zak2011-05-251-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [sysfs.c] add sysfs_readlink and name/path functionsKarel Zak2011-05-181-14/+122
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [sysfs.c] make sysfs_read_* function more robustKarel Zak2011-05-181-11/+39
| | | | | | | The functions does not modify result if the requested sysfs attribute does not exist. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: use stuff from sysfs.h and at.hKarel Zak2011-05-161-0/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add generic sysfs utilsKarel Zak2011-05-161-0/+348
Signed-off-by: Karel Zak <kzak@redhat.com>