Commit Graph

5855 Commits

Author SHA1 Message Date
Karel Zak 6498ece0e7 libmount: allow to use propagation flags in fstab
Linux kernel does not allow to change more than one propagation flag
by one mount(2) syscall. The flags also cannot be mixed with another
mount options. It means that the propagation flags cannot be stored in
/etc/fstab, manual "mount --make-* <mountpoint>" is always necessary
after successful mount. Painful...

This patch implements additional mount(2) after previous successful
mount(2) (or exec /sbin/mount.<type>).

For example:

  mount /dev/sda1 /A -o private,unbindable,ro

or fstab entry:

  /dev/sda1   /A  auto  ro,private,unbindable

is implemented by three mount(2) calls:

	- 1st mounts /dev/sda1 with MS_RDONLY
	- 2nd sets MS_PRIVATE flag
        - 3rd sets MS_UNBINDABLE flag.

It's the same as as to manually call:

  mount /dev/sda1 /A -o ro
  mount --make-private /A
  mount --make-unbindable /A

This solution is not atomic, and umount(2) is not called if
propagation flags are not successfully applied, only error is
returned.

This change does not affect libmount API, so one beautiful day when
mount(2) syscall will be improved we can drop this nasty patch.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-15 13:55:29 +01:00
Karel Zak 741587f3e9 kill: add note about threads to the man page
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=846790
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-15 11:18:28 +01:00
Karel Zak 3e373967ec findmnt: make --target usable with bind mounts
The --target <non-mount-point> functionality should be enabled only if
previous regular search found nothing to avoid collisions with bind
mounts, because to detect mountpoint we use traditional child / parent
stat.st_dev comparison which does not work for bind mounts (--bind /A
/A).

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-14 14:50:50 +01:00
Karel Zak 624f2b47c3 findmnt: add PROPAGATION column
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 15:59:16 +01:00
Karel Zak 4b9d67a23d libmount: add mnt_fs_get_propagation()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 15:58:52 +01:00
Karel Zak 9238e0fa33 findmnt: add ID column
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 14:59:39 +01:00
Karel Zak 327ea85a73 findmnt: add OPT-FIELDS column
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 14:58:05 +01:00
Ondrej Oprala e47a19312f libmount: read optional mountinfo fields
[kzak@redhat.com: - rename struct member and functions from
                    "propagation" to "optional fields"
                  - split the original patch
                  - fix parser]

Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 14:52:24 +01:00
Ondrej Oprala 0770effc00 libmount: fix regression test helper
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 14:52:12 +01:00
Karel Zak fba712149c libblkid: make btrfs magics more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 11:40:21 +01:00
Sami Kerola 3a3dcbdc5a build-sys: cleanup --enable-most-builds list
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-10 11:28:13 +01:00
Sami Kerola bc6d983403 build-sys: ignore chkdupexe
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-10 11:26:59 +01:00
Sami Kerola fb26bfaf6b build-sys: add files to distribution
To fix 'make distcheck' compilation.  The fdisks/Makemodule.am has one
new entry 'dos_part_types.h', the rest is about sorting the list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-10 11:26:55 +01:00
Goffredo Baroncelli d4a2764912 libblkid: add support for btrfs backup superblock
Btrfs has three superblock. The first one is placed at 64KB, the second one at
64MB, the third one at 256GB.

If the first superblock is valid except that the "magic field" is zeroed, btrfs
skips the check of the other superblocks.  If the first superblock is fully
invalid, btrfs checks for the other superblock.

So zeroing the first superblock "magic field" at the beginning seems that the
filesystem is wiped. But when the first superblock is overwritten (eg by
another filesystem), then the other two superblock may be considered valid, and
the filesystem may resurrect.

This patch allow to find and wipe the other btrfs superblocks signature.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-10 11:26:48 +01:00
Ondrej Oprala f1107b4a87 hexdump: do not segfault when iterating over an empty format string
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-01-10 11:08:51 +01:00
Ondrej Oprala 701c69617e mount: add support for x-mount.mkdir[=<mode>] option
If the target directory (mountpoint) does not exist then mount(8) will create
it before mount.<type> is executed or mount(2) syscall is called.

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-09 18:52:32 +01:00
Karel Zak fd73f46830 libmount; add recursive mkdir
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-09 18:05:08 +01:00
Karel Zak f3242e065a mount: document x-* options
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-09 15:41:46 +01:00
Richard Tollerton 1707b9b104 mount: Fix -t in listing mode when run as non-root
Presently, libmount-mount completely prohibits the use of -t by non-root
users.  This breaks using -t in listing mode as a user, which represents
a regression against mount-deprecated, macosx and presumably *BSD.

This commit fixes the issue by deferring the mnt_context_is_restricted
check for -t until we know we're not in listing mode.

Signed-off-by: Rich Tollerton <rich.tollerton@ni.com>
2013-01-09 14:47:25 +01:00
Karel Zak b4ee2cacca mkfs.minix: fix compiler warning [-Wformat]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-09 14:44:59 +01:00
Phillip Susi af269d901d libblkid: add missing promise raid metadata locations
There are some additional locations where dmraid can find
and use pdc raid metadata that libblkid was not checking.
2013-01-09 14:42:04 +01:00
Dave Reisner 886330478b mount: document options for debugfs
Since 3.4, debugfs allows uid, gid, and mode options.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2013-01-09 14:42:01 +01:00
Dave Reisner 479d50bd65 build-sys: invert flag for sulogin emergency mount
This should be disabled by default.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2013-01-09 14:41:46 +01:00
Sami Kerola e0b0676988 losetup: fix declarations [smatch scan]
sys-utils/losetup.c:309:2: error: 'for' loop initial declarations are only allowed in C99 mode
sys-utils/losetup.c:374:2: error: 'for' loop initial declarations are only allowed in C99 mode

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:23 +01:00
Sami Kerola d96b743f3f swapon: default to --show if nothing is requested
Proposed-by: Karel Zak <kzak@redhat.com>
References: http://www.spinics.net/lists/util-linux-ng/msg07301.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:21 +01:00
Sami Kerola fce1a34807 ipcs: fix spacing in summary output
Change 56692a6 introduced spacing error to --summary printing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:03 +01:00
Sami Kerola b4ff2f54d7 script: search shell from path, when necessary
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518532
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:01 +01:00
Mike Frysinger 295dd90226 flock: improve usage strings
The current examples miss the best usage of all: specifying the command
and its arguments directly on the command line.  Add that to both the
program usage and the man page.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-09 13:36:58 +01:00
Werner Fink f5664477cb include/ttyutils: add default chardata
this one moves the init_chardata to include/ttyutils.h as well as to
lib/include/ttyutils.c.  Also the macros CTL/CTRL are fixed in
agetty.c and sulogin.c to use the XOR variant CTL.

[kzak@redhat.com: use macro rather than global variable for default
                  chardata]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:42:12 +01:00
Karel Zak 0f23ee0c85 include: cleanup copyright headers
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>
2013-01-08 15:10:17 +01:00
Karel Zak 1a1eb4e188 include/bitopts: Use the operating system byteswapping functions
The swap macros are already in libc.

Co-Author: Cristian Rodríguez <crrodriguez@opensuse.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 14:07:48 +01:00
Karel Zak cd04b26bf8 swapon: print warning about insecure owner/permissions
Let's make it more obvious if swap area is accessible for non-root
users. The old version prints the warning only if --verbose is
specified.

Reported-by: mp.lists@free.fr
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 13:15:52 +01:00
Milan Broz 2adb1a44c2 lsblk: Add write-same attribute to topology info
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-07 18:12:02 +01:00
Neil Horman 4bbe809939 unshare: support the switching of namespaces
In addition to the unshare syscall, there exists the setns syscall, which
allows processes to migrate to the namepsaces of other processes.  Add this
functionality into the unshare command, as they operate in a fairly simmilar
fashion.

Note: There was discussion of adding a path based namespace argument to unshare
in the origional discussion thread, but I opted to leave that out as it didn't
seem to fit in nicely with the current argument pattern.  I figure we can always
add that in later if we need to

[kzak@redhat.com: - fix optional arguments
                  - do not call unshare if no flag specified
                  - use O_CLOEXEC
                  - codding style cleanup]

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-07 14:56:32 +01:00
Karel Zak 91984e938e agetty: replace perms 660 to 620
... the default is root:tty 620

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-02 08:27:32 +01:00
Karel Zak f35336526f build-sys: remove consoles.h
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-27 17:37:27 +01:00
Karel Zak 4226f910d4 sulogin: don't use {de,con}structor attributes
We're not Russian roulette players, so don't use such ugly things at all..

Reported-by:  Dave Reisner <d@falconindy.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23 22:44:05 +01:00
Karel Zak a73f59fa03 sulogin: remove consoles.c from libcommon
- move struct chardata to include/ttyutils.h
- move console.{h,c} to login-utils/sulogin-* (it's sulogin specific)
- fix sulogin and agetty includes

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23 22:14:21 +01:00
Karel Zak 248b8101a0 mkfs.minix: fsck:minix: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 20:01:35 +01:00
Karel Zak f3b1628642 mkswap: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 20:00:11 +01:00
Karel Zak 46d4ce56a7 lslocks: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:57:48 +01:00
Karel Zak 130820a8c8 fdisk: (gpt) fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:55:55 +01:00
Karel Zak 747c1d9d57 setterm: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:55:20 +01:00
Karel Zak 278e7203fa ipcs: fix compiler warnings, use 64bit time
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:52:16 +01:00
Karel Zak 7f89534e6e hwclock: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:51:38 +01:00
Karel Zak 7e88f61717 ipcs: make --human really sexy
Align the "size" columns to the right.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19 15:27:12 +01:00
Karel Zak 45ddc110ac lib/ismounted: improve loopdev support
... to make it usable for situations when the same backing
file is mapped to more loop devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19 14:34:01 +01:00
Karel Zak 1c3f44f7b8 libblkid: improve test_blkid_devno, fix compiler warning [-Wunused-result]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19 12:56:39 +01:00
Karel Zak ca4f6229b0 lib/ismounted: basic support for loop devices
# losetup -a /dev/loop0
 /dev/loop0: [2053]:1048578 (/home/fs-images/filesystems/ext2.img)

 # findmnt /dev/loop0
 TARGET    SOURCE     FSTYPE OPTIONS
 /mnt/test /dev/loop0 ext3   rw,relatime,data=ordered

old version:

 ./test_ismounted /home/fs-images/filesystems/ext2.img
 not mounted

new version:

 ./test_ismounted /home/fs-images/filesystems/ext2.img
 mounted on /mnt/test

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19 12:40:32 +01:00
Karel Zak 06f588f7d1 lib/loopdev: fix loopdev_find_by_backing_file()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19 12:40:19 +01:00