Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=db40272dc51e00222654d554f7c786fbed02bd81

commit db40272dc51e00222654d554f7c786fbed02bd81
Author: Miklos Vajna <vmik...@frugalware.org>
Date:   Tue Dec 7 03:03:04 2010 +0100

util-linux-ng-2.18-5-i686

- change /etc/mtab to /proc/self/mounts (hermier)
- backport two patches from git for fsck -l and agetty -s support
- enable fsck and partx (hermier, bouleetbil)
- disable unneeded rc scripts when using systemd
- add lsb header to rc.bootclean

diff --git a/source/base/util-linux-ng/FrugalBuild 
b/source/base/util-linux-ng/FrugalBuild
index b2ebe1a..c1d5b97 100644
--- a/source/base/util-linux-ng/FrugalBuild
+++ b/source/base/util-linux-ng/FrugalBuild
@@ -3,10 +3,11 @@

pkgname=util-linux-ng
pkgver=2.18
-pkgrel=1
+pkgrel=5
pkgdesc="Miscellaneous system utilities for Linux"
url="http://www.kernel.org/pub/linux/utils/util-linux-ng";
backup=('etc/sysconfig/console' 'etc/sysconfig/numlock')
+removes=('etc/mtab')
depends=('bash' 'ncurses>=5.6-4' 'zlib>=1.2.3-6' 'texinfo>=4.11-3')
makedepends=('cvs')
replaces=('util-linux' 'linux32')
@@ -20,8 +21,9 @@ source=($url/v${pkgver%%.?}/util-linux-ng-$pkgver.tar.bz2 \
frugalwaregetty numlock rc.{bootclean,console,mount,rmount,swap,time} \
rc.bootclean-{de,hu}.po rc.mount-{de,hu}.po rc.rmount-{de,hu}.po \
rc.swap-{de,hu}.po rc.time-{de,hu}.po \
-       README.Frugalware)
-signatures=($source.sign '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 
'')
+       README.Frugalware \
+       util-linux-ng-2.18-agetty-baudrate.patch 
util-linux-ng-2.18-fsck-wholedisk.patch)
+signatures=($source.sign '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 
'' '' '')

subpkgs=("${subpk...@]}" "libblkid")
subdescs=("${subdes...@]}" 'Block device id library')
@@ -41,10 +43,10 @@ rodepends=("${rodepen...@]}" "${subpk...@]}")

build() {
export CFLAGS="$CFLAGS -fPIC"
-       Fcd
+       Fpatchall
Fautoreconf
-       Fbuild --enable-arch --enable-raw  --enable-elvtune \
-               --mandir=/usr/share/man --disable-fsck
+       Fmake --enable-arch --enable-raw --enable-elvtune --enable-partx
+       Fmakeinstall
# Remove conflicting files.
Frm /bin/kill /usr/bin/wall
Frm /usr/share/man/man1/{kill,wall}.1
@@ -55,6 +57,8 @@ build() {
# This one will be created by ldconfig
Frm /lib/libblkid.so.1

+       Fln /proc/self/mounts /etc/mtab
+
# Move stuff to the right location (where util-linux had them, maybe
# remove later).
Fmv /sbin/raw /usr/bin/raw
@@ -64,8 +68,17 @@ build() {
do
Frcd2 $i
done
-       [ "$CARCH" != "ppc" ] && Frcd2 time
Fexe /etc/rc.d/rc.console
+       # don't run old sysv init script with different name when using systemd
+       Fmkdir /lib/systemd/system
+       Fln remount-rootfs.service /lib/systemd/system/mount.service
+       Fln remount-rootfs.service /lib/systemd/system/rmount.service
+       Fln remount-rootfs.service /lib/systemd/system/swap.service
+       Fln systemd-vconsole-setup.service /lib/systemd/system/console.service
+       if [ "$CARCH" != "ppc" ]; then
+               Frcd2 time
+               Fln hwclock-load.service /lib/systemd/system/time.service
+       fi

# Our getty.
Fexe /sbin/frugalwaregetty
diff --git a/source/base/util-linux-ng/rc.bootclean 
b/source/base/util-linux-ng/rc.bootclean
index a38e360..7b1c04c 100644
--- a/source/base/util-linux-ng/rc.bootclean
+++ b/source/base/util-linux-ng/rc.bootclean
@@ -1,4 +1,7 @@
#!/bin/bash
+### BEGIN INIT INFO
+# Default-Start: S
+### END INIT INFO

# (c) 2005 Marcus Habermehl <bmh198...@yahoo.de>
# (c) 2005 Laszlo Dvornik <dvor...@gnome.hu>
diff --git a/source/base/util-linux-ng/util-linux-ng-2.18-agetty-baudrate.patch 
b/source/base/util-linux-ng/util-linux-ng-2.18-agetty-baudrate.patch
new file mode 100644
index 0000000..72dc257
--- /dev/null
+++ b/source/base/util-linux-ng/util-linux-ng-2.18-agetty-baudrate.patch
@@ -0,0 +1,206 @@
+
+ based on upstream patch:
+
+       commit 848e5e6ce3978d921366b799d907a78a12299924
+       Author: Karel Zak <k...@redhat.com>
+       Date:   Wed Aug 18 09:02:03 2010 +0200
+
+       agetty: add -s to reuse existing baud rate
+
+       For example:
+
+       /sbin/agetty -s /dev/ttyS0 9600
+
+       will reuse the speed the kernel configured on the port. If the setting
+       from kernel is useless (tty returns BREAK character) then the baud
+       rate from command line (9600) is used.
+
+       Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=623685
+       Signed-off-by: Karel Zak <k...@redhat.com>
+
+ and
+
+       commit e98f4af950a64db188e0a9f3eed20fefaa463a99
+       Author: Karel Zak <k...@redhat.com>
+       Date:   Fri Oct 22 21:24:50 2010 +0200
+
+       agetty: fix -s option (baud rate setup)
+
+       The problem is pretty visible in strace output:
+
+       broken version:
+       ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo 
...}) = 0
+       [...]
+       ioctl(0, SNDCTL_TMR_START or TCSETS, {B0 -opost -isig -icanon -echo 
...}) = 0
+                                          ^^^
+       fixed version:
+       ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 opost isig icanon echo 
...}) = 0
+       [...]
+       ioctl(0, SNDCTL_TMR_START or TCSETS, {B115200 -opost -isig -icanon 
-echo ...}) = 0
+
+       Reported-by: Jon Masters <j...@redhat.com>
+       Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=645640
+       Signed-off-by: Karel Zak <k...@redhat.com>
+
+diff -up util-linux-ng-2.18/login-utils/agetty.8.kzak 
util-linux-ng-2.18/login-utils/agetty.8
+--- util-linux-ng-2.18/login-utils/agetty.8.kzak       2010-02-04 
12:53:56.000000000 +0100
++++ util-linux-ng-2.18/login-utils/agetty.8    2010-10-22 22:07:43.000000000 
+0200
+@@ -3,7 +3,7 @@
+ agetty \- alternative Linux getty
+
+ .SH SYNOPSIS
+-.BR "agetty " [\-8ihLmnUw]
++.BR "agetty " [\-8ihLmnsUw]
+ .RI "[-f " issue_file ]
+ .RI "[-l " login_program ]
+ .RI "[-I " init ]
+@@ -12,16 +12,6 @@ agetty \- alternative Linux getty
+ .I port
+ .I baud_rate,...
+ .RI [ term ]
+-.br
+-.BR "agetty " [\-8ihLmnw]
+-.RI "[-f " issue_file ]
+-.RI "[-l " login_program ]
+-.RI "[-I " init ]
+-.RI "[-t " timeout ]
+-.RI "[-H " login_host ]
+-.I baud_rate,...
+-.I port
+-.RI [ term ]
+
+ .SH DESCRIPTION
+ .ad
+@@ -163,6 +153,10 @@ Force the line to be a local line with n
+ be useful when you have a locally attached terminal where the serial line
+ does not set the carrier detect signal.
+ .TP
++\-s
++Try to keep the existing baud rate. The baud rates from
++the command line are used when agetty receives a BREAK character.
++.TP
+ \-U
+ Turn on support for detecting an uppercase only terminal.  This setting will
+ detect a login name containing only capitals as indicating an uppercase
+diff -up util-linux-ng-2.18/login-utils/agetty.c.kzak 
util-linux-ng-2.18/login-utils/agetty.c
+--- util-linux-ng-2.18/login-utils/agetty.c.kzak       2010-04-01 
16:11:56.000000000 +0200
++++ util-linux-ng-2.18/login-utils/agetty.c    2010-10-22 22:15:40.000000000 
+0200
+@@ -133,6 +133,7 @@ struct options {
+ #define F_CUSTISSUE   (1<<6)          /* give alternative issue file */
+ #define F_NOPROMPT    (1<<7)          /* don't ask for login name! */
+ #define F_LCUC                (1<<8)          /* Support for *LCUC stty modes 
*/
++#define F_KEEPSPEED   (1<<9)          /* Follow baud rate from kernel */
+
+ /* Storage for things detected while the login name was read. */
+
+@@ -203,7 +204,7 @@ void parse_args P_((int argc, char **arg
+ void parse_speeds P_((struct options *op, char *arg));
+ void update_utmp P_((char *line));
+ void open_tty P_((char *tty, struct termios *tp, int local));
+-void termio_init P_((struct termios *tp, int speed, struct options *op));
++void termio_init P_((struct termios *tp, struct options *op));
+ void auto_baud P_((struct termios *tp));
+ void do_prompt P_((struct options *op, struct termios *tp));
+ void next_speed P_((struct termios *tp, struct options *op));
+@@ -297,7 +298,7 @@ main(argc, argv)
+     tcsetpgrp(0, getpid());
+     /* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */
+     debug("calling termio_init\n");
+-    termio_init(&termios, options.speeds[FIRST_SPEED], &options);
++    termio_init(&termios, &options);
+
+     /* write the modem init string and DON'T flush the buffers */
+     if (options.flags & F_INITSTRING) {
+@@ -373,7 +374,7 @@ parse_args(argc, argv, op)
+     extern int optind;                        /* getopt */
+     int     c;
+
+-    while (isascii(c = getopt(argc, argv, "8I:LH:f:hil:mt:wUn"))) {
++    while (isascii(c = getopt(argc, argv, "8I:LH:f:hil:mst:wUn"))) {
+       switch (c) {
+       case '8':
+           op->eightbits = 1;
+@@ -443,6 +444,9 @@ parse_args(argc, argv, op)
+       case 'n':
+           op->flags |= F_NOPROMPT;
+           break;
++      case 's':
++          op->flags |= F_KEEPSPEED;           /* keep kernel defined speed */
++          break;
+       case 't':                               /* time out */
+           if ((op->timeout = atoi(optarg)) <= 0)
+               error(_("bad timeout value: %s"), optarg);
+@@ -691,11 +695,17 @@ char gbuf[1024];
+ char area[1024];
+
+ void
+-termio_init(tp, speed, op)
++termio_init(tp, op)
+      struct termios *tp;
+-     int     speed;
+      struct options *op;
+ {
++    speed_t ispeed, ospeed;
++
++    if (op->flags & F_KEEPSPEED) {
++      ispeed = cfgetispeed(tp);               /* save the original setting */
++      ospeed = cfgetospeed(tp);
++    } else
++      ospeed = ispeed = op->speeds[FIRST_SPEED];
+
+     /*
+      * Initial termios settings: 8-bit characters, raw-mode, blocking i/o.
+@@ -706,14 +716,20 @@ termio_init(tp, speed, op)
+     /* flush input and output queues, important for modems! */
+     (void) tcflush(0, TCIOFLUSH);
+
++    tp->c_iflag = tp->c_lflag = tp->c_oflag = 0;
++
+     tp->c_cflag = CS8 | HUPCL | CREAD;
+-    cfsetispeed(tp, speed);
+-    cfsetospeed(tp, speed);
++
++    /* Note that the speed is stored in the c_cflag termios field, so we have
++     * set the speed always when the cflag se reseted.
++     */
++    cfsetispeed(tp, ispeed);
++    cfsetospeed(tp, ospeed);
++
+     if (op->flags & F_LOCAL) {
+       tp->c_cflag |= CLOCAL;
+     }
+
+-    tp->c_iflag = tp->c_lflag = tp->c_oflag = 0;
+ #ifdef HAVE_STRUCT_TERMIOS_C_LINE
+     tp->c_line = 0;
+ #endif
+@@ -973,9 +989,18 @@ next_speed(tp, op)
+      struct termios *tp;
+      struct options *op;
+ {
+-    static int baud_index = FIRST_SPEED;/* current speed index */
++    static int baud_index = -1;
++
++    if (baud_index == -1)
++      /*
++       * if the F_KEEPSPEED flags is set then the FIRST_SPEED is not
++       * tested yet (see termio_init()).
++       */
++      baud_index = (op->flags & F_KEEPSPEED) ? FIRST_SPEED :
++                                               1 % op->numspeed;
++    else
++      baud_index = (baud_index + 1) % op->numspeed;
+
+-    baud_index = (baud_index + 1) % op->numspeed;
+     cfsetispeed(tp, op->speeds[baud_index]);
+     cfsetospeed(tp, op->speeds[baud_index]);
+     (void) tcsetattr(0, TCSANOW, tp);
+@@ -1203,7 +1228,7 @@ bcode(s)
+ void
+ usage()
+ {
+-    fprintf(stderr, _("Usage: %s [-8hiLmUw] [-l login_program] [-t timeout] 
[-I initstring] [-H login_host] baud_rate,... line [termtype]\nor\t[-hiLmw] [-l 
login_program] [-t timeout] [-I initstring] [-H login_host] line baud_rate,... 
[termtype]\n"), progname);
++    fprintf(stderr, _("Usage: %s [-8hiLmsUw] [-l login_program] [-t timeout] 
[-I initstring] [-H login_host] baud_rate,... line [termtype]\nor\t[-hiLmw] [-l 
login_program] [-t timeout] [-I initstring] [-H login_host] line baud_rate,... 
[termtype]\n"), progname);
+     exit(1);
+ }
+
diff --git a/source/base/util-linux-ng/util-linux-ng-2.18-fsck-wholedisk.patch 
b/source/base/util-linux-ng/util-linux-ng-2.18-fsck-wholedisk.patch
new file mode 100644
index 0000000..3718255
--- /dev/null
+++ b/source/base/util-linux-ng/util-linux-ng-2.18-fsck-wholedisk.patch
@@ -0,0 +1,510 @@
+diff -up util-linux-ng-2.18/fsck/fsck.8.kzak util-linux-ng-2.18/fsck/fsck.8
+--- util-linux-ng-2.18/fsck/fsck.8.kzak        2010-06-30 12:51:35.000000000 
+0200
++++ util-linux-ng-2.18/fsck/fsck.8     2010-10-26 23:55:30.000000000 +0200
+@@ -7,7 +7,7 @@
+ fsck \- check and repair a Linux file system
+ .SH SYNOPSIS
+ .B fsck
+-.RB [ \-sAVRTMNP ]
++.RB [ \-lsAVRTMNP ]
+ .RB [ \-C
+ .RI [ fd ]]
+ .RB [ \-t
+@@ -80,6 +80,17 @@ variable.  Please see the file system-sp
+ further details.
+ .SH OPTIONS
+ .TP
++.B \-l
++Lock whole-disk device by exclusive
++.BR flock (2).
++This option can be used with one device only (e.g. -A and -l are mutually
++exclusive). This option is recommended when more
++.B fsck (8)
++instances are executed in the same time. The option is ignored when used for
++multiple devices or for non-rotating disk. The fsck does not lock underlying
++devices if executed to check stacked devices (e.g. MD or DM) -- this feature 
is
++not implemented yet.
++.TP
+ .B \-s
+ Serialize
+ .B fsck
+@@ -200,6 +211,11 @@ If there are multiple filesystems with t
+ fsck will attempt to check them in parallel, although it will avoid running
+ multiple filesystem checks on the same physical disk.
+ .sp
++.B fsck
++does not check stacked devices (RAIDs, dm-crypt, ...) in parallel with any 
other
++device. See below for FSCK_FORCE_ALL_PARALLEL setting. The /sys filesystem is
++used to detemine dependencies between devices.
++.sp
+ Hence, a very common configuration in
+ .I /etc/fstab
+ files is to set the root filesystem to have a
+@@ -366,10 +382,10 @@ program's behavior is affected by the fo
+ .B FSCK_FORCE_ALL_PARALLEL
+ If this environment variable is set,
+ .B fsck
+-will attempt to run all of the specified filesystems in parallel,
+-regardless of whether the filesystems appear to be on the same
+-device.  (This is useful for RAID systems or high-end storage systems
+-such as those sold by companies such as IBM or EMC.)
++will attempt to run all of the specified filesystems in parallel, regardless 
of
++whether the filesystems appear to be on the same device.  (This is useful for
++RAID systems or high-end storage systems such as those sold by companies such
++as IBM or EMC.) Note that the fs_passno value is still used.
+ .TP
+ .B FSCK_MAX_INST
+ This environment variable will limit the maximum number of file system
+diff -up util-linux-ng-2.18/fsck/fsck.c.kzak util-linux-ng-2.18/fsck/fsck.c
+--- util-linux-ng-2.18/fsck/fsck.c.kzak        2010-05-19 23:36:23.000000000 
+0200
++++ util-linux-ng-2.18/fsck/fsck.c     2010-10-26 23:55:30.000000000 +0200
+@@ -31,6 +31,8 @@
+ #include <sys/wait.h>
+ #include <sys/signal.h>
+ #include <sys/stat.h>
++#include <sys/file.h>
++#include <fcntl.h>
+ #include <limits.h>
+ #include <stdio.h>
+ #include <ctype.h>
+@@ -42,6 +44,8 @@
+ #include <errno.h>
+ #include <malloc.h>
+ #include <signal.h>
++#include <dirent.h>
++#include <blkid.h>
+
+ #include "fsprobe.h"
+
+@@ -85,6 +89,7 @@ char *devices[MAX_DEVICES];
+ char *args[MAX_ARGS];
+ int num_devices, num_args;
+
++int lockdisk = 0;
+ int verbose = 0;
+ int doall = 0;
+ int noexecute = 0;
+@@ -214,11 +219,97 @@ static void parse_escape(char *word)
+       *q = 0;
+ }
+
++static dev_t get_disk(const char *device)
++{
++      struct stat st;
++      dev_t disk;
++
++      if (!stat(device, &st) &&
++          !blkid_devno_to_wholedisk(st.st_rdev, NULL, 0, &disk))
++              return disk;
++
++      return 0;
++}
++
++static int is_irrotational_disk(dev_t disk)
++{
++      char path[PATH_MAX];
++      FILE *f;
++      int rc, x;
++
++      rc = snprintf(path, sizeof(path),
++                      "/sys/dev/block/%d:%d/queue/rotational",
++                      major(disk), minor(disk));
++
++      if (rc < 0 || rc + 1 > sizeof(path))
++              return 0;
++
++      f = fopen(path, "r");
++      if (!f)
++              return 0;
++
++      rc = fscanf(f, "%u", &x);
++      fclose(f);
++
++      return rc == 1 ? !x : 0;
++}
++
++static void lock_disk(struct fsck_instance *inst)
++{
++      dev_t disk = inst->fs->disk ? : get_disk(inst->fs->device);
++      char *diskname;
++
++      if (!disk || is_irrotational_disk(disk))
++              return;
++
++      diskname = blkid_devno_to_devname(disk);
++      if (!diskname)
++              return;
++
++      if (verbose)
++              printf(_("Locking disk %s ... "), diskname);
++
++      inst->lock = open(diskname, O_CLOEXEC | O_RDONLY);
++      if (inst->lock >= 0) {
++              int rc = -1;
++
++              /* inform users that we're waiting on the lock */
++              if (verbose &&
++                  (rc = flock(inst->lock, LOCK_EX | LOCK_NB)) != 0 &&
++                  errno == EWOULDBLOCK)
++                      printf(_("(waiting) "));
++
++              if (rc != 0 && flock(inst->lock, LOCK_EX) != 0) {
++                      close(inst->lock);                      /* failed */
++                      inst->lock = -1;
++              }
++      }
++
++      if (verbose)
++              printf("%s.\n", inst->lock >= 0 ? _("success") : _("failed"));
++
++      free(diskname);
++      return;
++}
++
++static void unlock_disk(struct fsck_instance *inst)
++{
++      if (inst->lock >= 0) {
++              /* explicitly unlock, don't rely on close(), maybe some library
++               * (e.g. liblkid) has still open the device.
++               */
++              flock(inst->lock, LOCK_UN);
++              close(inst->lock);
++      }
++}
++
++
++
+ static void free_instance(struct fsck_instance *i)
+ {
++      if (lockdisk)
++              unlock_disk(i);
+       free(i->prog);
+-      free(i->device);
+-      free(i->base_device);
+       free(i);
+       return;
+ }
+@@ -240,6 +331,8 @@ static struct fs_info *create_fs_device(
+       fs->passno = passno;
+       fs->flags = 0;
+       fs->next = NULL;
++      fs->disk = 0;
++      fs->stacked = 0;
+
+       if (!filesys_info)
+               filesys_info = fs;
+@@ -414,8 +507,7 @@ static int progress_active(NOARGS)
+  * Execute a particular fsck program, and link it into the list of
+  * child processes we are waiting for.
+  */
+-static int execute(const char *type, const char *device, const char *mntpt,
+-                 int interactive)
++static int execute(const char *type, struct fs_info *fs, int interactive)
+ {
+       char *s, *argv[80], prog[80];
+       int  argc, i;
+@@ -452,7 +544,7 @@ static int execute(const char *type, con
+               }
+       }
+
+-      argv[argc++] = string_copy(device);
++      argv[argc++] = string_copy(fs->device);
+       argv[argc] = 0;
+
+       s = find_fsck(prog);
+@@ -464,12 +556,19 @@ static int execute(const char *type, con
+
+       if (verbose || noexecute) {
+               printf("[%s (%d) -- %s] ", s, num_running,
+-                     mntpt ? mntpt : device);
++                     fs->mountpt ? fs->mountpt : fs->device);
+               for (i=0; i < argc; i++)
+                       printf("%s ", argv[i]);
+               printf("\n");
+       }
+
++
++      inst->fs = fs;
++      inst->lock = -1;
++
++      if (lockdisk)
++              lock_disk(inst);
++
+       /* Fork and execute the correct program. */
+       if (noexecute)
+               pid = -1;
+@@ -492,8 +591,6 @@ static int execute(const char *type, con
+       inst->pid = pid;
+       inst->prog = string_copy(prog);
+       inst->type = string_copy(type);
+-      inst->device = string_copy(device);
+-      inst->base_device = base_device(device);
+       inst->start_time = time(0);
+       inst->next = NULL;
+
+@@ -597,12 +694,12 @@ static struct fsck_instance *wait_one(in
+               } else {
+                       printf(_("Warning... %s for device %s exited "
+                              "with signal %d.\n"),
+-                             inst->prog, inst->device, sig);
++                             inst->prog, inst->fs->device, sig);
+                       status = EXIT_ERROR;
+               }
+       } else {
+               printf(_("%s %s: status is %x, should never happen.\n"),
+-                     inst->prog, inst->device, status);
++                     inst->prog, inst->fs->device, status);
+               status = EXIT_ERROR;
+       }
+       inst->exit_status = status;
+@@ -641,7 +738,7 @@ ret_inst:
+               instance_list = inst->next;
+       if (verbose > 1)
+               printf(_("Finished with %s (exit status %d)\n"),
+-                     inst->device, inst->exit_status);
++                     inst->fs->device, inst->exit_status);
+       num_running--;
+       return inst;
+ }
+@@ -698,7 +795,7 @@ static void fsck_device(struct fs_info *
+               type = DEFAULT_FSTYPE;
+
+       num_running++;
+-      retval = execute(type, fs->device, fs->mountpt, interactive);
++      retval = execute(type, fs, interactive);
+       if (retval) {
+               fprintf(stderr, _("%s: Error %d while executing fsck.%s "
+                       "for %s\n"), progname, retval, type, fs->device);
+@@ -924,40 +1021,70 @@ static int ignore(struct fs_info *fs)
+       return 0;
+ }
+
++static int count_slaves(dev_t disk)
++{
++      DIR *dir;
++      struct dirent *dp;
++      char dirname[PATH_MAX];
++      int count = 0;
++
++      snprintf(dirname, sizeof(dirname),
++                      "/sys/dev/block/%u:%u/slaves/",
++                      major(disk), minor(disk));
++
++      if (!(dir = opendir(dirname)))
++              return -1;
++
++      while ((dp = readdir(dir)) != 0) {
++#ifdef _DIRENT_HAVE_D_TYPE
++              if (dp->d_type != DT_UNKNOWN && dp->d_type != DT_LNK)
++                      continue;
++#endif
++              if (dp->d_name[0] == '.' &&
++                  ((dp->d_name[1] == 0) ||
++                   ((dp->d_name[1] == '.') && (dp->d_name[2] == 0))))
++                      continue;
++
++              count++;
++      }
++      closedir(dir);
++      return count;
++}
++
+ /*
+  * Returns TRUE if a partition on the same disk is already being
+  * checked.
+  */
+-static int device_already_active(char *device)
++static int disk_already_active(struct fs_info *fs)
+ {
+       struct fsck_instance *inst;
+-      char *base;
+
+       if (force_all_parallel)
+               return 0;
+
+-#ifdef BASE_MD
+-      /* Don't check a soft raid disk with any other disk */
+-      if (instance_list &&
+-          (!strncmp(instance_list->device, BASE_MD, sizeof(BASE_MD)-1) ||
+-           !strncmp(device, BASE_MD, sizeof(BASE_MD)-1)))
++      if (instance_list && instance_list->fs->stacked)
++              /* any instance for a stacked device is already running */
+               return 1;
+-#endif
+
+-      base = base_device(device);
++      if (!fs->disk) {
++              fs->disk = get_disk(fs->device);
++              if (fs->disk)
++                      fs->stacked = count_slaves(fs->disk);
++      }
++
+       /*
+        * If we don't know the base device, assume that the device is
+        * already active if there are any fsck instances running.
++       *
++       * Don't check a stacked device with any other disk too.
+        */
+-      if (!base)
++      if (!fs->disk || fs->stacked)
+               return (instance_list != 0);
++
+       for (inst = instance_list; inst; inst = inst->next) {
+-              if (!inst->base_device || !strcmp(base, inst->base_device)) {
+-                      free(base);
++              if (!inst->fs->disk || fs->disk == inst->fs->disk)
+                       return 1;
+-              }
+       }
+-      free(base);
+       return 0;
+ }
+
+@@ -1038,7 +1165,7 @@ static int check_all(NOARGS)
+                        * already been spawned, then we need to defer
+                        * this to another pass.
+                        */
+-                      if (device_already_active(fs->device)) {
++                      if (disk_already_active(fs)) {
+                               pass_done = 0;
+                               continue;
+                       }
+@@ -1188,6 +1315,9 @@ static void PRS(int argc, char *argv[])
+                                       }
+                               }
+                               break;
++                      case 'l':
++                              lockdisk++;
++                              break;
+                       case 'V':
+                               verbose++;
+                               break;
+@@ -1298,6 +1428,12 @@ int main(int argc, char *argv[])
+       if ((num_devices == 1) || (serialize))
+               interactive = 1;
+
++      if (lockdisk && (doall || num_devices > 1)) {
++              fprintf(stderr, _("%s: the -l option can be used with one "
++                                "device only -- ignore\n"), progname);
++              lockdisk = 0;
++      }
++
+       /* If -A was specified ("check all"), do that! */
+       if (doall)
+               return check_all();
+diff -up util-linux-ng-2.18/fsck/fsck.h.kzak util-linux-ng-2.18/fsck/fsck.h
+--- util-linux-ng-2.18/fsck/fsck.h.kzak        2010-03-18 23:11:23.000000000 
+0100
++++ util-linux-ng-2.18/fsck/fsck.h     2010-10-26 23:55:30.000000000 +0200
+@@ -44,6 +44,8 @@ struct fs_info {
+       int   freq;
+       int   passno;
+       int   flags;
++      dev_t disk;
++      int   stacked;
+       struct fs_info *next;
+ };
+
+@@ -56,12 +58,12 @@ struct fs_info {
+ struct fsck_instance {
+       int     pid;
+       int     flags;
++      int     lock;           /* flock()ed whole disk file descriptor or -1 */
+       int     exit_status;
+       time_t  start_time;
+       char *  prog;
+       char *  type;
+-      char *  device;
+-      char *  base_device;
++      struct fs_info *fs;
+       struct fsck_instance *next;
+ };
+
+diff -up util-linux-ng-2.18/fsck/Makefile.am.kzak 
util-linux-ng-2.18/fsck/Makefile.am
+--- util-linux-ng-2.18/fsck/Makefile.am.kzak   2010-05-24 12:33:46.000000000 
+0200
++++ util-linux-ng-2.18/fsck/Makefile.am        2010-10-26 23:55:30.000000000 
+0200
+@@ -3,7 +3,7 @@ include $(top_srcdir)/config/include-Mak
+ sbin_PROGRAMS = fsck
+ dist_man_MANS = fsck.8
+
+-fsck_SOURCES = base_device.c fsck.c fsck.h $(top_srcdir)/lib/ismounted.c \
++fsck_SOURCES = fsck.c fsck.h $(top_srcdir)/lib/ismounted.c \
+              $(top_srcdir)/lib/fsprobe.c $(top_srcdir)/lib/canonicalize.c
+ fsck_LDADD =
+ fsck_CFLAGS = $(AM_CFLAGS)
+diff -up util-linux-ng-2.18/fsck/Makefile.in.kzak 
util-linux-ng-2.18/fsck/Makefile.in
+--- util-linux-ng-2.18/fsck/Makefile.in.kzak   2010-10-26 23:56:04.000000000 
+0200
++++ util-linux-ng-2.18/fsck/Makefile.in        2010-10-26 23:56:15.000000000 
+0200
+@@ -62,9 +62,8 @@ CONFIG_CLEAN_FILES =
+ CONFIG_CLEAN_VPATH_FILES =
+ am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"
+ PROGRAMS = $(sbin_PROGRAMS)
+-am_fsck_OBJECTS = fsck-base_device.$(OBJEXT) fsck-fsck.$(OBJEXT) \
+-      fsck-ismounted.$(OBJEXT) fsck-fsprobe.$(OBJEXT) \
+-      fsck-canonicalize.$(OBJEXT)
++am_fsck_OBJECTS = fsck-fsck.$(OBJEXT) fsck-ismounted.$(OBJEXT) \
++      fsck-fsprobe.$(OBJEXT) fsck-canonicalize.$(OBJEXT)
+ fsck_OBJECTS = $(am_fsck_OBJECTS)
+ am__DEPENDENCIES_1 =
+ @build_libblkid_fa...@am__dependencies_2 = $(am__DEPENDENCIES_1)
+@@ -204,6 +203,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+ PACKAGE_NAME = @PACKAGE_NAME@
+ PACKAGE_STRING = @PACKAGE_STRING@
+ PACKAGE_TARNAME = @PACKAGE_TARNAME@
++PACKAGE_URL = @PACKAGE_URL@
+ PACKAGE_VERSION = @PACKAGE_VERSION@
+ PATH_SEPARATOR = @PATH_SEPARATOR@
+ PERL = @PERL@
+@@ -315,7 +315,7 @@ ul_libmount_la = $(top_builddir)/shlibs/
+ # mount.h is generated by ./configure script and stored in build directory
+ ul_libmount_incdir = $(ul_libmount_builddir)
+ dist_man_MANS = fsck.8
+-fsck_SOURCES = base_device.c fsck.c fsck.h $(top_srcdir)/lib/ismounted.c \
++fsck_SOURCES = fsck.c fsck.h $(top_srcdir)/lib/ismounted.c \
+              $(top_srcdir)/lib/fsprobe.c $(top_srcdir)/lib/canonicalize.c
+
+ fsck_LDADD = $(am__append_1) $(am__append_3)
+@@ -407,7 +407,6 @@ mostlyclean-compile:
+ distclean-compile:
+       -rm -f *.tab.c
+
+...@amdep_true@@am__include@ 
@am__qu...@./$(DEPDIR)/fsck-base_device...@am__quote@
+ @AMDEP_TRUE@@am__include@ 
@am__qu...@./$(DEPDIR)/fsck-canonicalize...@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__qu...@./$(DEPDIR)/fsck-fsck...@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__qu...@./$(DEPDIR)/fsck-fsprobe...@am__quote@
+@@ -437,22 +436,6 @@ distclean-compile:
+ @AMDEP_TRUE@@am__fastdepCC_FALSE@     DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+-fsck-base_device.o: base_device.c
+...@am__fastdepcc_true@        $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fsck_CFLAGS) $(CFLAGS) -MT 
fsck-base_device.o -MD -MP -MF $(DEPDIR)/fsck-base_device.Tpo -c -o 
fsck-base_device.o `test -f 'base_device.c' || echo '$(srcdir)/'`base_device.c
+...@am__fastdepcc_true@        $(AM_V_at)$(am__mv) 
$(DEPDIR)/fsck-base_device.Tpo $(DEPDIR)/fsck-base_device.Po
+...@am__fastdepcc_false@       $(AM_V_CC) @AM_BACKSLASH@
+...@amdep_true@@am__fastdepCC_FALSE@   source='base_device.c' 
object='fsck-base_device.o' libtool=no @AMDEPBACKSLASH@
+...@amdep_true@@am__fastdepCC_FALSE@   DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+...@am__fastdepcc_false@       $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(fsck_CFLAGS) $(CFLAGS) -c -o fsck-base_device.o 
`test -f 'base_device.c' || echo '$(srcdir)/'`base_device.c
+-
+-fsck-base_device.obj: base_device.c
+...@am__fastdepcc_true@        $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(fsck_CFLAGS) $(CFLAGS) -MT 
fsck-base_device.obj -MD -MP -MF $(DEPDIR)/fsck-base_device.Tpo -c -o 
fsck-base_device.obj `if test -f 'base_device.c'; then $(CYGPATH_W) 
'base_device.c'; else $(CYGPATH_W) '$(srcdir)/base_device.c'; fi`
+...@am__fastdepcc_true@        $(AM_V_at)$(am__mv) 
$(DEPDIR)/fsck-base_device.Tpo $(DEPDIR)/fsck-base_device.Po
+...@am__fastdepcc_false@       $(AM_V_CC) @AM_BACKSLASH@
+...@amdep_true@@am__fastdepCC_FALSE@   source='base_device.c' 
object='fsck-base_device.obj' libtool=no @AMDEPBACKSLASH@
+...@amdep_true@@am__fastdepCC_FALSE@   DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
+...@am__fastdepcc_false@       $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(fsck_CFLAGS) $(CFLAGS) -c -o fsck-base_device.obj 
`if test -f 'base_device.c'; then $(CYGPATH_W) 'base_device.c'; else 
$(CYGPATH_W) '$(srcdir)/base_device.c'; fi`
+-
+ fsck-fsck.o: fsck.c
+ @am__fastdepCC_TRUE@  $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(AM_CPPFLAGS) $(CPPFLAGS) $(fsck_CFLAGS) $(CFLAGS) -MT fsck-fsck.o -MD -MP -MF 
$(DEPDIR)/fsck-fsck.Tpo -c -o fsck-fsck.o `test -f 'fsck.c' || echo 
'$(srcdir)/'`fsck.c
+ @am__fastdepCC_TRUE@  $(AM_V_at)$(am__mv) $(DEPDIR)/fsck-fsck.Tpo 
$(DEPDIR)/fsck-fsck.Po
+diff -up util-linux-ng-2.18/Makefile.am.kzak util-linux-ng-2.18/Makefile.am
+--- util-linux-ng-2.18/Makefile.am.kzak        2010-03-18 23:11:23.000000000 
+0100
++++ util-linux-ng-2.18/Makefile.am     2010-10-26 23:55:30.000000000 +0200
+@@ -30,8 +30,10 @@ SUBDIRS += mount
+ endif
+
+ if BUILD_FSCK
++if BUILD_LIBBLKID
+ SUBDIRS += fsck
+ endif
++endif
+
+ ACLOCAL_AMFLAGS = -I m4
+
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to