Commit Graph

5059 Commits

Author SHA1 Message Date
Karel Zak 1425948c8c uuidd: move from /var/run/uuidd to /run/uuidd
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-18 15:46:20 +02:00
Karel Zak 949b61c2b2 libuuid: move clock.txt path to header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-18 15:36:00 +02:00
Davidlohr Bueso 7cfd1b2643 partx: use -s option for default output
It's been around a year and a half now that partx was rewritten,
and the legacy output should no longer be default.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-15 13:21:25 +02:00
Karel Zak 2fc4a256ce lib/blkdev: return static strings by blkdev_scsi_type_to_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:14:30 +02:00
Karel Zak 9d738ff822 lsblk: use fallback for TYPE
... bug introduced by 1edd8af70b

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:13:40 +02:00
Karel Zak aa323539cf include/blkdev: cleanup up
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:01:51 +02:00
Karel Zak d5f9b6e5fb Merge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit:
  lsblk: use blkdev_scsi_type_to_name()
  blkdev: add blkdev_scsi_type_to_name()
  wipefs: use symbolic value for markup mode
  eject: inform if CD-ROM drive is not ready
  docs: clean up partx.8 manual
  include: fix void pointer arithmetics warnings
  sysfs: fix printf format warnings
  build: fix unused parameter warnings
  build: fix redundant redeclaration warnings
  include: fix spurious list.h warnings
  uuidd: use output redirection which works [checkbashisms]
  blkid: fix realloc memory leak [cppcheck]
  setarch: do not use -1 as array index [cppcheck]
2012-06-15 12:44:17 +02:00
Karel Zak 9d670a2ab4 libmount: make some string operations more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 12:26:05 +02:00
Petr Uzel 3cbc5a9559 libmount: fix trivial typos
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-06-15 11:52:13 +02:00
Petr Uzel bf15afd1e7 libmount: fix read before allocated buffer
valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== Invalid read of size 1
==21359==    at 0x415AC6: mnt_optstr_remove_option_at (optstr.c:310)
==21359==    by 0x416358: mnt_optstr_apply_flags (optstr.c:716)
==21359==    by 0x40DFBF: mnt_context_prepare_mount (context_mount.c:86)
==21359==    by 0x40EB5A: mnt_context_mount (context_mount.c:782)
==21359==    by 0x4058B0: main (mount.c:918)
==21359==  Address 0x51cd5bf is 1 bytes before a block of size 10 alloc'd
==21359==    at 0x4C297CD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359==    by 0x4C29957: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359==    by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359==    by 0x412822: mnt_fs_append_options (fs.c:764)
==21359==    by 0x409288: mnt_context_append_options (context.c:733)
==21359==    by 0x4053F0: main (mount.c:776)

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-06-15 11:52:10 +02:00
Petr Uzel 31821efc29 libmount: plug a memory leak in exec_helper()
valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== 28 bytes in 1 blocks are definitely lost in loss record 1 of 1
==21359==    at 0x4C298B2: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359==    by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359==    by 0x415CB5: mnt_optstr_set_option (optstr.c:387)
==21359==    by 0x40D778: do_mount (context_mount.c:192)
==21359==    by 0x40E6A9: mnt_context_do_mount (context_mount.c:685)
==21359==    by 0x40EB7B: mnt_context_mount (context_mount.c:786)
==21359==    by 0x4058B0: main (mount.c:918)

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-06-15 11:52:05 +02:00
Milan Broz 31550e7001 libblkid: update dm-verity scan
New superblock now contains UUID. Old version is not going to be used.

Signed-off-by: Milan Broz <mbroz@redhat.com>
2012-06-15 11:52:00 +02:00
Bernhard Voelker b4479ffaa8 setsid: fix off-by-one error in execvp call
Bug introduced during --ctty implementation by v2.21-112-g8a2f04d.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-06-15 11:42:43 +02:00
Bernhard Voelker f5caaf39d2 su: remove unimplemented options -u and -v
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-06-15 11:18:08 +02:00
Jan \"Yenya\" Kasprzak 827b1ceefd flock: user-configurable exit code
When locking the file fails with -n or -w option, caller has no way
to distinguish between the exit code 1 of the -c command,
and the exit code 1 of flock(1) caused by the conflicting lock.

Add a new -E <exitcode> (--conflict-exit-code) option to set
the exit code for the case of locking failure to any value.
2012-06-15 11:12:06 +02:00
Karel Zak e26de525e2 mount: (new) allow sloppy for non-root
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=825836
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-14 14:43:21 +02:00
Karel Zak e90e7401d0 libmount: don't use nosuid,noexec,nodev for cifs user=foo
mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux

is incorrectly translated to

   mount.cifs -o noexec,nosuid,nodev,user=root,password=linux ...

The command mount(8) should be sensitive to "user" (without "=<name>")
only. The correct cifs command line is:

   mount.cifs -o user=root,password=linux

Addresses: https://bugzilla.novell.com/show_bug.cgi?id=766157
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-14 14:19:26 +02:00
Karel Zak 6b741564d8 libmount: don't generate empty option strings
mount -t foo something /mnt/test -o user=root,password=linux

generates

 "rw,noexec,nosuid,nodev,password=linux,,user=root"

options string for /sbin/mount.foo, the ",," is incorrect.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-14 11:38:53 +02:00
Karel Zak 8cd48d67f4 eject: cleanup umount code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-13 15:58:16 +02:00
Karel Zak 8388bbb3df eject: don't try to use non-device path
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-13 13:55:49 +02:00
Karel Zak 566cd92c9f eject: add --no-partitions-unmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-13 13:46:24 +02:00
Karel Zak b5c6f48631 tools: add small and stupid script to check HAVE_DECL_
use 'make checkdecl' to run the script

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-13 11:59:29 +02:00
Karel Zak a01e15f1e4 libblkid: trust in udev symlinks, don't verify
The libblkid always verify that /dev/disk/by-* symlinks match with
on-device LABELs/UUIDs. It means that all requests (e.g. mount -L |
-U) generates extra superblocks scans on the device.

Currently, many users and tools (GNOME, systemd, ...etc) use the
symlink directly and udev maintains the symlinks by inotify (+watch
rule). It seems better for system performance to disable the extra
paranoid mode and trust in udev.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-12 16:31:39 +02:00
Karel Zak e4062c72d1 losetup: improve -a to report loopdevs < 512 bytes
# ll ~/xxx2
  -rw-r--r-- 1 root root 500 Jun 12 14:30 /root/xxx2

 old version:
  # losetup -a

 new version:
  # losetup -a
  /dev/loop0: [2052]:535312 (/root/xxx2)

The new version scans /sys/block/loopN, kernel >= 2.6.37 is required
otherwise fallback to the original not-so-smart /proc/partitions scan.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-12 15:41:47 +02:00
Karel Zak 3554545636 losetup: warn about backing file size
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-12 14:34:16 +02:00
Sami Kerola 1edd8af70b lsblk: use blkdev_scsi_type_to_name()
Replace inline version of similar, but less complete, functionality
with the lib/blkdev.c function.  The function will inform if a type is
unknown, which appears as hex string value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:06 +02:00
Sami Kerola ba32a9465a blkdev: add blkdev_scsi_type_to_name()
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>
2012-06-11 22:06:06 +02:00
Sami Kerola 4f0537374f wipefs: use symbolic value for markup mode
In case mode value is found to be out of bounds program will crash.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:05 +02:00
Sami Kerola f31d041aaf eject: inform if CD-ROM drive is not ready
Include file (see linux/cdrom.h lines 395 and 398) suggests ioctl() can
return CDS_NO_INFO and CDS_DRIVE_NOT_READY, which where ignored.  This
commit will tell user what is going on.

The commit will also make eject to crash in ioctl() will return
unexpected value.

Reference: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=include/linux/cdrom.h;h=dfd7f187c351440d2ffa81050e46ed2602877f73;hb=HEAD
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:05 +02:00
Sami Kerola 957a3eede9 docs: clean up partx.8 manual
* Remove bold & italic noise.
* Reformat text to be 70 characters wide.
* Use option and option argument highlights consistently.
* Indent option argument list for --nr.
* Squeeze examples where the same is done multiple different ways.
* Use URL and email macros where appropriate.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:03 +02:00
Sami Kerola 667d375ea8 include: fix void pointer arithmetics warnings
all-io.h:18:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]
all-io.h:38:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola 9d72cbc1e2 sysfs: fix printf format warnings
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>
2012-06-11 19:51:35 +02:00
Sami Kerola 838c5f6bb8 build: fix unused parameter warnings
pager.c:203:14: warning: unused parameter 'argc' [-Wunused-parameter]
pager.c:203:26: warning: unused parameter 'argv' [-Wunused-parameter]

randutils.c:108:14: warning: unused parameter 'argc' [-Wunused-parameter]
randutils.c:108:26: warning: unused parameter 'argv' [-Wunused-parameter]

optstr.c:774:37: warning: unused parameter 'optstr' [-Wunused-parameter]
optstr.c:774:51: warning: unused parameter 'value' [-Wunused-parameter]
optstr.c:774:65: warning: unused parameter 'valsz' [-Wunused-parameter]
optstr.c:774:79: warning: unused parameter 'next' [-Wunused-parameter]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola 0e9b73d3fb build: fix redundant redeclaration warnings
env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]

fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls]

kill.h:1:13: note: previous declaration of 'get_pids' was here
kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls]

kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]

agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls]
agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]

libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here
libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here
mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls]
mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola c42206e4a7 include: fix spurious list.h warnings
include/list.h:224:17: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]
include/list.h:255:19: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]

Compilation warned about that at least 110 times.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola 7244ad8c09 uuidd: use output redirection which works [checkbashisms]
possible bashism in misc-utils/uuidd.rc line 52 (should be >word 2>&1):
	if pidofproc -p $PIDFILE $DAEMON >& /dev/null ; then

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:50:40 +02:00
Sami Kerola 41420120a8 blkid: fix realloc memory leak [cppcheck]
[misc-utils/blkid.c:367]: (error) Common realloc mistake: 'str' nulled but not freed upon failure

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:50:35 +02:00
Sami Kerola 50f32c363a setarch: do not use -1 as array index [cppcheck]
Negative array index does technically work, but looks awkward and
can confuse static analyser such as cppcheck.

[sys-utils/setarch.c:267]: (error) Array index -1 is out of bounds

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-09 22:51:10 +02:00
Karel Zak 0e60bc9b15 build-sys: add compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-06 12:10:41 +02:00
Karel Zak df68ccd8b8 fdisk: fix io_size usage in new API
properly implemented fdisk_dev_has_topology() requires optimal
I/O size to detect that the device provides topology.

Unfortunately, currently used cxt->io_size maybe overwritten in
__discover_topology() to min_io_size.

This patch introduces cxt->optimal_io_size and keeps it independent on
cxt->io_size. The cxt->io_size is I/O size used by fdisk for alignment
calculation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-06 11:03:23 +02:00
Karel Zak dde32b6ccd fdisk: fix compiler warning [-Wunused-variable]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-06 10:56:29 +02:00
Karel Zak c04e4a6a20 fdisk: fix compiler warning [-Wpointer-sign]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-06 10:53:20 +02:00
Karel Zak e1fc87eacd fdisk: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-06 10:48:26 +02:00
Davidlohr Bueso 14e93ff3c8 fdisk: remove user specified sector size global variable
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-06 10:43:27 +02:00
Davidlohr Bueso 6e89f25e8b fdisk: add fdisk_dev_sectsz_is_default helper
Instead of printing this warning from the API, add a helper and call it from
fdisk logic.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-06 10:41:51 +02:00
Davidlohr Bueso 3e3de41ad9 fdisk: use EXIT_SUCCESS for -l option
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-06 10:41:38 +02:00
Davidlohr Bueso 618882d609 fdisk: add total sectors
Add the total_sectors variable to the context structure. This is the initial
geometry information.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-06 10:40:40 +02:00
Davidlohr Bueso e53ced85bf fdisk: add device topology to the API
This patch adds device topology discovery to the internal API. This
functionality is static only to the API and therefore hidden from general fdisk
code. Functionality itself doesn't really change, min_io_size, io_size, logical
and physical sector sizes and alignment offset are added to the fdisk_context
structure and elements are accessed from there. The logical sector size
(sector_size) is now unsigned long instead of unsigned int, this as no effect
otherwise.

A few things to notice:
 - The patch is larger than I wanted but we need to modify function parameters
   across fdisk and its labels to use the topology data from cxt-> instances.
   Hopefully this will be pretty much it regarding this kind of modifications -
   perhaps geometry will need something of the like too.

 - The -b option must override internal discovery.

 - A new helper function has added to verify if the device provides topology
   information, this replaces the 'has_topology' global variable.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-06 10:30:07 +02:00
Davidlohr Bueso 7db8141571 fdisk: sun: use sector_t
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-06 10:12:05 +02:00
Davidlohr Bueso c9d7e0140f fdisk: sgi: use sector_t
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-06-06 10:12:01 +02:00