summaryrefslogtreecommitdiffstats
path: root/lib/blkdev.c
Commit message (Collapse)AuthorAgeFilesLines
* lib/blkdev: remove support for Linux < 2.6Ruediger Meier2017-06-291-11/+2Star
| | | | | | Remove a hack for kernels between 2.4.15 and 2.4.17 Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: use unique ifdefs for testsKarel Zak2017-01-041-1/+1
| | | | | | | Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more robust. Signed-off-by: Karel Zak <kzak@redhat.com>
* blkdev: guard against missing DIOCGDINFO on FreeBSD 11Franco Fichtner2016-08-111-2/+2
| | | | | DIOCGMEDIASIZE is supported and available since FreeBSD 5, it may make sense to kill the backwards-glue completely instead.
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* misc: fix some includesRuediger Meier2016-02-291-3/+0Star
| | | | | | | | | features.h: any glibc header includes this already libgen.h: was unused there sys/uio.h: for writev(3p) sys/queue.h seems like it was never used Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: remove unused variableRuediger Meier2016-02-181-1/+0Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib: fix unused parameters and variablesRuediger Meier2016-02-111-9/+24
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib/blkdev: add open_blkdev_or_file() functionSami Kerola2015-11-221-0/+24
| | | | | | | | | Purpose of this function is to open a path that is potentially pointing to a block device or file without races. The function also proper open(3) flags are used to check the device is not busy, and finally warning is been printed if a block device happens to be misaligned. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/blkdev: use 64-bit to count size in bytesKarel Zak2015-08-051-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: fix make checkincludes warningsSami Kerola2015-01-071-8/+4Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/blkdev: report correct disk size on GNU/kFreeBSD. Thanks Tuco.Robert Millan2014-09-171-0/+4
| | | | Addresses-Debian-Bug: 592292
* loopdev: sync capacity after setting itJeff Mahoney2013-04-091-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I recently tried to mount an hfsplus file system from an image file with a partition table by using the loop offset and sizelimit options to specify the location of the file system. hfsplus stores some metadata at a set offset from the end of the partition, so it's sensitive to the device size reported by the kernel. It worked with this: But failed with this: /dev/loop0: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000 /dev/loop1: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000 /proc/partitions shows the correct number of blocks to match the sizelimit. But if I set a breakpoint in mount before the mount syscall, I could see: 102400000 102432768 The kernel loop driver will set the gendisk capacity of the device at LOOP_SET_STATUS64 but won't sync it to the block device until one of two conditions are met: All open file descriptors referring to the device are closed (and it will sync when re-opened) or if the LOOP_SET_CAPACITY ioctl is called to sync it. Since mount opens the device and passes it directly to the mount syscall after LOOP_SET_STATUS64 without closing and reopening it, the sizelimit argument is effectively ignroed. The capacity needs to be synced immediately for it to work as expected. This patch adds the LOOP_SET_CAPACITY call to loopctx_setup_device since the device isn't yet released to the user, so it's safe to sync the capacity immediately. [kzak@redhat.com: - port to the current git HEAD, - use uint64_t] Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: use O_CLOEXEC in libcommonKarel Zak2013-04-031-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include: cleanup copyright headersKarel Zak2013-01-081-1/+6
| | | | | | | 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>
* lib/blkdev: return static strings by blkdev_scsi_type_to_name()Karel Zak2012-06-151-22/+19Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* blkdev: add blkdev_scsi_type_to_name()Sami Kerola2012-06-111-1/+47
| | | | | | | | Add a function, and necessary symbols, to convert scsi type id's to name strings. Reference: http://permalink.gmane.org/gmane.linux.utilities.util-linux-ng/5994 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/blkdev: fix compiler warning [-Wreturn-type]Karel Zak2012-04-101-1/+3
| | | | | | | ../lib/blkdev.c: In function ‘blkdev_get_geometry’: ../lib/blkdev.c:287:1: warning: control reaches end of non-void function [-Wreturn-type] Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: move kernel geometry into blkdevDavidlohr Bueso2012-04-101-0/+23
| | | | | | This is a more generic place for this ioctl. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* blkdev: add is_blkdev functionDavidlohr Bueso2012-01-051-0/+6
| | | | | | We should have the most basic of checks in this library to see whether or not a block device is being used. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* fdisk: use CDROM_GET_CAPABILITY ioctlDavidlohr Bueso2012-01-021-0/+13
| | | | | | And replace the current archaic logic of is_ide_cdrom_or_tape(). Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* lib: [blkdev.c] remove kernel version check from blkdev_get_sector_size()Karel Zak2011-06-271-10/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [blkdev.c] more robust blkdev_is_misaligned()Karel Zak2011-06-271-1/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: [blkdev.c] add blkdev_get_physector_size()Davidlohr Bueso2011-06-271-4/+33
| | | | | | | | This function uses the BLKPBSZGET ioctl to get the physical block size of the device. Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: hurd build fixesSamuel Thibault2011-06-201-0/+4
| | | | | | | | | | | | * Make blkdev_is_misaligned return 0 when BLKALIGNOFF is not available. * Make procutils.c include c.h to get a PATH_MAX replacement. * Provide agetty.c USE_SYSLOG, DEFAULT_VCTERM and DEFAULT_STERM defaults for Hurd. * Make agetty.c only deal with OFDEL, XCASE and VSWTCH if they are available. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* blkdev: add blkdev_is_misaligned()Davidlohr Bueso2011-04-121-0/+12
| | | | | | | | | | This functions returns the status of the device's alignment. It will be 0 when aligned, otherwise return the offset. [kzak@redhat.com: - returns 0 if the ioctl failed] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+1
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* lib: fix syntax error in blkdev.cKarel Zak2010-08-231-1/+1
| | | | | Reported-by: Tuco <tuco.xyz@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: fix blkdev_find_size()Karel Zak2010-03-161-4/+16
| | | | | | | | | | | | | | echo l | fdisk/fdisk /dev/zero FYI that however now spins forever doing: offset=3074457345618258603) at ../lib/blkdev.c:31 at ../lib/blkdev.c:151 at ../lib/blkdev.c:161 Reported-by: Pádraig Brady <P@draigBrady.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: avoid compilation failure on rawhideJim Meyering2010-03-161-0/+1
| | | | * lib/blkdev.c: Include <sys/stat.h>, for use of S_ISREG.
* lib: use fstat() as fallback in blkdev_get_size()Karel Zak2010-03-111-0/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* liblkid: move getsize.c code to lib/Karel Zak2010-03-101-8/+79
| | | | | | .. and cleanup blkdev_get_size() usage in libblkid. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: use BLKSSZGET for GPT sectorsKarel Zak2009-10-221-1/+5
| | | | | | | | | | | | | | The current implementation uses fixed sector size (512 bytes), that's wrong. UEFI standard requires real logical sector size -- it means BLKSSZGET for Linux. The size of GPT header is not static, but whole sector is allocated for the header. In theory the HeaderSize field could be greater than sizeof(struct gpt_header). It means we have to read whole sector with the header, because the header crc32 checksum is counted according to HeaderSize. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add test_ismounted for regression testKarel Zak2009-02-181-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: blkdev.c clean up, non-linux supportSamuel Thibault2008-07-241-8/+59
| | | | | | | [kzak@redhat.com: split the original patch to small patches] Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add blkdev.{c,h}Stefan Krah2007-11-071-0/+93
Now we duplicate BLK* ioctls on many places... This patch also fix BLKGETSIZE64 usage in dependence on kernel version. Co-Author: Karel Zak <kzak@redhat.com> Signed-off-by: Stefan Krah <stefan@bytereef.org> Signed-off-by: Karel Zak <kzak@redhat.com>