summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* losetup: wait for udevKarel Zak2014-01-241-0/+1
| | | | | | | | | | | | | On system with /dev/lop-control the udevd creates /dev/loopN nodes. It seems better to wait a moment after unsuccessful open(/dev/loopN) and try it to open again. The problem is pretty visible on systems where udevd also modifies permission for loopN devices, then open() fails with EACCES when losetup executed by non-root user (but user who is in "disk" group). Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1045432 Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c.h: prefer nanosleep() over usleep()Karel Zak2014-01-242-8/+17
| | | | | | | | | | | | | | Let's use nanosleep() although if usleep() exists. The nanosleep function does no interact with signals and other timers. The patch introduces xusleep() as replacement to libc (or our fallback) usleep(). Yes, we don't want to use struct timespec + nanosleep() everywhere in code as nano-time resolution is useless for us. The patch also enlarges delays in some busy wait loops. It seems enough to try read/write 4x per second. Signed-off-by: Karel Zak <kzak@redhat.com>
* unshare: Add possibility to add mapping into root user in user namespaceLubomir Rintel2014-01-071-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it very convenient to use make use of privileged actions on CONFIG_USER_NS enabled kernels, without having to manually tinker with uid_map and gid_map to obtain required credentials (as those given upon unshare() vanish with call to execve() and lot of userspace checks for euid==0 anyway). Usage example: $ unshare --uts unshare: unshare failed: Operation not permitted $ unshare --user --uts [nfsnobody@odvarok ~]$ hostname swag hostname: you must be root to change the host name $ unshare -r --uts [root@odvarok util-linux]# hostname swag [root@odvarok util-linux]# [kzak@redhat.com: - move code to map_id() - use all-io.h - add paths to pathnames.h] Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: add path_strdup()Karel Zak2014-01-061-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: update links to http://git.kernel.org/ web repository viewsSami Kerola2013-11-121-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* strutils: add skip_space() functionOndrej Oprala2013-11-081-0/+18
| | | | | | | | [kzak@redhat.com: - add also skip_blank(), - remove duplicate implementation from libmount] Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: Add missing includesMichael Forney2013-10-041-0/+3
| | | | | | | | sys/types.h: For u_char typedef sys/params.h: For MAXNAMLEN sys/ttydefaults.h: For various tty definitions (also add configure check) Signed-off-by: Karel Zak <kzak@redhat.com>
* nologin: add new commandKarel Zak2013-09-301-0/+2
| | | | | | | Currently it's maintained as distro specific (or people use impolite /bin/false way). Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: fix include Makemodule.amKarel Zak2013-09-261-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: add -L to colorize outputKarel Zak2013-09-161-2/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: (bsd) write/read PT code cleanupKarel Zak2013-09-161-3/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: move bsd definitions to pt-bsd.hKarel Zak2013-09-162-0/+160
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: move mbr code to the libraryKarel Zak2013-09-162-0/+106
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: add mbr_get_partition()Karel Zak2013-09-161-0/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: use functions from pt-mbr.hKarel Zak2013-09-161-8/+29
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: rename sys_type to sys_indKarel Zak2013-09-161-1/+1
| | | | | | | This makes struct dos_partition more compatible with the current fdisk code. Signed-off-by: Karel Zak <kzak@redhat.com>
* include/pt-mbr: add functio to store leKarel Zak2013-09-161-0/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: move MBR definitions to include/pt-mbr.hKarel Zak2013-09-161-0/+37
|
* fdisk: (sgi) fix checksum calculationKarel Zak2013-09-161-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: move MBR partition types to include/Karel Zak2013-09-162-0/+107
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: (sgi) cleanup devparams flagsKarel Zak2013-09-161-1/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: (sgi) cleanu sgi_info stuffKarel Zak2013-09-161-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: (sgi) remove magic stringsKarel Zak2013-09-161-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: (sgi) share disk label definition with libblkidKarel Zak2013-09-161-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: move SGI disklabel definitions to include/Karel Zak2013-09-162-0/+91
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: add TT_FL_FREEDATAKarel Zak2013-09-161-3/+5
| | | | | | ... to call free() for line data. Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: add \S to output /etc/os-release dataKarel Zak2013-09-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows to use a new \S or \S{VARNAME} sequence in the /etc/issue file. The sequence prints data from /etc/os-release. The reason is to keep /etc/issue file distribution and release independent. The \S{ANSI_COLOR} is converted to the real terminal escape seq. For example: \S Kernel \r on an \m (\l) or more complex example: Welcome to \S{ANSI_COLOR}\S{NAME}0m \S{VERSION} Report bugs at \S{BUG_REPORT_URL}. See http://www.freedesktop.org/software/systemd/man/os-release.html fr more details about /etc/issue. Based on patch from Bill Nottingham <notting@redhat.com>. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add crc64()Karel Zak2013-09-113-0/+11
| | | | | | Based on bcache code from Rolf Fokkens. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: rename time-util.c to timeutils.c, fix headersKarel Zak2013-09-102-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: optimalize {starts,ends}with()Karel Zak2013-09-101-3/+40
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: move *swith() functions to private librarySami Kerola2013-08-291-0/+4
| | | | | | | | Avoid code dublication in libmount and time-util. Proposed-by: Karel Zak <kzak@redhat.com> Reference: http://markmail.org/message/h7zexvqsieqngtmx Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/time-util: copy time parsing functions from systemdSami Kerola2013-08-292-0/+56
| | | | | | | | The functions are copied nearly as-is. Coding style has been modified to match with util-linux project, while the functionality remains untouched. CC: Lennart Poettering <lennart@poettering.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: carefulput: print determined char when unprintable char is foundSami Kerola2013-08-231-2/+2
| | | | | | This is done to allow reuse of the functin in last(1). Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* losetup: use loop-control to explicitly ask for deviceKarel Zak2013-08-061-0/+1
| | | | | | | | | | | | | | | | Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example losetup -f foo.img Unfortunately, losetup(8) allows to ask for specified device losetup /dev/loop100 foo.img and in this case we assume that the device already exists in the system. This is incorrect, we should be able to use loop-control LOOP_CTL_ADD ioctl to ask for the specified device. Signed-off-by: Karel Zak <kzak@redhat.com>
* include/xalloc: add warn_unused_result to allocation functionsKarel Zak2013-07-092-5/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: don't remove ECHOCTL from c_lflagKarel Zak2013-06-031-4/+2Star
| | | | | | | | It's really unexpected that arrows keys move cursor when agetty/login asks for login name or password. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=969458 Signed-off-by: Karel Zak <kzak@redhat.com>
* lscpu: detect more hypervisor vendorsOndrej Oprala2013-05-201-0/+2
| | | | | | | | [kzak@redhat.com: - cleanup coding style, - use path_exist()] Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: don't hardcode terminal fd in get_terminal_name()Karel Zak2013-05-131-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: add colormode_or_err()Karel Zak2013-05-071-0/+1
| | | | | | ... to make the code easy to use in utils. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: add support for auto, always and never modesKarel Zak2013-05-061-1/+12
| | | | | | ... to implement --color[=<when>] Signed-off-by: Karel Zak <kzak@redhat.com>
* include: add close_fd() for noticing write errors before close()Sami Kerola2013-04-261-0/+19
| | | | | | | | | | | Essentially this helper function is similar to close_stream(), but for file descriptors. When a file descriptors are close()'d status of write is often overlooked. The close_fd() will try to determine what happen to writes with fsync() before closing the file descriptor. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: fix SYS_{unshare,nsenter} usageKarel Zak2013-04-171-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: arch independent minix detectionKarel Zak2013-04-151-3/+6
| | | | | | | It seems that on-disk MINIX FS superblock is native-endian. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=833841 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/xalloc: add xstrndup()Karel Zak2013-04-101-0/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* loopdev: sync capacity after setting itJeff Mahoney2013-04-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* include/fileutils: use O_CLOEXEC for mktemp stuffKarel Zak2013-04-031-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: add macro UL_CLOEXECSTRKarel Zak2013-04-031-0/+8
| | | | | | ... to make "e" for fopen() portable to systems without O_CLOEXEC. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/xalloc: fix mamory leak in xgethostname() [coverity scan]Karel Zak2013-03-271-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/pathnames: rename _PATH_ADJPATH to _PATH_ADJTIMEKarel Zak2013-03-261-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: arch is gone, use delpart as usage() function exampleSami Kerola2013-03-261-1/+1
| | | | | | The arch.c was removed in commit 27abd809. Signed-off-by: Sami Kerola <kerolasa@iki.fi>