Util-Linux package development
 help / color / mirror / Atom feed
* Re: dmesg(1) changes
From: Lennart Poettering @ 2011-07-14 12:40 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110714115231.GF3486@nb.net.home>

On Thu, 14.07.11 13:52, Karel Zak (kzak@redhat.com) wrote:

>  * add --facility=<LIST> option to filter out messages, for example:
> 
>     $ dmesg --facility=daemon,user
>     [    1.802065] dracut: dracut-009-11.fc15
>     [    1.811267] dracut: rd.luks=0: removing cryptoluks activation
>     [    1.813913] dracut: rd.lvm=0: removing LVM activation
>     [    1.819348] udev[111]: starting version 167
> 
> 
> Comments & suggestions?

This is really cool! Thanks a lot for implementing this!

One last thing on my wishlist: "dmesg -k" as alias for "dmesg
--facility=kern", just to make this presumably very often requested
switch is easy to reach.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.

^ permalink raw reply

* dmesg(1) changes
From: Karel Zak @ 2011-07-14 11:52 UTC (permalink / raw)
  To: util-linux; +Cc: Lennart Poettering


 Hi,

I did some changes to dmesg(1) in last days:

 * \x<hex> encoding is used for non-printable chars and invalid 
   multibyte sequences

 * add --decode option to decode facility and level (priotity) number to
   human readable prefixes, for example:

    $ dmesg --decode
    kern  :info  : [53335.593617] ata1.00: configured for UDMA/100
    kern  :info  : [53335.743185] PM: resume of devices complete after 2496.795 msecs
    kern  :debug : [53335.743593] PM: Finishing wakeup.
    kern  :warn  : [53335.743595] Restarting tasks ... done.
    kern  :info  : [53335.790452] video LNXVIDEO:00: Restoring backlight state

 * add --facility=<LIST> option to filter out messages, for example:

    $ dmesg --facility=daemon,user
    [    1.802065] dracut: dracut-009-11.fc15
    [    1.811267] dracut: rd.luks=0: removing cryptoluks activation
    [    1.813913] dracut: rd.lvm=0: removing LVM activation
    [    1.819348] udev[111]: starting version 167

 * add --level=<LIST> option to filter out messages, for example:

    $ dmesg --level=debug,info

    $ dmesg --facility=kern --level=warn,err

 * add --clear option to clear the kernel ring buffer

 * add --read-clear to read and clear the kernel ring buffer

 * add --console-off and --console-on to control output to console

 * -n <LEVEL> (--console-level) supports human readable level names,
   for example:

    $ dmesg --console-level=emerg,alert

Comments & suggestions?

    Karel
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply

* Re: [PATCH] minix: v3 super-block does not have s_state field
From: Karel Zak @ 2011-07-14  9:18 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: kerolasa, util-linux
In-Reply-To: <1310609005.3482.0.camel@offbook>

On Wed, Jul 13, 2011 at 10:03:25PM -0400, Davidlohr Bueso wrote:
> >  Ignore kernel, 2. is right in this case.
> 
> Yep, I agree. Karel, if you have no objections then please apply my
> patch as it does fix the sb mismatch.

 Applied. It would be nice to clean up the superblocks definitions
 (use POSIX int types), move it to include/minix.h and use it for
 libblkid too.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply

* Re: [PATCH] minix: v3 super-block does not have s_state field
From: Davidlohr Bueso @ 2011-07-14  2:03 UTC (permalink / raw)
  To: Karel Zak; +Cc: kerolasa, util-linux
In-Reply-To: <20110713173430.GD3486@nb.net.home>

On Wed, 2011-07-13 at 19:34 +0200, Karel Zak wrote:
> On Wed, Jul 13, 2011 at 04:54:22PM +0200, Sami Kerola wrote:
> > On Wed, Jul 13, 2011 at 14:12, Karel Zak <kzak@redhat.com> wrote:
> > > On Wed, Jul 13, 2011 at 01:33:03PM +0200, Sami Kerola wrote:
> > >> On Wed, Jul 13, 2011 at 06:05, Davidlohr Bueso <dave@gnu.org> wrote:
> > >> > I don't think we should always rely on having the kernel headers, =
that's
> > >> > why the fallback is provided.
> > >> [snip]
> > >> > I think with this patch we address the issue without removing our
> > >> > fallback.
> > >>
> > >> The preprocessor directive bellow is problematic. I don't see where,
> > >> or how, it might get satisfied so I am afraid the 'fall back' is
> > >> always in use regardless whether an user has kernel headers or not.
> > >>
> > >> #ifdef KERNEL_INCLUDES_ARE_CLEAN
> > >>
> > >> To fix that I modified the patch to use autoconf to check whether ea=
ch
> > >> necessary header is present, and use them if possible. Notice that
> > >> Dave that I wrote your name to Reviewed-by patch line so it would be
> > >> nice to hear that you're OK with the change. See the attachment, or
> > >> pull from my repository.
> > >
> > >  This is wrong way... the kernel types (e.g. u32, s64) are
> > >  *unexpected* in util-linux. The new code should not use this junk. W=
e
> > >  have <stdint.h> and <inttypes.h>.
> >=20
> > Fixed.
> >=20
> > >  The mkfs.minix should not depend on kernel headers. It's normal that
> > >  we use our own (on kernel independent) copy of FS superbloks. See
> > >  libblkid code.
> >=20
> > By depend do you mean;
> >=20
> > 1. Distrust that kernel headers are present, and have alternative
> > copy, but use them when they are present.
> > 2. Use always util-linux copy of structures ignoring the possible
> > header even they might be present.
>=20
>  Ignore kernel, 2. is right in this case.

Yep, I agree. Karel, if you have no objections then please apply my
patch as it does fix the sb mismatch.

Thanks.

>=20
>     Karel

^ permalink raw reply

* Re: `fsck -A` and fs-specific options
From: Mike Frysinger @ 2011-07-13 18:31 UTC (permalink / raw)
  To: Theodore Tso; +Cc: util-linux
In-Reply-To: <EFBAB464-FF32-46CB-8BB9-A94CE880F730@mit.edu>

[-- Attachment #1: Type: Text/Plain, Size: 993 bytes --]

On Wednesday, July 13, 2011 07:17:27 Theodore Tso wrote:
> On Jul 12, 2011, at 3:18 PM, Mike Frysinger wrote:
> > when i read the kernel source, that seemed to be the case.  but i dont
> > think it's the case for reiserfs, and i think there's a very tiny edge
> > case with ext[34] related to moving the journal, but probably so small
> > we can ignore it :p.
> 
> What do you think the edge case is?   Yes, the external journal's
> dev_t is cached, but that is only used by the kernel since it
> was simpler than having callouts to a userspace daemon.
> 
> E2fsck will use blkid to locate the external journal, and when it
> finds it, it will update the cached dev_t if it is out of date, so that
> at mount time the kernel will be able to find the external journal.
> This way even if the external journal is on a device with an
> unstable dev_t (e.g., a USB device), the right thing should
> happen...

that sounds like it covers all the non-pathological cases ;)
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH] minix: v3 super-block does not have s_state field
From: Karel Zak @ 2011-07-13 17:34 UTC (permalink / raw)
  To: kerolasa; +Cc: dave, util-linux
In-Reply-To: <CAG27Bk2m+d=N9yVTSbByzhfkMUmP-d7heQXS643uWE3n+05+Mw@mail.gmail.com>

On Wed, Jul 13, 2011 at 04:54:22PM +0200, Sami Kerola wrote:
> On Wed, Jul 13, 2011 at 14:12, Karel Zak <kzak@redhat.com> wrote:
> > On Wed, Jul 13, 2011 at 01:33:03PM +0200, Sami Kerola wrote:
> >> On Wed, Jul 13, 2011 at 06:05, Davidlohr Bueso <dave@gnu.org> wrote:
> >> > I don't think we should always rely on having the kernel headers, that's
> >> > why the fallback is provided.
> >> [snip]
> >> > I think with this patch we address the issue without removing our
> >> > fallback.
> >>
> >> The preprocessor directive bellow is problematic. I don't see where,
> >> or how, it might get satisfied so I am afraid the 'fall back' is
> >> always in use regardless whether an user has kernel headers or not.
> >>
> >> #ifdef KERNEL_INCLUDES_ARE_CLEAN
> >>
> >> To fix that I modified the patch to use autoconf to check whether each
> >> necessary header is present, and use them if possible. Notice that
> >> Dave that I wrote your name to Reviewed-by patch line so it would be
> >> nice to hear that you're OK with the change. See the attachment, or
> >> pull from my repository.
> >
> >  This is wrong way... the kernel types (e.g. u32, s64) are
> >  *unexpected* in util-linux. The new code should not use this junk. We
> >  have <stdint.h> and <inttypes.h>.
> 
> Fixed.
> 
> >  The mkfs.minix should not depend on kernel headers. It's normal that
> >  we use our own (on kernel independent) copy of FS superbloks. See
> >  libblkid code.
> 
> By depend do you mean;
> 
> 1. Distrust that kernel headers are present, and have alternative
> copy, but use them when they are present.
> 2. Use always util-linux copy of structures ignoring the possible
> header even they might be present.

 Ignore kernel, 2. is right in this case.

    Karel
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply

* Re: Error in man page for fstab
From: Brad Goodman @ 2011-07-13 15:54 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110713084243.GB3486@nb.net.home>

On Wed, Jul 13, 2011 at 4:42 AM, Karel Zak <kzak@redhat.com> wrote:
> On Tue, Jul 12, 2011 at 12:21:58PM -0400, Brad Goodman wrote:
>> The fstab man page contains the following text:
>>
>> >> The third field, (fs_vfstype) ... An entry "none" is  useful  for bind or move mounts
>>
>> "none" is interpreted as an actual vfstype, which does not have the
>> intended consequences.
>
>  The bind mounts are completely independent on FS type. The type does
>  not make sense here. The recent version of the mount(8) always
>  overwrites the FS type to "none" for all MS_BIND, MS_MOVE and
>  MS_PROPAGATION operations.
>

If I specify "none" as the third parameter in fstab, and try to mount
a DVD, I get an error on mount:

Unrecognized fs type "none"

If I change this to "auto", it correctly mounts as iso9660.

-BKG

^ permalink raw reply

* Fake block devices (Was Re: `fsck -A` and fs-specific options)
From: David Zeuthen @ 2011-07-13 15:03 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110713083214.GA3486@nb.net.home>

Hey,

On Wed, 2011-07-13 at 10:32 +0200, Karel Zak wrote:
>  Good point. There is demand for a generic API to assemble block
>  devices (dm-crypt, MD, LVM, loopdev, ...). This functionality has
>  been requested by desktop guys, dracut, udev and it seems also
>  attractive for mount and fsck. I'll probably start to work on this
>  task at the end of this year (I hope with DM guys).
> 
>  The idea is to have a simple library (libblkasm ?) that provide API
>  to assemble a block device according to the configuration in
>  /etc/fstab and /etc/blkasm.d/. The library should be modular, so
>  subsystem specific modules (lvm.so, crypt.so, ...) will be maintained
>  externally by subsystem developers. It seems like a good way how to
>  keep the functionality up to date and minimize some communication
>  problems between people :-)
> 
>  Note that the original idea is from David Zeuthen
>  http://people.freedesktop.org/~david/stc-20101011/stc.conf.html, but
>  David's goal was daemon.

FWIW, I've changed my mind about this. Basically, I don't think it's
worth supporting fake block devices (except for dm-luks and maybe loop
devices). Specifically, I will not support it in the next major version
of GNOME Disk Utility (aka Palimpsest) except for showing the "friendly"
dm name (e.g. /dev/mapper/blah) instead of /dev/dm-0. Here's a
work-in-progress screenshot

http://people.freedesktop.org/~david/palimpsest-with-fake-block-devices.png

(Compare to: http://people.freedesktop.org/~david/nautilus-lvm2-b.png )

Anyway, I think it would be better if people instead worked on e.g.
btrfs and making we properly support multi-disk in btrfs... because
btrfs multi-disk is subject to exactly the same problems as you have
when activating RAID or LVM devices (except that you can't do arbitrary
trees - which is a good thing!). For example, there's a policy decision
when to start a device in degraded mode. And, IIRC, the kernel don't
even properly convey what underlying devices a btrfs fs is currently
using  (it didn't last time I checked which is ~12 months ago).

    David



^ permalink raw reply

* Re: [PATCH] minix: v3 super-block does not have s_state field
From: Sami Kerola @ 2011-07-13 14:54 UTC (permalink / raw)
  To: Karel Zak; +Cc: dave, util-linux
In-Reply-To: <20110713121232.GC3486@nb.net.home>

On Wed, Jul 13, 2011 at 14:12, Karel Zak <kzak@redhat.com> wrote:
> On Wed, Jul 13, 2011 at 01:33:03PM +0200, Sami Kerola wrote:
>> On Wed, Jul 13, 2011 at 06:05, Davidlohr Bueso <dave@gnu.org> wrote:
>> > I don't think we should always rely on having the kernel headers, that=
's
>> > why the fallback is provided.
>> [snip]
>> > I think with this patch we address the issue without removing our
>> > fallback.
>>
>> The preprocessor directive bellow is problematic. I don't see where,
>> or how, it might get satisfied so I am afraid the 'fall back' is
>> always in use regardless whether an user has kernel headers or not.
>>
>> #ifdef KERNEL_INCLUDES_ARE_CLEAN
>>
>> To fix that I modified the patch to use autoconf to check whether each
>> necessary header is present, and use them if possible. Notice that
>> Dave that I wrote your name to Reviewed-by patch line so it would be
>> nice to hear that you're OK with the change. See the attachment, or
>> pull from my repository.
>
> =A0This is wrong way... the kernel types (e.g. u32, s64) are
> =A0*unexpected* in util-linux. The new code should not use this junk. We
> =A0have <stdint.h> and <inttypes.h>.

Fixed.

> =A0The mkfs.minix should not depend on kernel headers. It's normal that
> =A0we use our own (on kernel independent) copy of FS superbloks. See
> =A0libblkid code.

By depend do you mean;

1. Distrust that kernel headers are present, and have alternative
copy, but use them when they are present.
2. Use always util-linux copy of structures ignoring the possible
header even they might be present.

I assumed the 1 is correct. If the 2 is correct then Dave's patch
should be applied and I'll redo rest of the patches.

> =A0There is libblkid/src/superblocks/minix.c where are minix
> =A0superblocks, it would be probably better to move the superblocks to
> =A0iniclude/minix.h and use it everywhere.

So something like the next 4 changes.

The following changes since commit bfa8d39b5826b928deb6d84aee3a4a1d6557364c=
:

  build-sys: fix spaces versus tabs conflict (2011-07-11 15:12:06 +0200)

are available in the git repository at:
  https://github.com/kerolasa/lelux-utiliteetit minix

Sami Kerola (5):
      minix: v3 super-block does not have s_state field
      minix: use data types from stdint.h
      minix: move minix.h to include directory
      libblkid: use superblock structure from minix.h
      libblkid: use BLOCK_SIZE from minix.h

 configure.ac                     |    5 ++
 disk-utils/Makefile.am           |    4 +-
 disk-utils/mkfs.minix.c          |    2 -
 include/Makefile.am              |    1 +
 {disk-utils =3D> include}/minix.h  |  148 ++++++++++++++++++++++----------=
------
 libblkid/src/superblocks/minix.c |   37 +---------
 6 files changed, 96 insertions(+), 101 deletions(-)
 rename {disk-utils =3D> include}/minix.h (59%)

--=20
=A0=A0 Sami Kerola
=A0=A0 http://www.iki.fi/kerolasa/

^ permalink raw reply

* Re: [PATCH] minix: v3 super-block does not have s_state field
From: Karel Zak @ 2011-07-13 12:12 UTC (permalink / raw)
  To: kerolasa; +Cc: dave, util-linux
In-Reply-To: <CAG27Bk0vW2LZySAf8B38OBbVaXpSDP81C+wVuA1vSW1rwhgwgg@mail.gmail.com>

On Wed, Jul 13, 2011 at 01:33:03PM +0200, Sami Kerola wrote:
> On Wed, Jul 13, 2011 at 06:05, Davidlohr Bueso <dave@gnu.org> wrote:
> > I don't think we should always rely on having the kernel headers, that's
> > why the fallback is provided.
> [snip]
> > I think with this patch we address the issue without removing our
> > fallback.
> 
> Hi Dave et.al.
> 
> The preprocessor directive bellow is problematic. I don't see where,
> or how, it might get satisfied so I am afraid the 'fall back' is
> always in use regardless whether an user has kernel headers or not.
> 
> #ifdef KERNEL_INCLUDES_ARE_CLEAN
> 
> To fix that I modified the patch to use autoconf to check whether each
> necessary header is present, and use them if possible. Notice that
> Dave that I wrote your name to Reviewed-by patch line so it would be
> nice to hear that you're OK with the change. See the attachment, or
> pull from my repository.

 This is wrong way... the kernel types (e.g. u32, s64) are
 *unexpected* in util-linux. The new code should not use this junk. We
 have <stdint.h> and <inttypes.h>.
 
 The mkfs.minix should not depend on kernel headers. It's normal that
 we use our own (on kernel independent) copy of FS superbloks. See
 libblkid code.

 There is libblkid/src/superblocks/minix.c where are minix
 superblocks, it would be probably better to move the superblocks to
 iniclude/minix.h and use it everywhere.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply

* Re: [PATCH] minix: v3 super-block does not have s_state field
From: Sami Kerola @ 2011-07-13 11:33 UTC (permalink / raw)
  To: dave; +Cc: util-linux
In-Reply-To: <1310529931.4444.7.camel@offbook>

[-- Attachment #1: Type: text/plain, Size: 1429 bytes --]

On Wed, Jul 13, 2011 at 06:05, Davidlohr Bueso <dave@gnu.org> wrote:
> I don't think we should always rely on having the kernel headers, that's
> why the fallback is provided.
[snip]
> I think with this patch we address the issue without removing our
> fallback.

Hi Dave et.al.

The preprocessor directive bellow is problematic. I don't see where,
or how, it might get satisfied so I am afraid the 'fall back' is
always in use regardless whether an user has kernel headers or not.

#ifdef KERNEL_INCLUDES_ARE_CLEAN

To fix that I modified the patch to use autoconf to check whether each
necessary header is present, and use them if possible. Notice that
Dave that I wrote your name to Reviewed-by patch line so it would be
nice to hear that you're OK with the change. See the attachment, or
pull from my repository.

The following changes since commit bfa8d39b5826b928deb6d84aee3a4a1d6557364c:

  build-sys: fix spaces versus tabs conflict (2011-07-11 15:12:06 +0200)

are available in the git repository at:
  https://github.com/kerolasa/lelux-utiliteetit minix

Sami Kerola (1):
      minix: v3 super-block does not have s_state field

 configure.ac            |    5 ++
 disk-utils/minix.h      |  129 ++++++++++++++++++++++++++++------------------
 disk-utils/mkfs.minix.c |    2 -
 3 files changed, 83 insertions(+), 53 deletions(-)

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

[-- Attachment #2: 0001-minix-v3-super-block-does-not-have-s_state-field.txt --]
[-- Type: text/plain, Size: 6807 bytes --]

From 3e60f8617e349aea3a1d3e70e89695dc7c8afda9 Mon Sep 17 00:00:00 2001
From: Sami Kerola <kerolasa@iki.fi>
Date: Tue, 12 Jul 2011 16:45:10 +0200
Subject: [PATCH] minix: v3 super-block does not have s_state field

Originally attempt was to use minix definitions and file system
structures from linux/minix_fs.h, but that failed at first try.

mkfs.minix.c:164:10: error: no member named 's_state' in 'struct
      minix3_super_block'
                Super3.s_state |= MINIX_VALID_FS;
                ~~~~~~ ^
mkfs.minix.c:165:10: error: no member named 's_state' in 'struct
      minix3_super_block'
                Super3.s_state &= ~MINIX_ERROR_FS;

Primary reason seems to be that the minix3 super-block does not
have s_state field. And it looks to me that it has never had it.
Further details about s_state can be found from minix v3 file
system support kernel patch.

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=939b00df0306bc4b5cd25c3c3c78e89b91e72fc8

Former minix disk s_state is now in kernel memory super-block
info structure as a s_mount_state field, if someone wonders what
happen to it.

Issue appeared commit a2657ae3ffb56616ac9c921886bcca8ef242499f
(two weeks ago), and hopefully not too many users where affected.
The mismatch in this case is not completely fatal because it is
at the end of the structure.

The patch fixes also #ifdef KERNEL_INCLUDES_ARE_CLEAN
preprocessor directive, which never is set. Autoconf is set to
inspect that necessary kernel headers are present. For fallback
there are local definitions.

Reviewed-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 configure.ac            |    5 ++
 disk-utils/minix.h      |  129 ++++++++++++++++++++++++++++------------------
 disk-utils/mkfs.minix.c |    2 -
 3 files changed, 83 insertions(+), 53 deletions(-)

diff --git a/configure.ac b/configure.ac
index a02b5e3..c2c74f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,6 +123,11 @@ AC_CHECK_HEADERS(
 	linux/version.h \
 	linux/falloc.h \
 	linux/cdrom.h \
+	linux/fs.h \
+	linux/limits.h \
+	linux/magic.h \
+	linux/minix_fs.h \
+	linux/types.h \
 	fcntl.h \
 	locale.h \
 	stdint.h \
diff --git a/disk-utils/minix.h b/disk-utils/minix.h
index fc1d1c0..6b2ee10 100644
--- a/disk-utils/minix.h
+++ b/disk-utils/minix.h
@@ -1,53 +1,92 @@
 #ifndef __MINIX_H__
 #define __MINIX_H__
 
-#ifdef KERNEL_INCLUDES_ARE_CLEAN
-
-#include <linux/fs.h>
-#include <linux/minix_fs.h>
-
+#ifdef HAVE_LINUX_TYPES_H
+#include <linux/types.h>
 #else
-
 typedef unsigned char u8;
 typedef unsigned short u16;
 typedef unsigned int u32;
+#endif
+
+#ifdef HAVE_LINUX_LIMITS_H
+#include <linux/limits.h>
+#else
+#define NAME_MAX  255		/* # chars in a file name */
+#endif
+
+#ifdef HAVE_LINUX_FS_H
+#include <linux/fs.h>
+#else
+#define BLOCK_SIZE_BITS 10
+#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
+#endif
+
+#ifdef HAVE_LINUX_MAGIC_H
+#include <linux/magic.h>
+#else
+#define MINIX_SUPER_MAGIC	0x137F	/* minix v1 fs, 14 char names */
+#define MINIX_SUPER_MAGIC2	0x138F	/* minix v1 fs, 30 char names */
+#define MINIX2_SUPER_MAGIC	0x2468	/* minix v2 fs, 14 char names */
+#define MINIX2_SUPER_MAGIC2	0x2478	/* minix v2 fs, 30 char names */
+#define MINIX3_SUPER_MAGIC	0x4d5a	/* minix v3 fs, 60 char names */
+#endif
+
+#ifdef HAVE_LINUX_MINIX_FS_H
+#include <linux/minix_fs.h>
+#else
 
+/*
+ * This is the original minix inode layout on disk.
+ * Note the 8-bit gid and atime and ctime.
+ */
 struct minix_inode {
-        u16 i_mode;
-        u16 i_uid;
-        u32 i_size;
-        u32 i_time;
-        u8  i_gid;
-        u8  i_nlinks;
-        u16 i_zone[9];
+	u16 i_mode;
+	u16 i_uid;
+	u32 i_size;
+	u32 i_time;
+	u8 i_gid;
+	u8 i_nlinks;
+	u16 i_zone[9];
 };
 
+/*
+ * The new minix inode has all the time entries, as well as
+ * long block numbers and a third indirect block (7+1+1+1
+ * instead of 7+1+1). Also, some previously 8-bit values are
+ * now 16-bit. The inode is now 64 bytes instead of 32.
+ */
 struct minix2_inode {
-        u16 i_mode;
-        u16 i_nlinks;
-        u16 i_uid;
-        u16 i_gid;
-        u32 i_size;
-        u32 i_atime;
-        u32 i_mtime;
-        u32 i_ctime;
-        u32 i_zone[10];
+	u16 i_mode;
+	u16 i_nlinks;
+	u16 i_uid;
+	u16 i_gid;
+	u32 i_size;
+	u32 i_atime;
+	u32 i_mtime;
+	u32 i_ctime;
+	u32 i_zone[10];
 };
 
+/*
+ * minix super-block data on disk
+ */
 struct minix_super_block {
-        u16 s_ninodes;
-        u16 s_nzones;
-        u16 s_imap_blocks;
-        u16 s_zmap_blocks;
-        u16 s_firstdatazone;
-        u16 s_log_zone_size;
-        u32 s_max_size;
-        u16 s_magic;
-        u16 s_state;
-        u32 s_zones;
+	u16 s_ninodes;
+	u16 s_nzones;
+	u16 s_imap_blocks;
+	u16 s_zmap_blocks;
+	u16 s_firstdatazone;
+	u16 s_log_zone_size;
+	u32 s_max_size;
+	u16 s_magic;
+	u16 s_state;
+	u32 s_zones;
 };
 
-/* V3 minix super-block data on disk */
+/*
+ * V3 minix super-block data on disk
+ */
 struct minix3_super_block {
 	u32 s_ninodes;
 	u16 s_pad0;
@@ -61,29 +100,17 @@ struct minix3_super_block {
 	u16 s_magic;
 	u16 s_pad2;
 	u16 s_blocksize;
-	u8  s_disk_version;
-        u16 s_state;
+	u8 s_disk_version;
 };
 
-#define BLOCK_SIZE_BITS 10
-#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
-
-#define NAME_MAX   255   /* # chars in a file name */
-#define MAX_INODES 65535
-
 #define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
-#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
-
-#define MINIX_VALID_FS               0x0001          /* Clean fs. */
-#define MINIX_ERROR_FS               0x0002          /* fs has errors. */
+#define MINIX_VALID_FS		0x0001	/* Clean fs. */
+#define MINIX_ERROR_FS		0x0002	/* fs has errors. */
 
-#define MINIX_SUPER_MAGIC    0x137F          /* original minix fs */
-#define MINIX_SUPER_MAGIC2   0x138F          /* minix fs, 30 char names */
-#define MINIX2_SUPER_MAGIC   0x2468	     /* minix V2 fs */
-#define MINIX2_SUPER_MAGIC2  0x2478	     /* minix V2 fs, 30 char names */
-#define MINIX3_SUPER_MAGIC   0x4d5a          /* minix V3 fs (60 char names) */
+#endif				/* HAVE_LINUX_MINIX_FS_H */
 
-#endif /* KERNEL_INCLUDES_ARE_CLEAN */
+#define MAX_INODES 65535
+#define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
 
 #define Inode (((struct minix_inode *) inode_buffer)-1)
 #define Inode2 (((struct minix2_inode *) inode_buffer)-1)
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 916dd17..322c023 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -161,8 +161,6 @@ static void super_set_state(void)
 {
 	switch (fs_version) {
 	case 3:
-		Super3.s_state |= MINIX_VALID_FS;
-		Super3.s_state &= ~MINIX_ERROR_FS;
 		break;
 	default:
 		Super.s_state |= MINIX_VALID_FS;
-- 
1.7.6


^ permalink raw reply related

* Re: `fsck -A` and fs-specific options
From: Theodore Tso @ 2011-07-13 11:17 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: util-linux
In-Reply-To: <CAJaTeTpBxcZ8ofxSHd7B1aRbU3wtSH=ED6ZYKEPPs4q3fgc2nA@mail.gmail.com>


On Jul 12, 2011, at 3:18 PM, Mike Frysinger wrote:

> when i read the kernel source, that seemed to be the case.  but i dont
> think it's the case for reiserfs, and i think there's a very tiny edge
> case with ext[34] related to moving the journal, but probably so small
> we can ignore it :p.

What do you think the edge case is?   Yes, the external journal's
dev_t is cached, but that is only used by the kernel since it
was simpler than having callouts to a userspace daemon.

E2fsck will use blkid to locate the external journal, and when it
finds it, it will update the cached dev_t if it is out of date, so that
at mount time the kernel will be able to find the external journal.
This way even if the external journal is on a device with an 
unstable dev_t (e.g., a USB device), the right thing should 
happen...

-- Ted


^ permalink raw reply

* Re: `fsck -A` and fs-specific options
From: Theodore Tso @ 2011-07-13 11:13 UTC (permalink / raw)
  To: Karel Zak; +Cc: Mike Frysinger, util-linux, David Zeuthen
In-Reply-To: <20110713083214.GA3486@nb.net.home>


On Jul 13, 2011, at 4:32 AM, Karel Zak wrote:

> Good point. There is demand for a generic API to assemble block
> devices (dm-crypt, MD, LVM, loopdev, ...). This functionality has
> been requested by desktop guys, dracut, udev and it seems also
> attractive for mount and fsck. I'll probably start to work on this
> task at the end of this year (I hope with DM guys).
> 
> My goal is to provide only library and command line interface, so the
> library will be usable everywhere (for example also in some D-BUS
> daemon, dracut, etc.) 

For many cases it might also be useful to have some way of specfying
that some of these block devices should be automatically specified at
at boot time, and supply an init script that sets up certain block devices
before the fsckall script is run?

What might also be cool is some way of specifying that certain block
devices should only be created after the user logs on, and then there
would be a PAM module that would take care of using the user's
login password and passing it to LUKS.

Some of thise might be done in plugins, and not your core library,
but I think these are two important use cases to keep in mind.

-- Ted



^ permalink raw reply

* Re: Error in man page for fstab
From: Karel Zak @ 2011-07-13  8:42 UTC (permalink / raw)
  To: Brad Goodman; +Cc: util-linux
In-Reply-To: <CAAN0OpipdTBHfJGJG0s-YQQ0EbmrLzCkh6PWfHvVAdz78mFE6w@mail.gmail.com>

On Tue, Jul 12, 2011 at 12:21:58PM -0400, Brad Goodman wrote:
> The fstab man page contains the following text:
> 
> >> The third field, (fs_vfstype) ... An entry "none" is  useful  for bind or move mounts
> 
> "none" is interpreted as an actual vfstype, which does not have the
> intended consequences.

 The bind mounts are completely independent on FS type. The type does
 not make sense here. The recent version of the mount(8) always
 overwrites the FS type to "none" for all MS_BIND, MS_MOVE and
 MS_PROPAGATION operations.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply

* Re: `fsck -A` and fs-specific options
From: Karel Zak @ 2011-07-13  8:32 UTC (permalink / raw)
  To: Theodore Tso; +Cc: Mike Frysinger, util-linux, David Zeuthen
In-Reply-To: <9CD6ADB9-F3AD-47EE-BF7E-251D86B7B305@mit.edu>

On Tue, Jul 12, 2011 at 07:02:20AM -0400, Theodore Tso wrote:
> 
> On Jul 11, 2011, at 10:59 PM, Mike Frysinger wrote:
> > 
> > for example, some journaling file systems allow the journal to be stored 
> > separately.  reiserfs has the "jdev=" mount option and the "--journal" fsck 
> > option.  ext[34] have the "journal_dev=" mount option and the "-j" fsck 
> > option.
> 
> At least for ext[34] and external journals, e2fsck can find the external
> journal using the blkid library since the UUID of the external journal
> is in the superblock. 

 This seems like a very elegant solution. The fsck.<type> helpers have
 to be able to gather all necessary information (from FS superblock,
 /etc/fstab, ...). This is very filesystems specific and I don't think
 that we can resolve this problem in generic /sbin/fsck util. 

> > another example is with loop mounts that take an offset.  fsck cannot operate 
> > on the loop source as the start of the file is not the image.  it needs to 
> > first setup the loop with the offset, and then do the fsck on the loop point.
> > 	/tmp/foo.img /mnt/tmp ext3 loop,offset=10000

 Good point. There is demand for a generic API to assemble block
 devices (dm-crypt, MD, LVM, loopdev, ...). This functionality has
 been requested by desktop guys, dracut, udev and it seems also
 attractive for mount and fsck. I'll probably start to work on this
 task at the end of this year (I hope with DM guys).

 The idea is to have a simple library (libblkasm ?) that provide API
 to assemble a block device according to the configuration in
 /etc/fstab and /etc/blkasm.d/. The library should be modular, so
 subsystem specific modules (lvm.so, crypt.so, ...) will be maintained
 externally by subsystem developers. It seems like a good way how to
 keep the functionality up to date and minimize some communication
 problems between people :-)

 Note that the original idea is from David Zeuthen
 http://people.freedesktop.org/~david/stc-20101011/stc.conf.html, but
 David's goal was daemon.

 My goal is to provide only library and command line interface, so the
 library will be usable everywhere (for example also in some D-BUS
 daemon, dracut, etc.) 
 
    Karel
 
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply

* Re: [PATCH] minix: v3 super-block does not have s_state field
From: Davidlohr Bueso @ 2011-07-13  4:05 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux
In-Reply-To: <1310485846-3685-1-git-send-email-kerolasa@iki.fi>

On Tue, 2011-07-12 at 17:50 +0200, Sami Kerola wrote:
> Originally attempt was to use minix definitions and file system
> structures from linux/minix_fs.h, but that failed at first try.
> 
> mkfs.minix.c:164:10: error: no member named 's_state' in 'struct
>       minix3_super_block'
>                 Super3.s_state |= MINIX_VALID_FS;
>                 ~~~~~~ ^
> mkfs.minix.c:165:10: error: no member named 's_state' in 'struct
>       minix3_super_block'
>                 Super3.s_state &= ~MINIX_ERROR_FS;
> 
> Primary reason seems to be that the minix3 super-block does not
> have s_state field. And it looks to me that it has never had it.
> Further details about s_state can be found from minix v3 file
> system support kernel patch.

Yes, you are right. It was dropped during time for v3, but previous
versions still use it.

> 
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=939b00df0306bc4b5cd25c3c3c78e89b91e72fc8
> 
> Former minix disk s_state is now in kernel memory super-block
> info structure as a s_mount_state field, if someone wonders what
> happen to it.

I don't think we should always rely on having the kernel headers, that's
why the fallback is provided.

> 
> Issue appeared commit a2657ae3ffb56616ac9c921886bcca8ef242499f
> (13 days ago), and hopefully not too many users where affected as
> I am not sure how bad it is to have mismatch in super-block
> structure.

It can be quite bad depending on the mismatch, in this case the kernel
skips the s_state when using v3.

I think with this patch we address the issue without removing our
fallback.

From: Davidlohr Bueso <dave@gnu.org>
Date: Tue, 12 Jul 2011 23:55:14 -0400
Subject: [PATCH] minix: remove fs state

For v3 minix superblocks the state flag (s_state) has been removed, so drop it from the structure in accordance with the kernel's representation.

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 disk-utils/minix.h      |    1 -
 disk-utils/mkfs.minix.c |    7 ++-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/disk-utils/minix.h b/disk-utils/minix.h
index fc1d1c0..a13a2a4 100644
--- a/disk-utils/minix.h
+++ b/disk-utils/minix.h
@@ -62,7 +62,6 @@ struct minix3_super_block {
 	u16 s_pad2;
 	u16 s_blocksize;
 	u8  s_disk_version;
-        u16 s_state;
 };
 
 #define BLOCK_SIZE_BITS 10
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 916dd17..06d087e 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -160,11 +160,8 @@ static void check_mount(void) {
 static void super_set_state(void)
 {
 	switch (fs_version) {
-	case 3:
-		Super3.s_state |= MINIX_VALID_FS;
-		Super3.s_state &= ~MINIX_ERROR_FS;
-		break;
-	default:
+	case 1:
+	case 2:
 		Super.s_state |= MINIX_VALID_FS;
 		Super.s_state &= ~MINIX_ERROR_FS;
 		break;
-- 
1.7.4.1



^ permalink raw reply related

* Re: [PATCH] lscpu: add support for books
From: Heiko Carstens @ 2011-07-13  3:46 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110711104035.GH5214@nb.net.home>

On Mon, Jul 11, 2011 at 12:40:35PM +0200, Karel Zak wrote:
> > -	"# CPU,Core,Socket,Node"));
> > +	"# CPU,Core,Socket,Book,Node"));
> 
>  It would be better to use
> 
>     # CPU,Core,Socket,Node,Book
> 
>  to keep it usable for stupid scripts where the header is not parsed.

Hi Karel,

thanks. I updated the patch accordingly (see below).
Just another thing: there are more per cpu informations that are present
on s390 that I would also like to the parseable output. However, somehow
it won't fit to the current approach that lscpu -p prints everything
with a unique id starting from zero.
For example the cpus on s390 can be in any of one of the states
horizontal,vertical:low,vertical:medium or vertical:high (that's just
an information of how the hypervisor schedules the cpus).
How is that supposed to be mapped to current approach?
Map these simply to numbers? E.g. horizontal would be mapped to 0,
vertical:low would be mapped to 1 and so on?
Also would I also need a new seperation character between caches and
new information?
I'm asking because the output of caches is optional and if something
new would be added, it seem to get messy in the long term because of
all seperation characters that may or may not be there. No?

Anyway, here is the updated patch for book support:

Subject: [PATCH] lscpu: add support for books

From: Heiko Carstens <heiko.carstens@de.ibm.com>

This patch adds support for books in cpu topology output. Books are
currently only present on the s390 architecture, however it looks like
others will follow to use the extra scheduling domain of the kernel.

Books are logically between sockets and nodes. In order to not break
any existing tools that might parse the output of lscpu the output
is changed so that books will follow nodes:
CPU,Core,Socket,Node,Book

In addition the readable output is changed from
"CPU socket(s):" to "Socket(s) per book:" or simply "Socket(s):" in the
absence of books.
    
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---

 sys-utils/lscpu.c |   46 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 7 deletions(-)

Index: util-linux-ng/sys-utils/lscpu.c
===================================================================
--- util-linux-ng.orig/sys-utils/lscpu.c
+++ util-linux-ng/sys-utils/lscpu.c
@@ -113,6 +113,11 @@ struct lscpu_desc {
 	int		nnodes;		/* number of NUMA modes */
 	cpu_set_t	**nodemaps;	/* array with NUMA nodes */
 
+	/* books -- based on book_siblings (internal kernel map of cpuX's
+	 * hardware threads within the same book */
+	int		nbooks;		/* number of all online books */
+	cpu_set_t	**bookmaps;	/* unique book_siblings */
+
 	/* sockets -- based on core_siblings (internal kernel map of cpuX's
 	 * hardware threads within the same physical_package_id (socket)) */
 	int		nsockets;	/* number of all online sockets */
@@ -583,7 +588,7 @@ static int add_cpuset_to_array(cpu_set_t
 static void
 read_topology(struct lscpu_desc *desc, int num)
 {
-	cpu_set_t *thread_siblings, *core_siblings;
+	cpu_set_t *thread_siblings, *core_siblings, *book_siblings;
 
 	if (!path_exist(_PATH_SYS_CPU "/cpu%d/topology/thread_siblings", num))
 		return;
@@ -592,17 +597,24 @@ read_topology(struct lscpu_desc *desc, i
 					"/cpu%d/topology/thread_siblings", num);
 	core_siblings = path_cpuset(_PATH_SYS_CPU
 					"/cpu%d/topology/core_siblings", num);
+	book_siblings = NULL;
+	if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/book_siblings", num)) {
+		book_siblings = path_cpuset(_PATH_SYS_CPU
+					    "/cpu%d/topology/book_siblings", num);
+	}
 
 	if (!desc->coremaps) {
-		int ncores, nsockets, nthreads;
+		int nbooks, nsockets, ncores, nthreads;
 		size_t setsize = CPU_ALLOC_SIZE(maxcpus);
 
 		/* threads within one core */
 		nthreads = CPU_COUNT_S(setsize, thread_siblings);
 		/* cores within one socket */
 		ncores = CPU_COUNT_S(setsize, core_siblings) / nthreads;
-		/* number of sockets */
+		/* number of sockets within one book */
 		nsockets = desc->ncpus / nthreads / ncores;
+		/* number of books */
+		nbooks = desc->ncpus / nthreads / ncores / nsockets;
 
 		/* all threads, see also read_basicinfo()
 		 * -- this is fallback for kernels where is not
@@ -610,7 +622,11 @@ read_topology(struct lscpu_desc *desc, i
 		 */
 		if (!desc->nthreads)
 			desc->nthreads = nsockets * ncores * nthreads;
-
+		if (book_siblings) {
+			desc->bookmaps = calloc(nbooks, sizeof(cpu_set_t *));
+			if (!desc->bookmaps)
+				err(EXIT_FAILURE, _("error: calloc failed"));
+		}
 		desc->socketmaps = calloc(nsockets, sizeof(cpu_set_t *));
 		if (!desc->socketmaps)
 			err(EXIT_FAILURE, _("error: calloc failed"));
@@ -621,6 +637,8 @@ read_topology(struct lscpu_desc *desc, i
 
 	add_cpuset_to_array(desc->socketmaps, &desc->nsockets, core_siblings);
 	add_cpuset_to_array(desc->coremaps, &desc->ncores, thread_siblings);
+	if (book_siblings)
+		add_cpuset_to_array(desc->bookmaps, &desc->nbooks, book_siblings);
 }
 
 static int
@@ -732,7 +750,7 @@ print_parsable(struct lscpu_desc *desc)
 	"# The following is the parsable format, which can be fed to other\n"
 	"# programs. Each different item in every column has an unique ID\n"
 	"# starting from zero.\n"
-	"# CPU,Core,Socket,Node"));
+	"# CPU,Core,Socket,Node,Book"));
 
 	if (desc->ncaches) {
 		/* separator between CPU topology and cache information */
@@ -781,6 +799,16 @@ print_parsable(struct lscpu_desc *desc)
 		if (j == desc->nnodes)
 			putchar(',');
 
+		/* Book */
+		for (j = 0; j < desc->nbooks; j++) {
+			if (CPU_ISSET_S(i, setsize, desc->bookmaps[j])) {
+				printf(",%d", j);
+				break;
+			}
+		}
+		if (j == desc->nbooks)
+			putchar(',');
+
 		if (desc->ncaches)
 			putchar(',');
 
@@ -883,9 +911,13 @@ print_readable(struct lscpu_desc *desc, 
 	if (desc->nsockets) {
 		print_n(_("Thread(s) per core:"), desc->nthreads / desc->ncores);
 		print_n(_("Core(s) per socket:"), desc->ncores / desc->nsockets);
-		print_n(_("CPU socket(s):"), desc->nsockets);
+		if (desc->nbooks) {
+			print_n(_("Socket(s) per book:"), desc->nsockets / desc->nbooks);
+ 			print_n(_("Book(s):"), desc->nbooks);
+		} else {
+			print_n(_("Socket(s):"), desc->nsockets);
+		}
 	}
-
 	if (desc->nnodes)
 		print_n(_("NUMA node(s):"), desc->nnodes);
 	if (desc->vendor)

^ permalink raw reply

* Re: [PATCH] evstate: new utility for querying evdev key/switch/event state
From: Dmitry Torokhov @ 2011-07-12 20:35 UTC (permalink / raw)
  To: Paul Fox; +Cc: Daniel Drake, Karel Zak, util-linux, Kay Sievers, linux-input
In-Reply-To: <15489.1310501220@foxharp.boston.ma.us>

On Tuesday, July 12, 2011 01:07:00 PM Paul Fox wrote:
> daniel wrote:
>  > On 11 July 2011 17:39, Dmitry Torokhov <dmitry.torokhov@gmail.com> 
wrote:
>  > > Now I'd say that this utility probably better fit into linuxconsole
>  > > project with the rest of input-related utilities...
>  > 
>  > http://sourceforge.net/projects/linuxconsole/ ?
>  > 
>  > This must have been what you were referring to before. Yes, this
>  > looks like a more appropriate home. I'll take it in that direction.
> 
> i disagree.  the contents of that package seems to be mostly for
> testing and legacy support.  access to the state of input switches in
> a generic way seems far more generally useful than that.
> 
> i would rather not see the sysfs state variable go away in the first
> place -- it's too convenient to use, and inexpensive to implement --
> needing an ioctl for this seems like a step backwards.  but barring
> that, relegating the evstate functionality to linuxconsole seems wrong.
> (for instance, i don't think the OLPC laptop distros have a need for
> any of the other utilities in linuxconsole.)

You can package only what you need from it, no need to package everything.


-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] evstate: new utility for querying evdev key/switch/event state
From: Paul Fox @ 2011-07-12 20:07 UTC (permalink / raw)
  To: Daniel Drake
  Cc: Dmitry Torokhov, Karel Zak, util-linux, Kay Sievers, linux-input
In-Reply-To: <CAGq3pz4ueyiTg1usRwangBJfuPwYPoOC0k83ygKs2RikfOQyGw@mail.gmail.com>

daniel wrote:
 > On 11 July 2011 17:39, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
 > > Now I'd say that this utility probably better fit into linuxconsole
 > > project with the rest of input-related utilities...
 > 
 > http://sourceforge.net/projects/linuxconsole/ ?
 > 
 > This must have been what you were referring to before. Yes, this looks
 > like a more appropriate home. I'll take it in that direction.

i disagree.  the contents of that package seems to be mostly for
testing and legacy support.  access to the state of input switches in
a generic way seems far more generally useful than that.

i would rather not see the sysfs state variable go away in the first
place -- it's too convenient to use, and inexpensive to implement --
needing an ioctl for this seems like a step backwards.  but barring
that, relegating the evstate functionality to linuxconsole seems wrong.
(for instance, i don't think the OLPC laptop distros have a need for
any of the other utilities in linuxconsole.)

paul
=---------------------
 paul fox, pgf@laptop.org

^ permalink raw reply

* Re: `fsck -A` and fs-specific options
From: Mike Frysinger @ 2011-07-12 19:18 UTC (permalink / raw)
  To: Theodore Tso; +Cc: util-linux
In-Reply-To: <9CD6ADB9-F3AD-47EE-BF7E-251D86B7B305@mit.edu>

On Tue, Jul 12, 2011 at 07:02, Theodore Tso wrote:
> On Jul 11, 2011, at 10:59 PM, Mike Frysinger wrote:
>> for example, some journaling file systems allow the journal to be stored
>> separately.  reiserfs has the "jdev=" mount option and the "--journal" fsck
>> option.  ext[34] have the "journal_dev=" mount option and the "-j" fsck
>> option.
>
> At least for ext[34] and external journals, e2fsck can find the external
> journal using the blkid library since the UUID of the external journal
> is in the superblock.   (In fact that's why the blkid library was originally
> written, and why it was originally included as part of e2fsprogs.)

when i read the kernel source, that seemed to be the case.  but i dont
think it's the case for reiserfs, and i think there's a very tiny edge
case with ext[34] related to moving the journal, but probably so small
we can ignore it :p.

>> another example is with loop mounts that take an offset.  fsck cannot operate
>> on the loop source as the start of the file is not the image.  it needs to
>> first setup the loop with the offset, and then do the fsck on the loop point.
>>       /tmp/foo.img /mnt/tmp ext3 loop,offset=10000
>
> How often are people using loopback mounts as a default, standard thing which
> need to be mounted and checked as part of the boot sequence?   I'm just
> curious what the use case is for this?

common enough that i got a report on it ;).  it was a mount point to
be checked/mounted during boot.

> I suppose if this was something people really did care about, the /etc/fstab
> format could be extended to add a new field at the end for fsck options ---
> but it's more complexity, and could break programs try to programmatically
> modify /etc/fstab.

right, which is why i was thinking that parsing the fstab's options
field is the lesser of two evils ...
-mike

^ permalink raw reply

* Error in man page for fstab
From: Brad Goodman @ 2011-07-12 16:21 UTC (permalink / raw)
  To: util-linux

The fstab man page contains the following text:

>> The third field, (fs_vfstype) ... An entry "none" is  useful  for bind or move mounts

"none" is interpreted as an actual vfstype, which does not have the
intended consequences.

I believe the word "none" should be replaced with "auto", which
automatically detects the vfstype.

This was seen under Centos 6.0, which gave the following info from the man page:
Linux 2.2          15 June 1999                         FSTAB(5)

^ permalink raw reply

* [PATCH] minix: v3 super-block does not have s_state field
From: Sami Kerola @ 2011-07-12 15:50 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Originally attempt was to use minix definitions and file system
structures from linux/minix_fs.h, but that failed at first try.

mkfs.minix.c:164:10: error: no member named 's_state' in 'struct
      minix3_super_block'
                Super3.s_state |= MINIX_VALID_FS;
                ~~~~~~ ^
mkfs.minix.c:165:10: error: no member named 's_state' in 'struct
      minix3_super_block'
                Super3.s_state &= ~MINIX_ERROR_FS;

Primary reason seems to be that the minix3 super-block does not
have s_state field. And it looks to me that it has never had it.
Further details about s_state can be found from minix v3 file
system support kernel patch.

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=939b00df0306bc4b5cd25c3c3c78e89b91e72fc8

Former minix disk s_state is now in kernel memory super-block
info structure as a s_mount_state field, if someone wonders what
happen to it.

Issue appeared commit a2657ae3ffb56616ac9c921886bcca8ef242499f
(13 days ago), and hopefully not too many users where affected as
I am not sure how bad it is to have mismatch in super-block
structure.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 disk-utils/minix.h      |   68 +----------------------------------------------
 disk-utils/mkfs.minix.c |    2 -
 2 files changed, 1 insertions(+), 69 deletions(-)

diff --git a/disk-utils/minix.h b/disk-utils/minix.h
index fc1d1c0..de79366 100644
--- a/disk-utils/minix.h
+++ b/disk-utils/minix.h
@@ -1,90 +1,24 @@
 #ifndef __MINIX_H__
 #define __MINIX_H__
 
-#ifdef KERNEL_INCLUDES_ARE_CLEAN
-
+#include <linux/types.h>
 #include <linux/fs.h>
 #include <linux/minix_fs.h>
 
-#else
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned int u32;
-
-struct minix_inode {
-        u16 i_mode;
-        u16 i_uid;
-        u32 i_size;
-        u32 i_time;
-        u8  i_gid;
-        u8  i_nlinks;
-        u16 i_zone[9];
-};
-
-struct minix2_inode {
-        u16 i_mode;
-        u16 i_nlinks;
-        u16 i_uid;
-        u16 i_gid;
-        u32 i_size;
-        u32 i_atime;
-        u32 i_mtime;
-        u32 i_ctime;
-        u32 i_zone[10];
-};
-
-struct minix_super_block {
-        u16 s_ninodes;
-        u16 s_nzones;
-        u16 s_imap_blocks;
-        u16 s_zmap_blocks;
-        u16 s_firstdatazone;
-        u16 s_log_zone_size;
-        u32 s_max_size;
-        u16 s_magic;
-        u16 s_state;
-        u32 s_zones;
-};
-
-/* V3 minix super-block data on disk */
-struct minix3_super_block {
-	u32 s_ninodes;
-	u16 s_pad0;
-	u16 s_imap_blocks;
-	u16 s_zmap_blocks;
-	u16 s_firstdatazone;
-	u16 s_log_zone_size;
-	u16 s_pad1;
-	u32 s_max_size;
-	u32 s_zones;
-	u16 s_magic;
-	u16 s_pad2;
-	u16 s_blocksize;
-	u8  s_disk_version;
-        u16 s_state;
-};
-
 #define BLOCK_SIZE_BITS 10
 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
 
 #define NAME_MAX   255   /* # chars in a file name */
 #define MAX_INODES 65535
 
-#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode)))
 #define MINIX2_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix2_inode)))
 
-#define MINIX_VALID_FS               0x0001          /* Clean fs. */
-#define MINIX_ERROR_FS               0x0002          /* fs has errors. */
-
 #define MINIX_SUPER_MAGIC    0x137F          /* original minix fs */
 #define MINIX_SUPER_MAGIC2   0x138F          /* minix fs, 30 char names */
 #define MINIX2_SUPER_MAGIC   0x2468	     /* minix V2 fs */
 #define MINIX2_SUPER_MAGIC2  0x2478	     /* minix V2 fs, 30 char names */
 #define MINIX3_SUPER_MAGIC   0x4d5a          /* minix V3 fs (60 char names) */
 
-#endif /* KERNEL_INCLUDES_ARE_CLEAN */
-
 #define Inode (((struct minix_inode *) inode_buffer)-1)
 #define Inode2 (((struct minix2_inode *) inode_buffer)-1)
 
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c
index 916dd17..322c023 100644
--- a/disk-utils/mkfs.minix.c
+++ b/disk-utils/mkfs.minix.c
@@ -161,8 +161,6 @@ static void super_set_state(void)
 {
 	switch (fs_version) {
 	case 3:
-		Super3.s_state |= MINIX_VALID_FS;
-		Super3.s_state &= ~MINIX_ERROR_FS;
 		break;
 	default:
 		Super.s_state |= MINIX_VALID_FS;
-- 
1.7.6


^ permalink raw reply related

* Re: `fsck -A` and fs-specific options
From: Theodore Tso @ 2011-07-12 11:02 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: util-linux
In-Reply-To: <201107112259.55340.vapier@gentoo.org>


On Jul 11, 2011, at 10:59 PM, Mike Frysinger wrote:
> 
> for example, some journaling file systems allow the journal to be stored 
> separately.  reiserfs has the "jdev=" mount option and the "--journal" fsck 
> option.  ext[34] have the "journal_dev=" mount option and the "-j" fsck 
> option.

At least for ext[34] and external journals, e2fsck can find the external
journal using the blkid library since the UUID of the external journal
is in the superblock.   (In fact that's why the blkid library was originally
written, and why it was originally included as part of e2fsprogs.)

> another example is with loop mounts that take an offset.  fsck cannot operate 
> on the loop source as the start of the file is not the image.  it needs to 
> first setup the loop with the offset, and then do the fsck on the loop point.
> 	/tmp/foo.img /mnt/tmp ext3 loop,offset=10000

How often are people using loopback mounts as a default, standard thing which
need to be mounted and checked as part of the boot sequence?   I'm just
curious what the use case is for this?

I suppose if this was something people really did care about, the /etc/fstab
format could be extended to add a new field at the end for fsck options ---
but it's more complexity, and could break programs try to programmatically
modify /etc/fstab.

-- Ted


^ permalink raw reply

* [git pull] mkfs.bfs fixes
From: Sami Kerola @ 2011-07-12  8:43 UTC (permalink / raw)
  To: util-linux

The following changes since commit bfa8d39b5826b928deb6d84aee3a4a1d6557364c:

  build-sys: fix spaces versus tabs conflict (2011-07-11 15:12:06 +0200)

are available in the git repository at:
  https://github.com/kerolasa/lelux-utiliteetit mkfs.bfs

Sami Kerola (7):
      mkfs.bfs: use libc error facilities
      mkfs.bfs: add long options
      mkfs.bfs: use xstrdup from xalloc.h
      mkfs.bfs: validate numeric user inputs
      mkfs.bfs: include-what-you-use header check
      mkfs.bfs: coding style fix
      docs: add long options to mkfs.bfs.8

 disk-utils/Makefile.am |    2 +-
 disk-utils/mkfs.bfs.8  |   38 +++++---
 disk-utils/mkfs.bfs.c  |  245 ++++++++++++++++++++++++-----------------------
 3 files changed, 148 insertions(+), 137 deletions(-)

diff --git a/disk-utils/Makefile.am b/disk-utils/Makefile.am
index 7d018b5..604a65c 100644
--- a/disk-utils/Makefile.am
+++ b/disk-utils/Makefile.am
@@ -17,7 +17,7 @@ sbin_PROGRAMS = mkfs mkswap fsck.minix mkfs.minix mkfs.bfs

 fsck_minix_SOURCES = fsck.minix.c minix.h $(top_srcdir)/lib/ismounted.c
 mkfs_minix_SOURCES = mkfs.minix.c minix.h mkfs.h $(utils_common)
$(top_srcdir)/lib/strutils.c
-mkfs_bfs_SOURCES = mkfs.bfs.c $(utils_common)
+mkfs_bfs_SOURCES = mkfs.bfs.c $(utils_common) $(top_srcdir)/lib/strutils.c

 swaplabel_SOURCES = swaplabel.c $(utils_common)
 swaplabel_LDADD = $(uuid_ldadd)
diff --git a/disk-utils/mkfs.bfs.8 b/disk-utils/mkfs.bfs.8
index 741fca9..616c358 100644
--- a/disk-utils/mkfs.bfs.8
+++ b/disk-utils/mkfs.bfs.8
@@ -1,42 +1,48 @@
 .\" Copyright 1999 Andries E. Brouwer (aeb@cwi.nl)
 .\" May be freely distributed.
-.TH MKFS.BFS 8 "12 Sept 1999" "Util-linux 2.9x" "Linux System
Administrator's Manual"
+.TH MKFS.BFS "8" "July 2011" "util-linux" "System Administration Utilities"
 .SH NAME
 mkfs.bfs \- make an SCO bfs filesystem
 .SH SYNOPSIS
 .B mkfs.bfs
-.RB [ \-N
-.IR nr-of-inodes ]
-.RB [ \-V
-.IR volume-name ]
-.RB [ \-F
-.IR fsname ]
-.I device
-.RI [ size-in-blocks ]
+[\fIoptions\fR] \fIdevice \fR[\fIblock-count\fR]
 .SH DESCRIPTION
 .B mkfs.bfs
 creates an SCO bfs file-system on a block device
 (usually a disk partition or a file accessed via the loop device).
-
+.PP
 The
-.I size-in-blocks
+.I block-count
 parameter is the desired size of the file system, in blocks.
 If nothing is specified, the entire partition will be used.
 .SH OPTIONS
 .TP
-.B \-N
+\fB\-N\fR, \fB\-\-inodes\fR=\fINUM\fR
 Specify the desired number of inodes (at most 512).
 If nothing is specified some default number in the range 48-512 is picked
 depending on the size of the partition.
 .TP
-.BI \-V " volume-label"
+\fB\-V\fR, \fB\-\-vname\fR=\fINAME\fR
 Specify the volume label. I have no idea if/where this is used.
 .TP
-.BI \-F " fsname"
+\fB\-F\fR, \fB\-\-fname\fR=\fINAME\fR
 Specify the fsname. I have no idea if/where this is used.
 .TP
-.B \-v
-Be verbose.
+\fB\-v\fR, \fB\-\-verbose\fR
+Explain what is being done.
+.TP
+\fB\-c\fR
+This option is silently ignored.
+.TP
+\fB\-l\fR
+This option is silently ignored.
+.TP
+\fB\-V\fR, \fB\-\-version\fR
+Output version information and exit.
+\fB\-V\fR works only when specified as an only option.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Display help and exit.
 .SH "EXIT CODES"
 The exit code returned by
 .B mkfs.bfs
diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
index 58f5352..3d87fd0 100644
--- a/disk-utils/mkfs.bfs.c
+++ b/disk-utils/mkfs.bfs.c
@@ -1,21 +1,24 @@
 /*
  *  mkfs.bfs - Create SCO BFS filesystem - aeb, 1999-09-07
  *
- *  Usage: mkfs.bfs [-N nr-of-inodes] [-V volume-name] [-F fsname] device
  */

+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
 #include <string.h>
+#include <sys/stat.h>
 #include <time.h>
-#include "nls.h"
+#include <unistd.h>
+
 #include "blkdev.h"
+#include "c.h"
+#include "nls.h"
+#include "strutils.h"
+#include "xalloc.h"

 #define BFS_ROOT_INO		2
 #define BFS_NAMELEN		14
@@ -24,72 +27,72 @@

 /* superblock - 512 bytes */
 struct bfssb {
-        unsigned int s_magic;
-        unsigned int s_start;	  /* byte offset of start of data */
-        unsigned int s_end;       /* sizeof(slice)-1 */
-
-        /* for recovery during compaction */
-        int s_from, s_to;         /* src and dest block of current transfer */
-        int s_backup_from, s_backup_to;
-
-        /* labels - may well contain garbage */
-        char s_fsname[6];
-        char s_volume[6];
-        char s_pad[472];
+	unsigned int s_magic;
+	unsigned int s_start;	/* byte offset of start of data */
+	unsigned int s_end;	/* sizeof(slice)-1 */
+
+	/* for recovery during compaction */
+	int s_from, s_to;	/* src and dest block of current transfer */
+	int s_backup_from, s_backup_to;
+
+	/* labels - may well contain garbage */
+	char s_fsname[6];
+	char s_volume[6];
+	char s_pad[472];
 };

 /* inode - 64 bytes */
 struct bfsi {
-        unsigned short i_ino;
-        unsigned char i_pad1[2];
-        unsigned long i_first_block;
-        unsigned long i_last_block;
-        unsigned long i_bytes_to_end;
-        unsigned long i_type;           /* 1: file, 2: the unique dir */
-        unsigned long i_mode;
-        unsigned long i_uid, i_gid;
-        unsigned long i_nlinks;
-        unsigned long i_atime, i_mtime, i_ctime;
-        unsigned char i_pad2[16];
+	unsigned short i_ino;
+	unsigned char i_pad1[2];
+	unsigned long i_first_block;
+	unsigned long i_last_block;
+	unsigned long i_bytes_to_end;
+	unsigned long i_type;	/* 1: file, 2: the unique dir */
+	unsigned long i_mode;
+	unsigned long i_uid, i_gid;
+	unsigned long i_nlinks;
+	unsigned long i_atime, i_mtime, i_ctime;
+	unsigned char i_pad2[16];
 };

 #define BFS_DIR_TYPE	2

 /* directory entry - 16 bytes */
 struct bfsde {
-        unsigned short d_ino;
-        char d_name[BFS_NAMELEN];
+	unsigned short d_ino;
+	char d_name[BFS_NAMELEN];
 };

-
-static char *progname;
-
-static void
-fatal(char *s, ...) {
-    va_list p;
-
-    va_start(p, s);
-    fflush(stdout);
-    fprintf(stderr, "\n%s: ", progname);
-    vfprintf(stderr, s, p);
-    va_end(p);
-    fprintf(stderr, "\n");
-    exit(1);
+static void __attribute__ ((__noreturn__)) usage(FILE * out)
+{
+	fprintf(out,
+		_("Usage: %s [options] device [block-count]\n"),
+		program_invocation_short_name);
+	fprintf(out, _("\nOptions:\n"
+		       " -N, --inodes=NUM    specify desired number of inodes\n"
+		       " -V, --vname=NAME    specify volume name\n"
+		       " -F, --fname=NAME    specify file system name\n"
+		       " -v, --verbose       explain what is being done\n"
+		       " -c                  this option is silently ignored\n"
+		       " -l                  this option is silently ignored\n"
+		       " -V, --version       output version information and exit\n"
+		       "                     -V as version must be only option\n"
+		       " -h, --help          display this help and exit\n\n"));
+
+	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }

-static void
-usage(void) {
-	fprintf(stderr, _(
-		"Usage: %s [-v] [-N nr-of-inodes] [-V volume-name]\n"
-		"       [-F fsname] device [block-count]\n"),
-		progname);
-	exit(1);
+static void __attribute__ ((__noreturn__)) print_version(void)
+{
+	printf(_("%s (%s)\n"), program_invocation_short_name, PACKAGE_STRING);
+	exit(EXIT_SUCCESS);
 }

-int
-main(int argc, char *argv[]) {
+int main(int argc, char **argv)
+{
 	char *device, *volume, *fsname;
-	int inodes;
+	long inodes;
 	unsigned long long total_blocks, ino_bytes, ino_blocks, data_blocks;
 	unsigned long long user_specified_total_blocks = 0;
 	int verbose = 0;
@@ -100,106 +103,109 @@ main(int argc, char *argv[]) {
 	struct stat statbuf;
 	time_t now;
 	int c, i, len;
-	char *p;

-	progname = argv[0];
-	if ((p = strrchr(progname, '/')) != NULL)
-		progname = p+1;
+	enum { VERSION_OPTION = CHAR_MAX + 1 };
+	static const struct option longopts[] = {
+		{"inodes", required_argument, NULL, 'N'},
+		{"vname", required_argument, NULL, 'V'},
+		{"fname", required_argument, NULL, 'F'},
+		{"verbose", no_argument, NULL, 'v'},
+		{"version", no_argument, NULL, VERSION_OPTION},
+		{"help", no_argument, NULL, 'h'},
+		{NULL, 0, NULL, 0}
+	};

 	if (argc < 2)
-		usage();
+		usage(stderr);

-	if (argc == 2 &&
-	    (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
-		printf(_("%s (%s)\n"), progname, PACKAGE_STRING);
-		exit(0);
-	}
+	if (argc == 2 && !strcmp(argv[1], "-V"))
+		print_version();

 	volume = fsname = "      ";	/* is there a default? */
 	inodes = 0;

-	while ((c = getopt(argc, argv, "vF:N:V:cl:")) != -1) {
+	while ((c = getopt_long(argc, argv, "N:V:F:vhcl", longopts, NULL)) != -1) {
 		switch (c) {
 		case 'N':
-			inodes = atol(optarg);
+			inodes = strtol_or_err(optarg, _("invalid number of inodes"));
 			break;

 		case 'V':
 			len = strlen(optarg);
 			if (len <= 0 || len > 6)
-				fatal(_("volume name too long"));
-			volume = strdup(optarg);
+				errx(EXIT_FAILURE, _("volume name too long"));
+			volume = xstrdup(optarg);
 			break;

 		case 'F':
 			len = strlen(optarg);
 			if (len <= 0 || len > 6)
-				fatal(_("fsname name too long"));
-			fsname = strdup(optarg);
+				errx(EXIT_FAILURE, _("fsname name too long"));
+			fsname = xstrdup(optarg);
 			break;

 		case 'v':
 			verbose = 1;
 			break;

-			/* when called via mkfs we may get options c,l,v */
 		case 'c':
 		case 'l':
+			/* when called via mkfs we may get options c,l,v */
 			break;

+		case VERSION_OPTION:
+			print_version();
+		case 'h':
+			usage(stdout);
 		default:
-			usage();
+			usage(stderr);
 		}
 	}

 	if (optind == argc)
-		usage();
+		usage(stderr);

 	device = argv[optind++];

-	if (stat(device, &statbuf) == -1) {
-		perror(device);
-		fatal(_("cannot stat device %s"), device);
-	}
+	if (stat(device, &statbuf) < 0)
+		err(EXIT_FAILURE, _("cannot stat device %s"), device);

 	if (!S_ISBLK(statbuf.st_mode))
-		fatal(_("%s is not a block special device"), device);
+		errx(EXIT_FAILURE, _("%s is not a block special device"), device);

 	fd = open(device, O_RDWR | O_EXCL);
-	if (fd == -1) {
-		perror(device);
-		fatal(_("cannot open %s"), device);
-	}
+	if (fd < 0)
+		err(EXIT_FAILURE, _("cannot open %s"), device);

-	if (optind == argc-1)
-		user_specified_total_blocks = atoll(argv[optind]);
+	if (optind == argc - 1)
+		user_specified_total_blocks =
+			strtoll_or_err(argv[optind], _("invalid block-count"));
 	else if (optind != argc)
-		usage();
+		usage(stderr);

 	if (blkdev_get_sectors(fd, &total_blocks) == -1) {
-		if (!user_specified_total_blocks) {
-			perror("blkdev_get_sectors");
-			fatal(_("cannot get size of %s"), device);
-		}
+		if (!user_specified_total_blocks)
+			err(EXIT_FAILURE, _("cannot get size of %s"), device);
 		total_blocks = user_specified_total_blocks;
 	} else if (user_specified_total_blocks) {
 		if (user_specified_total_blocks > total_blocks)
-			fatal(_("blocks argument too large, max is %llu"),
-			      total_blocks);
+			errx(EXIT_FAILURE,
+			     _("blocks argument too large, max is %llu"),
+			     total_blocks);
 		total_blocks = user_specified_total_blocks;
 	}

 	if (!inodes) {
 		/* pick some reasonable default */
-		inodes = 8*(total_blocks/800);
+		inodes = 8 * (total_blocks / 800);
 		if (inodes < 48)
 			inodes = 48;
-		if (inodes > 512)
+		if (512 < inodes)
 			inodes = 512;
 	} else {
 		/* believe the user */
-		if (inodes > 512)
-			fatal(_("too many inodes - max is 512"));
+		if (512 < inodes)
+			errx(EXIT_FAILURE, _("too many inodes - max is 512"));
 	}

 	ino_bytes = inodes * sizeof(struct bfsi);
@@ -208,8 +214,9 @@ main(int argc, char *argv[]) {

 	/* mimic the behaviour of SCO's mkfs - maybe this limit is needed */
 	if (data_blocks < 32)
-		fatal(_("not enough space, need at least %llu blocks"),
-		      ino_blocks + 33);
+		errx(EXIT_FAILURE,
+		     _("not enough space, need at least %llu blocks"),
+		     ino_blocks + 33);

 	memset(&sb, 0, sizeof(sb));
 	sb.s_magic = BFS_SUPER_MAGIC;
@@ -224,29 +231,29 @@ main(int argc, char *argv[]) {
 		fprintf(stderr, _("Volume: <%-6s>\n"), volume);
 		fprintf(stderr, _("FSname: <%-6s>\n"), fsname);
 		fprintf(stderr, _("BlockSize: %d\n"), BFS_BLOCKSIZE);
-		if (ino_blocks==1)
-			fprintf(stderr, _("Inodes: %d (in 1 block)\n"),
+		if (ino_blocks == 1)
+			fprintf(stderr, _("Inodes: %lu (in 1 block)\n"),
 				inodes);
 		else
-			fprintf(stderr, _("Inodes: %d (in %lld blocks)\n"),
+			fprintf(stderr, _("Inodes: %lu (in %llu blocks)\n"),
 				inodes, ino_blocks);
 		fprintf(stderr, _("Blocks: %lld\n"), total_blocks);
 		fprintf(stderr, _("Inode end: %d, Data end: %d\n"),
-			sb.s_start-1, sb.s_end);
+			sb.s_start - 1, sb.s_end);
 	}

 	if (write(fd, &sb, sizeof(sb)) != sizeof(sb))
-		fatal(_("error writing superblock"));
+		errx(EXIT_FAILURE, _("error writing superblock"));

 	memset(&ri, 0, sizeof(ri));
 	ri.i_ino = BFS_ROOT_INO;
 	ri.i_first_block = 1 + ino_blocks;
 	ri.i_last_block = ri.i_first_block +
-		(inodes * sizeof(de) - 1) / BFS_BLOCKSIZE;
+	    (inodes * sizeof(de) - 1) / BFS_BLOCKSIZE;
 	ri.i_bytes_to_end = ri.i_first_block * BFS_BLOCKSIZE
-		+ 2 * sizeof(struct bfsde) - 1;
+	    + 2 * sizeof(struct bfsde) - 1;
 	ri.i_type = BFS_DIR_TYPE;
-	ri.i_mode = S_IFDIR | 0755; 	/* or just 0755 */
+	ri.i_mode = S_IFDIR | 0755;	/* or just 0755 */
 	ri.i_uid = 0;
 	ri.i_gid = 1;			/* random */
 	ri.i_nlinks = 2;
@@ -256,30 +263,28 @@ main(int argc, char *argv[]) {
 	ri.i_ctime = now;

 	if (write(fd, &ri, sizeof(ri)) != sizeof(ri))
-		fatal(_("error writing root inode"));
+		errx(EXIT_FAILURE, _("error writing root inode"));

 	memset(&ri, 0, sizeof(ri));
-	for (i=1; i<inodes; i++)
+	for (i = 1; i < inodes; i++)
 		if (write(fd, &ri, sizeof(ri)) != sizeof(ri))
-			fatal(_("error writing inode"));
+			errx(EXIT_FAILURE, _("error writing inode"));

-	if (lseek(fd, (1 + ino_blocks)*BFS_BLOCKSIZE, SEEK_SET) == -1)
-		fatal(_("seek error"));
+	if (lseek(fd, (1 + ino_blocks) * BFS_BLOCKSIZE, SEEK_SET) == -1)
+		errx(EXIT_FAILURE, _("seek error"));

 	memset(&de, 0, sizeof(de));
 	de.d_ino = BFS_ROOT_INO;
 	memcpy(de.d_name, ".", 1);
 	if (write(fd, &de, sizeof(de)) != sizeof(de))
-		fatal(_("error writing . entry"));
+		errx(EXIT_FAILURE, _("error writing . entry"));

 	memcpy(de.d_name, "..", 2);
 	if (write(fd, &de, sizeof(de)) != sizeof(de))
-		fatal(_("error writing .. entry"));
+		errx(EXIT_FAILURE, _("error writing .. entry"));

-	if (close(fd) == -1) {
-		perror(device);
-		fatal(_("error closing %s"), device);
-	}
+	if (close(fd) < 0)
+		err(EXIT_FAILURE, _("error closing %s"), device);

-	return 0;
+	return EXIT_SUCCESS;
 }

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply related

* `fsck -A` and fs-specific options
From: Mike Frysinger @ 2011-07-12  2:59 UTC (permalink / raw)
  To: util-linux

[-- Attachment #1: Type: text/plain, Size: 1213 bytes --]

ive got some "interesting" bugs here when using the `fsck -A` helper.  
consider file systems that have unique mount options that sometimes the fsck 
program also needs to know about.  for mounting, this isnt a problem as the 
options are stored in /etc/fstab and `mount` will extract the options field 
and pass it along.  but what about fsck ?

for example, some journaling file systems allow the journal to be stored 
separately.  reiserfs has the "jdev=" mount option and the "--journal" fsck 
option.  ext[34] have the "journal_dev=" mount option and the "-j" fsck 
option.

another example is with loop mounts that take an offset.  fsck cannot operate 
on the loop source as the start of the file is not the image.  it needs to 
first setup the loop with the offset, and then do the fsck on the loop point.
	/tmp/foo.img /mnt/tmp ext3 loop,offset=10000

i could code up some crap in the Gentoo init scripts to take care of this, but 
if we handled it in util-linux, everyone would get this for free.  seems like 
we need to add a per-filesystem-type lists that track the mount option (so we 
can extract it from /etc/fstab) and how to translate it into the related fsck 
option.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox