summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaMont Jones <lamont@mix.mmjgroup.com>2007-07-11 15:47:17 -0600
committerLaMont Jones <lamont@mix.mmjgroup.com>2007-07-11 15:47:17 -0600
commitec8f8cef53560e614317ac55b839a8c9b55ecdd6 (patch)
tree21df72408f9d07dcf0087922872d74bce0f94c13
parent69a7fde73cc4fad4e3d4bdb1fd4b1feae4ea40cb (diff)
parentdb0aaaa6a860e7a914ac8582c11f9d40c3164b25 (diff)
downloadutil-linux-old-ec8f8cef53560e614317ac55b839a8c9b55ecdd6.tar.gz
Merge commit 'origin/master' into debian
-rwxr-xr-xautogen.sh8
-rw-r--r--configure.ac1
-rw-r--r--fdisk/fdisk.c109
-rw-r--r--fdisk/gpt.c4
-rw-r--r--misc-utils/Makefile.am6
-rw-r--r--misc-utils/cal.c11
-rw-r--r--mount/lomount.c13
-rw-r--r--sys-utils/readprofile.c3
-rw-r--r--tests/commands.sh.in2
-rw-r--r--tests/helpers/Makefile.am6
-rw-r--r--tests/helpers/libpreload-time.c26
-rwxr-xr-xtests/ts-cal-116
-rwxr-xr-xtests/ts-cal-316
-rwxr-xr-xtests/ts-cal-y16
14 files changed, 152 insertions, 85 deletions
diff --git a/autogen.sh b/autogen.sh
index 70bb96b2..3451b953 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -44,13 +44,6 @@ DIE=0
echo "or see http://www.gnu.org/software/autoheader"
DIE=1
}
-(libtool --version) < /dev/null > /dev/null 2>&1 || {
- echo
- echo "You must have libtool installed to generate util-linux build-system."
- echo "Download the appropriate package for your distribution,"
- echo "or see http://www.gnu.org/software/libtool"
- DIE=1
-}
if test "$DIE" -eq 1; then
exit 1
fi
@@ -62,7 +55,6 @@ test -f mount/mount.c || {
set -e
autopoint --force
-libtoolize --copy --force
aclocal -I m4
autoconf
autoheader
diff --git a/configure.ac b/configure.ac
index 1afdb431..36b2641f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,6 @@ esac
AC_PROG_CC_STDC
AC_GNU_SOURCE
-AC_PROG_LIBTOOL
AC_PATH_PROG(PERL, perl)
AC_PATH_PROG(BLKID, blkid, [], [$PATH:/sbin])
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 292b7a85..5010d7db 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <getopt.h>
#include <sys/stat.h>
+#include <time.h>
#include "nls.h"
#include "common.h"
@@ -91,7 +92,7 @@ store4_little_endian(unsigned char *cp, unsigned int val) {
}
static unsigned int
-read4_little_endian(unsigned char *cp) {
+read4_little_endian(const unsigned char *cp) {
return (unsigned int)(cp[0]) + ((unsigned int)(cp[1]) << 8)
+ ((unsigned int)(cp[2]) << 16)
+ ((unsigned int)(cp[3]) << 24);
@@ -117,6 +118,49 @@ get_nr_sects(struct partition *p) {
return read4_little_endian(p->size4);
}
+static ssize_t
+xread(int fd, void *buf, size_t count) {
+ char *p = buf;
+ ssize_t out = 0;
+ ssize_t rv;
+
+ while (count) {
+ rv = read(fd, p, count);
+ if (rv == -1) {
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
+ return out ? out : -1; /* Error */
+ } else if (rv == 0) {
+ return out; /* EOF */
+ }
+
+ p += rv;
+ out += rv;
+ count -= rv;
+ }
+
+ return out;
+}
+
+static unsigned int
+get_random_id(void) {
+ int fd;
+ unsigned int v;
+ ssize_t rv = -1;
+
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd >= 0) {
+ rv = xread(fd, &v, sizeof v);
+ close(fd);
+ }
+
+ if (rv == sizeof v)
+ return v;
+
+ /* Fallback: sucks, but better than nothing */
+ return (unsigned int)(getpid() + time(NULL));
+}
+
/* normally O_RDWR, -l option gives O_RDONLY */
static int type_open = O_RDWR;
@@ -457,6 +501,7 @@ xmenu(void) {
puts(_(" f fix partition order")); /* !sun, !aix, !sgi */
puts(_(" g create an IRIX (SGI) partition table"));/* sgi */
puts(_(" h change number of heads"));
+ puts(_(" i change the disk identifier")); /* dos only */
puts(_(" m print this menu"));
puts(_(" p print the partition table"));
puts(_(" q quit without saving changes"));
@@ -720,25 +765,65 @@ read_extended(int ext) {
}
static void
+dos_write_mbr_id(unsigned char *b, unsigned int id) {
+ store4_little_endian(&b[440], id);
+}
+
+static unsigned int
+dos_read_mbr_id(const unsigned char *b) {
+ return read4_little_endian(&b[440]);
+}
+
+static void
+dos_print_mbr_id(void) {
+ printf(_("Disk identifier: 0x%08x\n"), dos_read_mbr_id(MBRbuffer));
+}
+
+static void
+dos_set_mbr_id(void) {
+ unsigned long new_id;
+ char *ep;
+ char ps[64];
+
+ snprintf(ps, sizeof ps, _("New disk identifier (current 0x%08x): "),
+ dos_read_mbr_id(MBRbuffer));
+
+ if (read_chars(ps) == '\n')
+ return;
+
+ new_id = strtoul(line_ptr, &ep, 0);
+ if (*ep != '\n')
+ return;
+
+ dos_write_mbr_id(MBRbuffer, new_id);
+ dos_print_mbr_id();
+}
+
+static void
create_doslabel(void) {
- int i;
+ unsigned int id = get_random_id();
fprintf(stderr,
- _("Building a new DOS disklabel. Changes will remain in memory only,\n"
- "until you decide to write them. After that, of course, the previous\n"
- "content won't be recoverable.\n\n"));
+ _("Building a new DOS disklabel with disk identifier 0x%08x.\n"
+ "Changes will remain in memory only, until you decide to write them.\n"
+ "After that, of course, the previous content won't be recoverable.\n\n"),
+ id);
sun_nolabel(); /* otherwise always recognised as sun */
sgi_nolabel(); /* otherwise always recognised as sgi */
mac_label = aix_label = osf_label = possibly_osf_label = 0;
partitions = 4;
- for (i = 510-64; i < 510; i++)
- MBRbuffer[i] = 0;
- write_part_table_flag(MBRbuffer);
+ /* Zero out the MBR buffer */
extended_offset = 0;
set_all_unchanged();
set_changed(0);
get_boot(create_empty_dos);
+
+ /* Generate an MBR ID for this disk */
+ dos_write_mbr_id(MBRbuffer, id);
+
+ /* Mark it bootable (unfortunately required) */
+ write_part_table_flag(MBRbuffer);
}
#include <sys/utsname.h>
@@ -1528,9 +1613,12 @@ list_disk_geometry(void) {
printf(_(", total %llu sectors"),
total_number_of_sectors / (sector_size/512));
printf("\n");
- printf(_("Units = %s of %d * %d = %d bytes\n\n"),
+ printf(_("Units = %s of %d * %d = %d bytes\n"),
str_units(PLURAL),
units_per_sector, sector_size, units_per_sector * sector_size);
+ if (dos_label)
+ dos_print_mbr_id();
+ printf("\n");
}
/*
@@ -1695,7 +1783,6 @@ list_table(int xtra) {
printf(_("This doesn't look like a partition table\n"
"Probably you selected the wrong device.\n\n"));
}
-
/* Heuristic: we list partition 3 of /dev/foo as /dev/foo3,
but if the device name ends in a digit, say /dev/foo1,
@@ -2310,6 +2397,8 @@ xselect(void) {
case 'i':
if (sun_label)
sun_set_ilfact();
+ if (dos_label)
+ dos_set_mbr_id();
break;
case 'o':
if (sun_label)
diff --git a/fdisk/gpt.c b/fdisk/gpt.c
index f1d751ac..b8f3d33d 100644
--- a/fdisk/gpt.c
+++ b/fdisk/gpt.c
@@ -173,10 +173,12 @@ last_lba(int fd)
}
if (S_ISBLK(s.st_mode))
sectors = _get_num_sectors(fd);
+ else if (S_ISREG(s.st_mode))
+ sectors = s.st_size >> _get_sector_size(fd);
else
{
fprintf(stderr,
- "last_lba(): I don't know how to handle files with mode %x\n",
+ "last_lba(): I don't know how to handle files with mode %o\n",
s.st_mode);
sectors = 1;
}
diff --git a/misc-utils/Makefile.am b/misc-utils/Makefile.am
index a9ea5ef4..794be494 100644
--- a/misc-utils/Makefile.am
+++ b/misc-utils/Makefile.am
@@ -74,3 +74,9 @@ install-exec-hook::
endif
endif
+
+noinst_PROGRAMS = cal_test
+cal_test_SOURCES = cal.c
+cal_test_CPPFLAGS = -DTEST_CAL $(AM_CPPFLAGS)
+cal_test_LDADD = $(cal_LDADD)
+
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index dc5848aa..f5ede93d 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -351,7 +351,16 @@ main(int argc, char **argv) {
errx(1, _("illegal year value: use 1-9999"));
break;
case 0:
- time(&now);
+ {
+#ifdef TEST_CAL
+ char *e = getenv("TEST_TIME");
+
+ if (e && isdigit((unsigned char) *e))
+ now = atol(e);
+ else
+#endif
+ time(&now);
+ }
local_time = localtime(&now);
if (isatty(1))
day = local_time->tm_yday + 1;
diff --git a/mount/lomount.c b/mount/lomount.c
index 1208f9fa..a9c77aef 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -312,16 +312,17 @@ set_loop(const char *device, const char *file, unsigned long long offset,
loopinfo64.lo_offset = offset;
-#ifdef MCL_FUTURE
+#ifdef MCL_FUTURE
/*
* Oh-oh, sensitive data coming up. Better lock into memory to prevent
* passwd etc being swapped out and left somewhere on disk.
*/
-
- if(mlockall(MCL_CURRENT | MCL_FUTURE)) {
- perror("memlock");
- fprintf(stderr, _("Couldn't lock into memory, exiting.\n"));
- exit(1);
+ if (loopinfo64.lo_encrypt_type != LO_CRYPT_NONE) {
+ if(mlockall(MCL_CURRENT | MCL_FUTURE)) {
+ perror("memlock");
+ fprintf(stderr, _("Couldn't lock into memory, exiting.\n"));
+ exit(1);
+ }
}
#endif
diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c
index 43991f2f..978e6c1d 100644
--- a/sys-utils/readprofile.c
+++ b/sys-utils/readprofile.c
@@ -306,7 +306,8 @@ main(int argc, char **argv) {
prgname, mapFile, maplineno);
exit(1);
}
- if (!strcmp(fn_name,"_stext")) /* only elf works like this */ {
+ /* only elf works like this */
+ if (!strcmp(fn_name,"_stext") || !strcmp(fn_name,"__stext")) {
add0 = fn_add;
break;
}
diff --git a/tests/commands.sh.in b/tests/commands.sh.in
index c659d1a3..f8128bb8 100644
--- a/tests/commands.sh.in
+++ b/tests/commands.sh.in
@@ -6,7 +6,6 @@ TS_TESTUSER=${TS_TESTUSER:-"test"}
# helpers
TS_HELPER_SYSINFO="$TS_TOPDIR/helpers/mnt_test_sysinfo"
-TS_HELPER_LIBPRELOAD_TIME="$TS_TOPDIR/helpers/.libs/libpreload-time.so"
# external commands
TS_ECMD_BLKID="@BLKID@"
@@ -31,6 +30,7 @@ TS_CMD_COL=${TS_CMD_COL:-"$TOPDIR/text-utils/col"}
TS_CMD_NAMEI=${TS_CMD_NAMEI-"$TOPDIR/misc-utils/namei"}
TS_CMD_LOOK=${TS_CMD_LOOK-"$TOPDIR/misc-utils/look"}
TS_CMD_CAL=${TS_CMD_CAL-"$TOPDIR/misc-utils/cal"}
+TS_CMD_CALTEST=${TS_CMD_CALTEST-"$TOPDIR/misc-utils/cal_test"}
TS_CMD_CHECKTTY=${TS_CMD_CHECKTTY-"$TOPDIR/login-utils/checktty_test"}
diff --git a/tests/helpers/Makefile.am b/tests/helpers/Makefile.am
index 6c514e7c..b6f0557f 100644
--- a/tests/helpers/Makefile.am
+++ b/tests/helpers/Makefile.am
@@ -3,9 +3,3 @@ include $(top_srcdir)/config/include-Makefile.am
noinst_PROGRAMS = mnt_test_sysinfo
mnt_test_sysinfo_SOURCES = mnt_test_sysinfo.c
-
-noinst_LTLIBRARIES = libpreload-time.la
-
-libpreload_time_la_SOURCES = libpreload-time.c
-libpreload_time_la_LDFLAGS = -shared -rpath `pwd` -avoid-version
-
diff --git a/tests/helpers/libpreload-time.c b/tests/helpers/libpreload-time.c
deleted file mode 100644
index e6979509..00000000
--- a/tests/helpers/libpreload-time.c
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <time.h>
-#include <sys/time.h>
-
-time_t
-time(time_t *t)
-{
- time_t tt = 0;
- char *e = getenv("TEST_TIME");
-
- if (e && isdigit((unsigned char) *e))
- tt = atol(e);
- else {
- struct timeval tv;
-
- if (gettimeofday(&tv, NULL) == 0)
- tt = tv.tv_sec;
- }
- if (t)
- *t = tt;
-
- return tt;
-}
diff --git a/tests/ts-cal-1 b/tests/ts-cal-1
index 674e4dd8..09242010 100755
--- a/tests/ts-cal-1
+++ b/tests/ts-cal-1
@@ -33,28 +33,28 @@ ts_log ""
ts_log "Gregorian - Monday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1m
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -1m
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1m >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -1m >> $TS_OUTPUT
ts_log "Gregorian - Sunday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1s
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -1s
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1s >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -1s >> $TS_OUTPUT
ts_log "Julian - Monday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1mj
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -1mj
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1mj >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -1mj >> $TS_OUTPUT
ts_log "Julian - Sunday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1sj
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -1sj
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -1sj >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -1sj >> $TS_OUTPUT
ts_finalize
diff --git a/tests/ts-cal-3 b/tests/ts-cal-3
index eeb6e0e1..e8da56f8 100755
--- a/tests/ts-cal-3
+++ b/tests/ts-cal-3
@@ -33,28 +33,28 @@ ts_log ""
ts_log "Gregorian - Monday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3m
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -3m
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3m >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -3m >> $TS_OUTPUT
ts_log "Gregorian - Sunday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3s
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -3s
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3s >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -3s >> $TS_OUTPUT
ts_log "Julian - Monday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3mj
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -3mj
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3mj >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -3mj >> $TS_OUTPUT
ts_log "Julian - Sunday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3sj
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -3sj
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -3sj >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -3sj >> $TS_OUTPUT
ts_finalize
diff --git a/tests/ts-cal-y b/tests/ts-cal-y
index 253bec23..f9c60bd1 100755
--- a/tests/ts-cal-y
+++ b/tests/ts-cal-y
@@ -33,28 +33,28 @@ ts_log ""
ts_log "Gregorian - Monday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ym
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -ym
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ym >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -ym >> $TS_OUTPUT
ts_log "Gregorian - Sunday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ys
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -ys
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ys >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -ys >> $TS_OUTPUT
ts_log "Julian - Monday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ymj
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -ymj
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ymj >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -ymj >> $TS_OUTPUT
ts_log "Julian - Sunday-based week"
if [ "$USETERM" == "yes" ]; then
- TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ysj
+ TEST_TIME=$MYTIME $TS_CMD_CALTEST -ysj
fi
-TEST_TIME=$MYTIME LD_PRELOAD=$TS_HELPER_LIBPRELOAD_TIME $TS_CMD_CAL -ysj >> $TS_OUTPUT
+TEST_TIME=$MYTIME $TS_CMD_CALTEST -ysj >> $TS_OUTPUT
ts_finalize