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.
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.
Sami Kerola [Fri, 28 Dec 2012 21:23:43 +0000 (21:23 +0000)]
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
Sami Kerola [Fri, 28 Dec 2012 21:23:42 +0000 (21:23 +0000)]
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>
Mike Frysinger [Wed, 26 Dec 2012 20:10:29 +0000 (15:10 -0500)]
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.
Werner Fink [Tue, 8 Jan 2013 14:38:40 +0000 (15:38 +0100)]
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>
Neil Horman [Fri, 28 Dec 2012 16:22:18 +0000 (11:22 -0500)]
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>
Sami Kerola [Sun, 16 Dec 2012 10:43:51 +0000 (10:43 +0000)]
ipcs: add --human readable size conversion option
Introduces new function ipc_print_size() which will call
size_to_human_string(), and handles the occasional '([k]bytes)' printing
if default size format is requested.
Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Werner Fink [Mon, 10 Dec 2012 12:27:11 +0000 (13:27 +0100)]
sulogin: add multi console feature from SysVinit sulogin
Now after adding Conflicts=rescue.service to getty@.service and
serial-getty@.service and Conflicts=getty.target to rescue.target
all works with `systemctl rescue'. Even adding init=/sbin/sulogin
to the kernels command line by using the `e' key in grub2 boot
menu works flawless.
This version is without the emergency code as I've this moved to
lib/console.c where it belongs to.
Werner Fink [Mon, 10 Dec 2012 12:27:10 +0000 (13:27 +0100)]
sulogin: mount temporary /dev and /proc if not found
This is very usefull if initrd can not loaded that is no /dev and no
/proc is found. Also if the /etc/shadow and /etc/passwd is copied into
the initrd the sulogin can be used in initrd even before /dev and/or /proc
are mounted.
Karel Zak [Wed, 12 Dec 2012 09:36:32 +0000 (10:36 +0100)]
chfn: clean up exit status
The old version in some cases (but not always) returns -1 (255) on
error. It seems better to cleanup the code and don't return internal
return codes by exit().
Bernhard Voelker [Fri, 30 Nov 2012 16:12:12 +0000 (17:12 +0100)]
libmount: avoid endless loop in mnt_get_kernel_cmdline_option
The above function infloops when the name to search for can only
be found at the beginning of /proc/cmdline but doesn't match,
e.g. when searching for "ro" in "root=/dev/sda1 quiet vga=0x31a".
* libmount/src/utils.c (mnt_get_kernel_cmdline_option): Replace
while by for loop to ensure the pointer p is incremented.
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
Karel Zak [Tue, 4 Dec 2012 10:58:13 +0000 (11:58 +0100)]
libblkid: cleanup nonnull attribute usage
- don't mix __attribute__((nonnull)) and "if (!argument) return" for
the same function. The "if ()" check will be *silently* optimized
out by gcc.
- use __attribute__((nonnull)) for functions where is impossible to
return error code. For example "is" and "has" functions or functions
where we return unsigned types and zero is a valid value.
Karel Zak [Mon, 3 Dec 2012 14:32:16 +0000 (15:32 +0100)]
fdisk: remove global variable sector_offset
- add cxt->first_lba as replacement to sector_offset
- add label->reset_alignment() to overwrite the default alignment setting
- add fdisk_reset_alignment() to setup grain, first LBA offset, etc.