Namhyung Kim [Sun, 29 Sep 2013 10:11:37 +0000 (19:11 +0900)]
libmount: Save errno if mkostemp() failed
After mkostemp() failed, umask() and free() might alter the errno
to another value. Not sure those calls really changes the errno
or not. But let's be more conservative.
Sami Kerola [Sun, 29 Sep 2013 09:51:13 +0000 (10:51 +0100)]
build-sys: simplify python detection
This allows './configure --enable-most-builds' and 'make distcheck' to
work when both python2 and python3 are installed, and user has set python
version preference using symlink and PATH order.
Mike Frysinger [Sun, 29 Sep 2013 04:44:43 +0000 (00:44 -0400)]
clean up term lib handling
The ncurses package has been providing pkg-config files for a while now.
So let's start using them to get the proper linker & compiler flags. It
can make a difference when ncurses is configured in a way that requires
extra link time flags but util-linux doesn't provide them, or when the
headers live in a weird place and util-linux can't find them.
Since the NCURSES_LIBS is always defined for the Makefile, there's no need
to gate on the HAVE_NCURSES conditional. When it's disabled, the var will
simply be empty.
With a minor tweak to how tinfo is handled, we can do the same thing -- we
just always use TINFO_LIBS in the Makefile's.
Mike Frysinger [Sun, 29 Sep 2013 04:44:36 +0000 (00:44 -0400)]
setterm: fix term.h/ncurses.h include ordering
The ncurses term.h header has logic in it to detect if nucrses.h has
already been included and void defining things when it has. But since
setterm includes term.h and the ncurses.h, it doesn't work and we can
get fun build-time warnings like:
CC term-utils/setterm-setterm.o
In file included from term-utils/setterm.c:109:0:
/usr/include/ncursesw/ncurses.h:827:12: warning: redundant redeclaration of 'tigetflag' [-Wredundant-decls]
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *); /* implemented */
^
In file included from term-utils/setterm.c:106:0:
/usr/include/ncursesw/term.h:775:12: note: previous declaration of 'tigetflag' was here
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);
^
Namhyung Kim [Wed, 25 Sep 2013 15:32:05 +0000 (00:32 +0900)]
libmount: Set each optstr's to NULL if failed
When mnt_split_optstr() failed in the middle, vfs, fs, user optstr's
are freed but not reset. It can lead to double frees at the end of
mnt_fs_{ap,pre}pend_options().
Karel Zak [Wed, 25 Sep 2013 15:41:26 +0000 (17:41 +0200)]
ORIG_HEAD
tests: update sun label test
* add fdisk -l outputs (to make the test more usable)
* use more usable geometry
* don't expect that 'create sun label' oprations asks for C/H/S (we
follows fdisk_context defaults)
Karel Zak [Wed, 25 Sep 2013 13:34:34 +0000 (15:34 +0200)]
libfdisk: use context geometry in SGI and SUN
* don't call HDIO_GETGEO ioctls in the drivers
* use context geometry (so user can overwrite it by -C/H/S options)
* use default geometry is ioctl does not return anything
While most disk partitioning tools out there create a pMBR's size in lba
to be the lesser of the whole disk or 2Tib, Microsoft apparently does not[1].
It always sets the entry to the maximum 32-bit limitation - even though a
drive may be smaller than that.
Loosen this check and only verify that the size is either the whole disk
or 0xFFFFFFFF. No tool in its right mind would set it to any value
other than these.
We only jump to the 'check_hybrid' label when a valid pmbr
is detected, so we need not recheck again. Move the label's
logic so it doesn't include the check.
The lscpu tool only shows the current and max CPU frequencies, however,
in many scenarios this is not enough. If there are energy saving situations
(like some CPUs being idle, or not fully used) the cpugov can lower this value.
Dave Reisner [Wed, 18 Sep 2013 14:15:29 +0000 (10:15 -0400)]
libmount: free username after check
Leak reported by valgrind:
==14226== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1
==14226== at 0x4C2757B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14226== by 0x5534839: strdup (in /usr/lib/libc-2.18.so)
==14226== by 0x4E53FE0: mnt_get_username (utils.c:560)
==14226== by 0x4E456A5: mnt_context_prepare_umount (context_umount.c:413)
==14226== by 0x4E464F7: mnt_context_umount (context_umount.c:851)
==14226== by 0x403476: umount_one (umount.c:299)
==14226== by 0x402B34: main (umount.c:629)
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Dave Reisner [Tue, 17 Sep 2013 21:05:09 +0000 (17:05 -0400)]
libmount: use memmove when overlap possible
When unmounting some mountpoints as an unprivileged user (via the
'user' option in fstab), the umount fails. Debug output of 'umount
/opt' reveals:
17760: libmount: CXT: [0x22890e0]: do umount
17760: libmount: UTILS: moving to /opt parent
17760: libmount: CXT: current directory moved to / [last_component='opt']
17760: libmount: CXT: [0x22890e0]: umount(2) [target='pt', flags=0x00000000]
valgrind shows the problem:
==23544== Source and destination overlap in memcpy(0x58d1370, 0x58d1371, 4)
==23544== at 0x4C2BBC3: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23544== by 0x4E537C3: mnt_chdir_to_parent (utils.c:168)
==23544== by 0x4E45E4C: mnt_context_do_umount (context_umount.c:601)
==23544== by 0x4E46513: mnt_context_umount (context_umount.c:855)
==23544== by 0x403476: umount_one (umount.c:299)
==23544== by 0x402B34: main (umount.c:629)
==23544==
ref: https://bugs.archlinux.org/task/36968 Signed-off-by: Dave Reisner <dreisner@archlinux.org>