From a2ff0f31c1987a480ffc4dacb7adf93f0aecf7f6 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 21 Mar 2008 09:10:09 -0400 Subject: debugfs, tune2fs: Handle daylight savings time when parsing a time string We need to set tm_isdst to -1 so that mktime will automatically determine whether or not daylight savings time (DST) is in effect. Previously tm_isdst was set to 0, which caused mktime to interpret the time as if it was always not using DST. Addresses-Debian-Bug: #471882 Signed-off-by: "Theodore Ts'o" --- debugfs/util.c | 1 + misc/tune2fs.c | 1 + 2 files changed, 2 insertions(+) diff --git a/debugfs/util.c b/debugfs/util.c index 06339601..ebce9d61 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -231,6 +231,7 @@ extern time_t string_to_time(const char *arg) ts.tm_min > 59 || ts.tm_sec > 61) ts.tm_mday = 0; #endif + ts.tm_isdst = -1; ret = mktime(&ts); if (ts.tm_mday == 0 || ret == ((time_t) -1)) { /* Try it as an integer... */ diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 4f66d42b..4e731f5c 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -540,6 +540,7 @@ static time_t parse_time(char *str) str); usage(); } + ts.tm_isdst = -1; return (mktime(&ts)); } -- cgit v1.2.3 From 402b95d285cbd12f0f11c786badbdf23ae701a89 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 21 Mar 2008 09:25:23 -0400 Subject: mke2fs: Clarify man page that -T is interpreted using the current timezone Signed-off-by: "Theodore Ts'o" --- misc/tune2fs.8.in | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/tune2fs.8.in b/misc/tune2fs.8.in index 8b59c178..260e76f3 100644 --- a/misc/tune2fs.8.in +++ b/misc/tune2fs.8.in @@ -464,6 +464,7 @@ Set the number of reserved filesystem blocks. .BI \-T " time-last-checked" Set the time the filesystem was last checked using .BR e2fsck . +The time is interpreted using the current (local) timezone. This can be useful in scripts which use a Logical Volume Manager to make a consistent snapshot of a filesystem, and then check the filesystem during off hours to make sure it hasn't been corrupted due to -- cgit v1.2.3 From ab7862049a3311c5ab3d22dde07823560d13afe0 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 26 Mar 2008 08:11:11 -0400 Subject: fsck: Fix -C handling so that subsequent progress bars are enabled The exiting fsck instance wasn't marked as DONE, so the safety checks thought a progress bar was still in progress, and so we didn't enable another filesystem's checking. Addresses-Debian-Bug: #432865 Addresses-Launchpad-Bug: #203323 Addresses-Sourceforge-Bug: #1926023 Signed-off-by: "Theodore Ts'o" --- misc/fsck.c | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/fsck.c b/misc/fsck.c index db572b1e..14d7a954 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -615,6 +615,7 @@ static struct fsck_instance *wait_one(int flags) status = EXIT_ERROR; } inst->exit_status = status; + inst->flags |= FLAG_DONE; if (progress && (inst->flags & FLAG_PROGRESS) && !progress_active()) { for (inst2 = instance_list; inst2; inst2 = inst2->next) { -- cgit v1.2.3 From be62523be2307123886934f258cf36f4b33b1c38 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 26 Mar 2008 08:26:01 -0400 Subject: e2fsck: Support a negative argument to -C to suppress progress information If a negative progress argument is given to -C, initially suppress the progress information. It can be enabled later by sending the e2fsck process a SIGUSR1 signal. Addresses-Launchpad-Bug: #203323 Addresses-Sourceforge-Bug: #1926023 Signed-off-by: "Theodore Ts'o" --- e2fsck/e2fsck.8.in | 10 ++++++++-- e2fsck/unix.c | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/e2fsck/e2fsck.8.in b/e2fsck/e2fsck.8.in index 6cae5773..3059e60f 100644 --- a/e2fsck/e2fsck.8.in +++ b/e2fsck/e2fsck.8.in @@ -139,6 +139,11 @@ so that the progress of the filesystem check can be monitored. This option is typically used by programs which are running .BR e2fsck . +If the file descriptor number is negative, then absolute value of +the file descriptor will be used, and the progress information will be +suppressed initially. It can later be enabled by sending the +.B e2fsck +process a SIGUSR1 signal. If the file descriptor specified is 0, .B e2fsck will print a completion bar as it goes about its business. This requires @@ -337,14 +342,15 @@ The following signals have the following effect when sent to .B SIGUSR1 This signal causes .B e2fsck -to start displaying a completion bar. (See discussion of the +to start displaying a completion bar or emitting progress information. +(See discussion of the .B \-C option.) .TP .B SIGUSR2 This signal causes .B e2fsck -to stop displaying a completion bar. +to stop displaying a completion bar or emitting progress information. .SH REPORTING BUGS Almost any piece of software will have bugs. If you manage to find a filesystem which causes diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 1227725a..e8432447 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -490,7 +490,6 @@ static void signal_progress_on(int sig EXT2FS_ATTR((unused))) return; ctx->progress = e2fsck_update_progress; - ctx->progress_fd = 0; } static void signal_progress_off(int sig EXT2FS_ATTR((unused))) @@ -627,6 +626,10 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) if (res != 1) goto sscanf_err; + if (ctx->progress_fd < 0) { + ctx->progress = 0; + ctx->progress_fd = ctx->progress_fd * -1; + } if (!ctx->progress_fd) break; /* Validate the file descriptor to avoid disasters */ -- cgit v1.2.3 From a16834335d745d631d6ee20eef0bdbe24e4b152d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 26 Mar 2008 08:53:13 -0400 Subject: fsck: Make -Cn work correctly where n != 0 Previously, fsck was only passing in -Cn to the first e2fsck process to start up, and enabling the progress information by sending a SIGUSR1 signal. This didn't work if the progress information was intended to go to file descriptor, since the information was never passed to e2fsck. So we now pass the progress fd in as a negative number if the progress information is intended to be initially suppressed. Addresses-Launchpad-Bug: #203323 Addresses-Sourceforge-Bug: #1926023 Signed-off-by: "Theodore Ts'o" --- misc/fsck.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/misc/fsck.c b/misc/fsck.c index 14d7a954..e44829ab 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -451,13 +451,19 @@ static int execute(const char *type, const char *device, const char *mntpt, for (i=0; i flags |= FLAG_PROGRESS; + + tmp[0] = 0; + if (!progress_active()) { + snprintf(tmp, 80, "-C%d", progress_fd); + inst->flags |= FLAG_PROGRESS; + } else if (progress_fd) + snprintf(tmp, 80, "-C%d", progress_fd * -1); + if (tmp[0]) + argv[argc++] = string_copy(tmp); } } -- cgit v1.2.3 From bf209ab7950ca2a06c5837f47756f6e0ae326e85 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 26 Mar 2008 08:58:25 -0400 Subject: fsck: Treat "ext4" and "ext4dev" as ext* filesystems Signed-off-by: "Theodore Ts'o" --- misc/fsck.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misc/fsck.c b/misc/fsck.c index e44829ab..139afd01 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -81,6 +81,8 @@ static const char *really_wanted[] = { "minix", "ext2", "ext3", + "ext4", + "ext4dev", "jfs", "reiserfs", "xiafs", @@ -453,7 +455,9 @@ static int execute(const char *type, const char *device, const char *mntpt, if (progress) { if ((strcmp(type, "ext2") == 0) || - (strcmp(type, "ext3") == 0)) { + (strcmp(type, "ext3") == 0) || + (strcmp(type, "ext4") == 0) || + (strcmp(type, "ext4dev") == 0)) { char tmp[80]; tmp[0] = 0; @@ -628,7 +632,9 @@ static struct fsck_instance *wait_one(int flags) if (inst2->flags & FLAG_DONE) continue; if (strcmp(inst2->type, "ext2") && - strcmp(inst2->type, "ext3")) + strcmp(inst2->type, "ext3") && + strcmp(inst2->type, "ext4") && + strcmp(inst2->type, "ext4dev")) continue; /* * If we've just started the fsck, wait a tiny -- cgit v1.2.3 From 1dc506cbe956419f0eafb8e84bae108ec2f0b2de Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 26 Mar 2008 09:09:09 -0400 Subject: e2fsck: Include the device name in the progress information Also make sure the device name has no spaces in it, to avoid confusing displays, and make ctx->filesystem_name and ctx->device_name allocated memory to avoid potential problems in the future. Addresses-Launchpad-Bug: #203323 Addresses-Sourceforge-Bug: #1926023 Signed-off-by: "Theodore Ts'o" --- e2fsck/e2fsck.c | 6 ++++++ e2fsck/unix.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c index e2434da8..9afd906e 100644 --- a/e2fsck/e2fsck.c +++ b/e2fsck/e2fsck.c @@ -169,6 +169,12 @@ void e2fsck_free_context(e2fsck_t ctx) if (ctx->profile) profile_release(ctx->profile); + + if (ctx->filesystem_name) + ext2fs_free_mem(&ctx->filesystem_name); + + if (ctx->device_name) + ext2fs_free_mem(&ctx->device_name); ext2fs_free_mem(&ctx); } diff --git a/e2fsck/unix.c b/e2fsck/unix.c index e8432447..3eb30647 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -444,14 +444,15 @@ int e2fsck_simple_progress(e2fsck_t ctx, const char *label, float percent, static int e2fsck_update_progress(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max) { - char buf[80]; + char buf[1024]; float percent; if (pass == 0) return 0; if (ctx->progress_fd) { - sprintf(buf, "%d %lu %lu\n", pass, cur, max); + snprintf(buf, sizeof(buf), "%d %lu %lu %s\n", + pass, cur, max, ctx->device_name); write(ctx->progress_fd, buf, strlen(buf)); } else { percent = calc_percent(&e2fsck_tbl, pass, cur, max); @@ -774,6 +775,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) argv[optind]); fatal_error(ctx, 0); } + ctx->filesystem_name = string_copy(ctx, ctx->filesystem_name, 0); if (extended_opts) parse_extended_opts(ctx, extended_opts); @@ -888,6 +890,7 @@ int main (int argc, char *argv[]) int journal_size; int sysval, sys_page_size = 4096; __u32 features[3]; + char *cp; clear_problem_context(&pctx); #ifdef MTRACE @@ -1109,7 +1112,10 @@ restart: sizeof(sb->s_volume_name)); } if (ctx->device_name == 0) - ctx->device_name = ctx->filesystem_name; + ctx->device_name = string_copy(ctx, ctx->filesystem_name, 0); + for (cp = ctx->device_name; *cp; cp++) + if (isspace(*cp) || *cp == ':') + *cp = '_'; /* * Make sure the ext3 superblock fields are consistent. -- cgit v1.2.3 From 62653d99d823f5d73eba925885896d91ea8bab91 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 26 Mar 2008 09:42:00 -0400 Subject: logsave: Pass any SIGTERM or SIGINT signals to child process Signed-off-by: "Theodore Ts'o" --- misc/logsave.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/misc/logsave.c b/misc/logsave.c index f256c20e..c6fd3f8c 100644 --- a/misc/logsave.c +++ b/misc/logsave.c @@ -19,6 +19,9 @@ #include #include #include +#ifdef HAVE_SIGNAL_H +#include +#endif #ifdef HAVE_GETOPT_H #include #else @@ -32,6 +35,7 @@ void *outbuf = 0; int verbose = 0; int do_skip = 0; int skip_mode = 0; +pid_t child_pid = -1; static void usage(char *progname) { @@ -102,17 +106,36 @@ static int do_read(int fd) return c; } +static void signal_term(int sig) +{ + if (child_pid > 0) + kill(child_pid, sig); +} + static int run_program(char **argv) { int fds[2]; int status, rc, pid; char buffer[80]; +#ifdef HAVE_SIGNAL_H + struct sigaction sa; +#endif if (pipe(fds) < 0) { perror("pipe"); exit(1); } +#ifdef HAVE_SIGNAL_H + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_handler = signal_term; + sigaction(SIGINT, &sa, 0); + sigaction(SIGTERM, &sa, 0); +#ifdef SA_RESTART + sa.sa_flags = SA_RESTART; +#endif +#endif + pid = fork(); if (pid < 0) { perror("vfork"); @@ -127,11 +150,13 @@ static int run_program(char **argv) perror(argv[0]); exit(1); } + child_pid = pid; close(fds[1]); while (!(waitpid(pid, &status, WNOHANG ))) { do_read(fds[0]); } + child_pid = -1; do_read(fds[0]); close(fds[0]); -- cgit v1.2.3 From fc03b9c4f27eff9fcab8bf9ee1ba42b2e1328d5d Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Sat, 29 Mar 2008 07:32:47 -0400 Subject: debian: Use UID/GID ranges from adduser.conf, if present Addresses-Debian-Bug: #473179 Signed-off-by: Michael Spang Signed-off-by: "Theodore Ts'o" --- debian/libuuid1.postinst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/debian/libuuid1.postinst b/debian/libuuid1.postinst index cd5b093c..ccbd8810 100644 --- a/debian/libuuid1.postinst +++ b/debian/libuuid1.postinst @@ -1,10 +1,22 @@ #!/bin/sh set -e -groupadd -f -K GID_MIN=100 -K GID_MAX=999 libuuid + +FIRST_SYSTEM_UID=100 +LAST_SYSTEM_UID=999 +FIRST_SYSTEM_GID=100 +LAST_SYSTEM_GID=999 + +if test -f /etc/adduser.conf; then + . /etc/adduser.conf +fi + +groupadd -f -K GID_MIN=$FIRST_SYSTEM_GID -K GID_MAX=$LAST_SYSTEM_GID libuuid + if ! grep -q libuuid /etc/passwd; then - useradd -d /var/lib/libuuid -K UID_MIN=100 -K UID_MAX=999 -g libuuid libuuid + useradd -d /var/lib/libuuid -K UID_MIN=$FIRST_SYSTEM_UID -K UID_MAX=$LAST_SYSTEM_UID -g libuuid libuuid fi + mkdir -p /var/lib/libuuid chown libuuid:libuuid /var/lib/libuuid chmod 2775 /var/lib/libuuid -- cgit v1.2.3 From a2447f8c8aaaa4732b8ab950cb29699a1ff0d694 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 29 Mar 2008 14:46:48 -0400 Subject: e2fsck: Avoid core dump when using the -N option This bug was accidentally introduced by commit 1dc506cb. Signed-off-by: "Theodore Ts'o" --- e2fsck/unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 3eb30647..d3a8a2b6 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -737,7 +737,7 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) break; #endif case 'N': - ctx->device_name = optarg; + ctx->device_name = string_copy(ctx, optarg, 0); break; #ifdef ENABLE_SWAPFS case 's': -- cgit v1.2.3 From e28a1bca9edbbd6c9880d16ea7b9199d0b6cb976 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Sun, 30 Mar 2008 14:02:00 -0400 Subject: Use -E instead of the deprecated -R option in the mke2fs man page Signed-off-by: Andreas Dilger Signed-off-by: "Theodore Ts'o" --- misc/mke2fs.8.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in index 14c3ca59..aaf017d3 100644 --- a/misc/mke2fs.8.in +++ b/misc/mke2fs.8.in @@ -227,7 +227,7 @@ for the filesystem. (For administrators who are creating filesystems on RAID arrays, it is preferable to use the .I stride RAID parameter as part of the -.B \-R +.B \-E option rather than manipulating the number of blocks per group.) This option is generally used by developers who are developing test cases. -- cgit v1.2.3