Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH 3/5] fdisk: print welcome message
From: Francesco Cosoleto @ 2011-08-16 22:19 UTC (permalink / raw)
  To: util-linux; +Cc: Francesco Cosoleto
In-Reply-To: <1313533146-2806-1-git-send-email-cosoleto@gmail.com>

This adds a welcome message with util-linux version number, information
about fdisk behaviour that doesn't write to disk after a command (unlike
gparted) and a warning about possible data loss.

The message appears just before the first command prompt.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
---
 fdisk/fdisk.c         |   10 +++++-----
 fdisk/fdisksgilabel.c |    4 +---
 fdisk/fdisksunlabel.c |    4 +---
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index d3fc200..1c1f492 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -932,11 +932,7 @@ static void
 create_doslabel(void) {
 	unsigned int id = get_random_id();
 
-	fprintf(stderr,
-	_("Building a new DOS disklabel with disk identifier 0x%08x.\n"
-	  "Changes will remain in memory only, until you decide to write them.\n"
-	  "After that, of course, the previous content won't be recoverable.\n\n"),
-		id);
+	fprintf(stderr, _("Building a new DOS disklabel with disk identifier 0x%08x.\n"), id);
 	sun_nolabel();  /* otherwise always recognised as sun */
 	sgi_nolabel();  /* otherwise always recognised as sgi */
 	disklabel = DOS_LABEL;
@@ -3093,6 +3089,10 @@ main(int argc, char **argv) {
 		disklabel = DOS_LABEL;
 	}
 
+	fprintf(stderr, _("Welcome to fdisk (%s).\n\n"
+		"Changes will remain in memory only, until you decide to write them.\n"
+		"Be careful before using the write command.\n"), PACKAGE_STRING);
+
 	while (1) {
 		putchar('\n');
 		c = tolower(read_char(_("Command (m for help): ")));
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c
index 20ed92d..c553abc 100644
--- a/fdisk/fdisksgilabel.c
+++ b/fdisk/fdisksgilabel.c
@@ -697,9 +697,7 @@ create_sgilabel(void)
 	sec_fac = sector_size / 512;	/* determine the sector factor */
 
 	fprintf(stderr,
-		_("Building a new SGI disklabel. Changes will remain in memory only,\n"
-		  "until you decide to write them. After that, of course, the previous\n"
-		  "content will be unrecoverably lost.\n\n"));
+		_("Building a new SGI disklabel.\n"));
 
 	other_endian = (BYTE_ORDER == LITTLE_ENDIAN);
 
diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c
index 7d3aa09..80408dd 100644
--- a/fdisk/fdisksunlabel.c
+++ b/fdisk/fdisksunlabel.c
@@ -189,9 +189,7 @@ void create_sunlabel(void)
 	int res;
 
 	fprintf(stderr,
-	_("Building a new sun disklabel. Changes will remain in memory only,\n"
-       	"until you decide to write them. After that, of course, the previous\n"
-	"content won't be recoverable.\n\n"));
+	_("Building a new Sun disklabel.\n"));
 #if BYTE_ORDER == LITTLE_ENDIAN
 	other_endian = 1;
 #else
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH 2/5] fdisk: print partition deleted message
From: Francesco Cosoleto @ 2011-08-16 22:19 UTC (permalink / raw)
  To: util-linux; +Cc: Francesco Cosoleto
In-Reply-To: <1313533146-2806-1-git-send-email-cosoleto@gmail.com>

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
---
 fdisk/fdisk.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index a08a4d4..d3fc200 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1676,27 +1676,18 @@ delete_partition(int i) {
 		return;		/* C/H/S not set */
 	pe->changed = 1;
 
-	if (disklabel == SUN_LABEL) {
+	if (disklabel == SUN_LABEL)
 		sun_delete_partition(i);
-		return;
-	}
-
-	if (disklabel == SGI_LABEL) {
+	else if (disklabel == SGI_LABEL)
 		sgi_delete_partition(i);
-		return;
-	}
-
-	if (i < 4) {
+	else if (i < 4) {
 		if (IS_EXTENDED (p->sys_ind) && i == ext_index) {
 			partitions = 4;
 			ptes[ext_index].ext_pointer = NULL;
 			extended_offset = 0;
 		}
 		clear_partition(p);
-		return;
-	}
-
-	if (!q->sys_ind && i > 4) {
+	} else if (!q->sys_ind && i > 4) {
 		/* the last one in the chain - just delete */
 		--partitions;
 		--i;
@@ -1733,6 +1724,7 @@ delete_partition(int i) {
 			/* the only logical: clear only */
 			clear_partition(ptes[i].part_table);
 	}
+	printf(_("Partition %d is deleted\n"), i + 1);
 }
 
 static void
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH 1/5] fdisk: print a message with size and type of created partition
From: Francesco Cosoleto @ 2011-08-16 22:19 UTC (permalink / raw)
  To: util-linux; +Cc: Francesco Cosoleto

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
---
 fdisk/Makefile.am     |    2 +-
 fdisk/fdisk.c         |   13 +++++++++++++
 fdisk/fdisk.h         |    1 +
 fdisk/fdisksgilabel.c |    8 +++++++-
 fdisk/fdisksunlabel.c |    4 ++++
 5 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/fdisk/Makefile.am b/fdisk/Makefile.am
index 7cad805..4409db5 100644
--- a/fdisk/Makefile.am
+++ b/fdisk/Makefile.am
@@ -4,7 +4,7 @@ EXTRA_DIST = README.fdisk README.cfdisk sfdisk.examples partitiontype.c
 
 fdisk_common = i386_sys_types.c common.h gpt.c gpt.h \
 	$(top_srcdir)/lib/blkdev.c $(top_srcdir)/lib/wholedisk.c \
-	$(top_srcdir)/lib/mbsalign.c
+	$(top_srcdir)/lib/mbsalign.c $(top_srcdir)/lib/strutils.c
 
 if LINUX
 fdisk_common += $(top_srcdir)/lib/linux_version.c
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 038536d..a08a4d4 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -32,6 +32,7 @@
 #include "wholedisk.h"
 #include "pathnames.h"
 #include "canonicalize.h"
+#include "strutils.h"
 
 #include "fdisksunlabel.h"
 #include "fdisksgilabel.h"
@@ -614,6 +615,10 @@ set_partition(int i, int doext, unsigned long long start,
 	p->sys_ind = sysid;
 	set_start_sect(p, start - offset);
 	set_nr_sects(p, stop - start + 1);
+
+	if (!doext)
+		print_partition_size(i + 1, start, stop, sysid);
+
 	if (dos_compatible_flag && (start/(sectors*heads) > 1023))
 		start = heads*sectors*1024 - 1;
 	set_hsc(p->head, p->sector, p->cyl, start);
@@ -2319,6 +2324,14 @@ get_unused_start(int part_n,
 	return start;
 }
 
+void print_partition_size(int num, unsigned long long start, unsigned long long stop, int sysid)
+{
+	char *str = size_to_human_string(SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
+				     (stop - start + 1) * sector_size);
+	printf(_("Partition %d of type %s and of size %s is set\n"), num, partition_type(sysid), str);
+	free(str);
+}
+
 static void
 add_partition(int n, int sys) {
 	char mesg[256];		/* 48 does not suffice in Japanese */
diff --git a/fdisk/fdisk.h b/fdisk/fdisk.h
index 9b7f4c7..e289043 100644
--- a/fdisk/fdisk.h
+++ b/fdisk/fdisk.h
@@ -75,6 +75,7 @@ extern struct partition *get_part_table(int);
 extern int valid_part_table_flag(unsigned char *b);
 extern unsigned int read_int(unsigned int low, unsigned int dflt,
 			     unsigned int high, unsigned int base, char *mesg);
+extern void print_partition_size(int num, unsigned long long start, unsigned long long stop, int sysid);
 
 extern unsigned char *MBRbuffer;
 extern void zeroize_mbr_buffer(void);
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c
index 8179bc1..20ed92d 100644
--- a/fdisk/fdisksgilabel.c
+++ b/fdisk/fdisksgilabel.c
@@ -570,6 +570,7 @@ sgi_set_partition(int i, unsigned int start, unsigned int length, int sys) {
 	set_changed(i);
 	if (sgi_gaps() < 0)	/* rebuild freelist */
 		printf(_("Do You know, You got a partition overlap on the disk?\n"));
+	print_partition_size(i + 1, start, start + length, sys);
 }
 
 static void
@@ -733,7 +734,6 @@ create_sgilabel(void)
 				old[i].sysid = get_part_table(i)->sys_ind;
 				old[i].start = get_start_sect(get_part_table(i));
 				old[i].nsect = get_nr_sects(get_part_table(i));
-				printf(_("Trying to keep parameters of partition %d.\n"), i);
 				if (debug)
 					printf(_("ID=%02x\tSTART=%d\tLENGTH=%d\n"),
 					       old[i].sysid, old[i].start, old[i].nsect);
@@ -741,6 +741,12 @@ create_sgilabel(void)
 		}
 	}
 
+	for (i = 0; i < 4; i++)
+		if (old[i].sysid) {
+			printf(_("Trying to keep parameters of partitions already set.\n"));
+			break;
+		}
+
 	zeroize_mbr_buffer();
 	sgilabel->magic = SSWAP32(SGI_LABEL_MAGIC);
 	sgilabel->boot_part = SSWAP16(0);
diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c
index 9335e75..7d3aa09 100644
--- a/fdisk/fdisksunlabel.c
+++ b/fdisk/fdisksunlabel.c
@@ -106,6 +106,7 @@ static void set_sun_partition(int i, uint32_t start, uint32_t stop, uint16_t sys
 	sunlabel->partitions[i].num_sectors =
 		SSWAP32(stop - start);
 	set_changed(i);
+	print_partition_size(i + 1, start, stop, sysid);
 }
 
 void sun_nolabel(void)
@@ -250,6 +251,9 @@ void create_sunlabel(void)
 	} else
 	        ndiv = cylinders * 2 / 3;
 
+	/* Make sure print_partition_size() uses correct sysid names */
+	disklabel = SUN_LABEL;
+
 	set_sun_partition(0, 0, ndiv * heads * sectors,
 			  SUN_TAG_LINUX_NATIVE);
 	set_sun_partition(1, ndiv * heads * sectors,
-- 
1.7.3.4


^ permalink raw reply related

* Re: [patches] tweaks of sfdisk's man page and help text
From: Karel Zak @ 2011-08-16 21:57 UTC (permalink / raw)
  To: Util-Linux
In-Reply-To: <20110816205018.GD1054@pc21.mareichelt.com>

On Tue, Aug 16, 2011 at 10:50:18PM +0200, markus reichelt wrote:
> * Benno Schulenberg <bensberg@justemail.net> wrote:
> 
> > -Then, if you discover that you did something stupid before anything
> > +Then, if you discover that you did something stupid b efore anything
> 
> Typo alert.

 Fixed. Thanks for review.

    Karel

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

^ permalink raw reply

* Re: [patches] tweaks of sfdisk's man page and help text
From: Karel Zak @ 2011-08-16 21:54 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Util-Linux
In-Reply-To: <1313521068.4590.140258130338973@webmail.messagingengine.com>

On Tue, Aug 16, 2011 at 08:57:48PM +0200, Benno Schulenberg wrote:
> Just two patches.  No more from me before rc2.

 Applied, thanks.

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

^ permalink raw reply

* Re: [patches] tweaks of sfdisk's man page and help text
From: markus reichelt @ 2011-08-16 20:50 UTC (permalink / raw)
  To: Util-Linux
In-Reply-To: <1313521068.4590.140258130338973@webmail.messagingengine.com>

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

* Benno Schulenberg <bensberg@justemail.net> wrote:

> -Then, if you discover that you did something stupid before anything
> +Then, if you discover that you did something stupid b efore anything

Typo alert.

-- 
left blank, right bald

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* [patches] tweaks of sfdisk's man page and help text
From: Benno Schulenberg @ 2011-08-16 18:57 UTC (permalink / raw)
  To: Util-Linux

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


Hi,

Just two patches.  No more from me before rc2.

Regards,

Benno

-- 
http://www.fastmail.fm - Does exactly what it says on the tin


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-sfdisk-man-page-use-comma-between-short-and-long-opt.patch --]
[-- Type: text/x-patch; name="0001-sfdisk-man-page-use-comma-between-short-and-long-opt.patch", Size: 15608 bytes --]

From 4299fb4d6a307ef0f62c7fc3c193ca568b562162 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Tue, 16 Aug 2011 20:20:19 +0200
Subject: [PATCH 1/2] sfdisk: (man page) use comma between short and long option instead of "or"

Also fix some erratic formatting, indent the third example too, drop
the trailing % prompt in examples, add a blank line before and after,
and improve the wording here and there.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 fdisk/sfdisk.8 |  179 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 90 insertions(+), 89 deletions(-)

diff --git a/fdisk/sfdisk.8 b/fdisk/sfdisk.8
index 02e8d11..6bbd4ab 100644
--- a/fdisk/sfdisk.8
+++ b/fdisk/sfdisk.8
@@ -5,9 +5,9 @@
 .\" -- May be distributed under the GNU General Public License
 .\" The `DRDOS Warning' was taken from a net post by Stephen Tweedie.
 .\"
-.TH SFDISK 8 "1 September 1995" "Linux" "Linux Programmer's Manual"
+.TH SFDISK 8 "August 2011" "util-linux" "System Administration"
 .SH NAME
-sfdisk \- Partition table manipulator for Linux
+sfdisk \- partition table manipulator for Linux
 .SH SYNOPSIS
 .B sfdisk
 .RI [ options ]
@@ -18,21 +18,21 @@ sfdisk \- Partition table manipulator for Linux
 .SH DESCRIPTION
 .B sfdisk
 has four (main) uses: list the size of a partition, list the partitions
-on a device, check the partitions on a device, and - very dangerous -
+on a device, check the partitions on a device, and \- very dangerous \-
 repartition a device.
 
 .B sfdisk
-doesn't understand GUID Partition Table (GPT) and
-it is not designed for large partitions. In particular case use more advanced GNU
+doesn't understand the GUID Partition Table (GPT) format and it is not
+designed for large partitions.  In these cases use the more advanced GNU
 .BR parted (8).
 
-.SS "List Sizes"
+.SS "List sizes"
 .BI "sfdisk \-s " partition
 gives the size of
 .I partition
-in blocks. This may be useful in connection with programs like
-.BR mkswap (8)
-or so. Here
+in blocks.  This may be useful in connection with programs like
+.BR mkswap (8).
+Here
 .I partition
 is usually something like
 .I /dev/hda1
@@ -40,20 +40,20 @@ or
 .IR /dev/sdb12 ,
 but may also be an entire disk, like
 .IR /dev/xda .
-.br
+
 .RS
 .nf
 .if t .ft CW
 % sfdisk \-s /dev/hda9
 81599
-%
 .if t .ft R
 .fi
 .RE
+
 If the partition argument is omitted,
 .B sfdisk
 will list the sizes of all disks, and the total:
-.br
+
 .RS
 .nf
 .if t .ft CW
@@ -64,20 +64,18 @@ will list the sizes of all disks, and the total:
 /dev/sda: 8877895
 /dev/sdb: 1758927
 total: 12901917 blocks
-%
 .if t .ft R
 .fi
 .RE
 
-.SS "List Partitions"
+.SS "List partitions"
 The second type of invocation:
-.B sfdisk \-l
-.RB [ options ]
+.BI "sfdisk \-l " device
+will list the partitions on the specified device.  If the
 .I device
-will list the partitions on this device.
-If the device argument is omitted, the partitions on all hard disks
-are listed.
-.br
+argument is omitted, the partitions on all hard disks are listed.
+
+.RS
 .nf
 .if t .ft CW
 % sfdisk \-l /dev/hdc
@@ -90,20 +88,21 @@ Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0
 /dev/hdc2        407     813     407    205128   83  Linux native
 /dev/hdc3        814    2044    1231    620424   83  Linux native
 /dev/hdc4          0       \-       0         0    0  Empty
-%
 .if t .ft R
 .fi
+.RE
+
 The trailing \- and + signs indicate that rounding has taken place,
-and that the actual value is slightly less (more).
-To see the exact values, ask for a listing with sectors as unit.
+and that the actual value is slightly less or more.  To see the
+exact values, ask for a listing with sectors as unit (\fB\-u S\fR).
 
 .SS "Check partitions"
 The third type of invocation:
 .BI "sfdisk \-V " device
 will apply various consistency checks to the partition tables on
 .IR device .
-It prints `OK' or complains. The \-V option can be used together
-with \-l. In a shell script one might use
+It prints `OK' or complains.  The \fB\-V\fR option can be used
+together with \fB\-l\fR.  In a shell script one might use
 .BI "sfdisk \-V \-q " device
 which only returns a status.
 
@@ -114,10 +113,10 @@ will cause
 .B sfdisk
 to read the specification for the desired partitioning of
 .I device
-from its standard input, and then to change the partition tables
-on that disk. Thus, it is possible to use
+from standard input, and then to change the partition tables
+on that disk.  Thus it is possible to use
 .B sfdisk
-from a shell script. When
+from a shell script.  When
 .B sfdisk
 determines that its standard input is a terminal, it will be
 conversational; otherwise it will abort on any error.
@@ -126,67 +125,69 @@ BE EXTREMELY CAREFUL - ONE TYPING MISTAKE AND ALL YOUR DATA IS LOST
 .LP
 As a precaution, one can save the sectors changed by
 .BR sfdisk :
+
 .RS
 .nf
 .if t .ft CW
 % sfdisk /dev/hdd \-O hdd-partition-sectors.save
 \&...
-%
 .if t .ft R
 .fi
 .RE
+
 .LP
-Then, if you discover that you did something stupid before anything
+Then, if you discover that you did something stupid b efore anything
 else has been written to disk, it may be possible to recover
-the old situation with
+the old situation with:
+
 .RS
 .nf
 .if t .ft CW
 % sfdisk /dev/hdd \-I hdd-partition-sectors.save
-%
 .if t .ft R
 .fi
 .RE
+
 .LP
 (This is not the same as saving the old partition table:
 a readable version of the old partition table can be saved
-using the \-d option. However, if you create logical partitions,
+using the \fB\-d\fR option.  However, if you create logical partitions,
 the sectors describing them are located somewhere on disk,
 possibly on sectors that were not part of the partition table
-before. Thus, the information the \-O option saves is not a binary
-version of the output of \-d.)
+before.  Thus, the information the \fB\-O\fR option saves
+is not a binary version of the output of \fB\-d\fR.)
 
 There are many options.
 
 .SH OPTIONS
 .TP
-.BR \-v " or " \-\-version
+.BR \-v ", " \-\-version
 Print version number of
 .B sfdisk
 and exit immediately.
 .TP
-.BR \-h " or " \-\-help
+.BR \-h ", " \-\-help
 Print a usage message and exit immediately.
 .TP
-.BR \-T " or " \-\-list\-types
+.BR \-T ", " \-\-list\-types
 Print the recognized types (system Id's).
 .TP
-.BR \-s " or " \-\-show\-size
+.BR \-s ", " \-\-show\-size
 List the size of a partition.
 .TP
-.BR \-g " or " \-\-show\-geometry
+.BR \-g ", " \-\-show\-geometry
 List the kernel's idea of the geometry of the indicated disk(s).
 .TP
-.BR \-G " or " \-\-show\-pt\-geometry
+.BR \-G ", " \-\-show\-pt\-geometry
 List the geometry of the indicated disks guessed by looking at
 the partition table.
 .TP
-.BR \-l " or " \-\-list
+.BR \-l ", " \-\-list
 List the partitions of a device.
 .TP
-.BR \-d " or " \-\-dump
-Dump the partitions of a device in a format useful as input
-to sfdisk. For example,
+.BR \-d ", " \-\-dump
+Dump the partitions of a device in a format that is usable as input
+to /fBsfdisk/fR.  For example,
 .br
 .nf
 .if t .ft CW
@@ -197,20 +198,18 @@ to sfdisk. For example,
 will correct the bad last extended partition that the OS/2
 fdisk creates.
 .TP
-.BR \-V " or " \-\-verify
-Test whether partitions seem correct. (See above.)
+.BR \-V ", " \-\-verify
+Test whether partitions seem correct.  (See the third invocation type above.)
 .TP
-.BR \-i " or " \-\-increment
+.BR \-i ", " \-\-increment
 Number cylinders etc. starting from 1 instead of 0.
 .TP
 .BI \-N " number"
-Change only the single partition indicated. For example:
-.br
+Change only the single partition indicated.  For example:
 .nf
 .if t .ft CW
     % sfdisk /dev/hdb \-N5
     ,,,*
-    %
 .if t .ft R
 .fi
 will make the fifth partition on /dev/hdb bootable (`active')
@@ -218,14 +217,14 @@ and change nothing else. (Probably this fifth partition
 is called /dev/hdb5, but you are free to call it something else,
 like `/my_equipment/disks/2/5' or so).
 .TP
-.BI \-A " or " \-\-activate " number"
+.BR \-A ", " \-\-activate " \fInumber\fR"
 Make the indicated partition(s) active, and all others inactive.
 .TP
-.BI \-c "\fR or " \-\-id " number [Id]"
-If no Id argument given: print the partition Id of the indicated
-partition. If an Id argument is present: change the type (Id) of
+.BR \-c ", " \-\-id " \fInumber\fR [\fIId\fR]"
+If no \fIId\fR argument given: print the partition Id of the indicated
+partition.  If an \fIId\fR argument is present: change the type (Id) of
 the indicated partition to the given value.
-This option has the two very long forms \-\-print\-id and \-\-change\-id.
+This option has two longer forms, \fB\-\-print\-id\fR and \fB\-\-change\-id\fR.
 For example:
 .br
 .nf
@@ -238,40 +237,42 @@ For example:
 .fi
 first reports that /dev/hdb5 has Id 6, and then changes that into 83.
 .TP
-.BR \-u " or " \-\-unit " SBCM"
-Accept as input, or when reporting show, in units of Sectors
-(Blocks, Cylinders, Megabytes, respectively). The default is
+.BR \-u ", " \-\-unit " \fI\letter\fR"
+Interpret the input and show the output in the units specified by
+.IR letter .
+This \fIletter\fR can be one of S, C, B or M, meaning Sectors, Cylinders,
+Blocks and Megabytes, respectively.  The default is
 cylinders, at least when the geometry is known.
 .TP
-.BR \-x " or " \-\-show\-extended
+.BR \-x ", " \-\-show\-extended
 Also list non-primary extended partitions on output,
 and expect descriptors for them on input.
 .TP
-.BI \-C " or " \-\-cylinders " cylinders"
+.BR \-C ", " \-\-cylinders " \fIcylinders\fR"
 Specify the number of cylinders, possibly overriding what the kernel thinks.
 .TP
-.BI \-H " or " \-\-heads " heads"
+.BR \-H ", " \-\-heads " \fIheads\fR"
 Specify the number of heads, possibly overriding what the kernel thinks.
 .TP
-.BI \-S " or " \-\-sectors " sectors"
+.BR \-S ", " \-\-sectors " \fIsectors\fR"
 Specify the number of sectors, possibly overriding what the kernel thinks.
 .TP
-.BR \-f " or " \-\-force
+.BR \-f ", " \-\-force
 Do what I say, even if it is stupid.
 .TP
-.BR \-q " or " \-\-quiet
+.BR \-q ", " \-\-quiet
 Suppress warning messages.
 .TP
-.BR \-L " or " \-\-Linux
+.BR \-L ", " \-\-Linux
 Do not complain about things irrelevant for Linux.
 .TP
-.BR \-D " or " \-\-DOS
+.BR \-D ", " \-\-DOS
 For DOS-compatibility: waste a little space.
 (More precisely: if a partition cannot contain sector 0,
 e.g. because that is the MBR of the device, or contains
 the partition table of an extended partition, then
 .B sfdisk
-would make it start the next sector. However, when this
+would make it start the next sector.  However, when this
 option is given it skips to the start of the next track,
 wasting for example 33 sectors (in case of 34 sectors/track),
 just like certain versions of DOS do.)
@@ -279,20 +280,20 @@ Certain Disk Managers and boot loaders (such as OSBS, but not
 LILO or the OS/2 Boot Manager) also live in this empty space,
 so maybe you want this option if you use one.
 .TP
-.BR \-E " or " \-\-DOS\-extended
+.BR \-E ", " \-\-DOS\-extended
 Take the starting sector numbers of "inner" extended partitions
-to be relative to the starting cylinder boundary of the outer one,
-(like some versions of DOS do) rather than to the starting sector
-(like Linux does).
+to be relative to the starting cylinder boundary of the outer one
+(like some versions of DOS do), rather than relative to the actual
+starting sector (like Linux does).
 (The fact that there is a difference here means that one should
 always let extended partitions start at cylinder boundaries if
 DOS and Linux should interpret the partition table in the same way.
 Of course one can only know where cylinder boundaries are when
 one knows what geometry DOS will use for this disk.)
 .TP
-.BR \-\-IBM " or " \-\-leave\-last
+.BR \-\-IBM ", " \-\-leave\-last
 Certain IBM diagnostic programs assume that they can use the
-last cylinder on a disk for disk-testing purposes. If you think
+last cylinder on a disk for disk-testing purposes.  If you think
 you might ever run such programs, use this option to tell
 .B sfdisk
 that it should not allocate the last cylinder.
@@ -301,9 +302,9 @@ Sometimes the last cylinder contains a bad sector table.
 .B \-n
 Go through all the motions, but do not actually write to disk.
 .TP
-.B \-R " or " \-\-re-read
+.BR \-R ", " \-\-re-read
 Only execute the BLKRRPART ioctl (to make the kernel re-read
-the partition table). This can be useful for checking in advance
+the partition table).  This can be useful for checking in advance
 that the final BLKRRPART will be successful, and also when you
 changed the partition table `by hand' (e.g., using dd from a backup).
 If the kernel complains (`device busy for revalidation (usage = 2)')
@@ -311,35 +312,35 @@ then something still uses the device, and you still have to unmount
 some file system, or say swapoff to some swap partition.
 .TP
 .B \-\-no\-reread
-When starting a repartitioning of a disk, sfdisk checks that this disk
+When starting a repartitioning of a disk, \fBsfdisk\fR checks that this disk
 is not mounted, or in use as a swap device, and refuses to continue
-if it is. This option suppresses the test. (On the other hand, the \-f
-option would force sfdisk to continue even when this test fails.)
+if it is.  This option suppresses the test.  (On the other hand, the \fB\-f\fR
+option would force \fBsfdisk\fR to continue even when this test fails.)
 .TP
 .B \-\-in\-order
-Caution, see warning section. To be documented.
+Caution, see warning section.  To be documented.
 .TP
 .B \-\-not\-in\-order
-Caution, see warning section. To be documented.
+Caution, see warning section.  To be documented.
 .TP
 .B \-\-inside\-outer
-Caution, see warning section. Chaining order.
+Caution, see warning section.  Chaining order.
 .TP
 .B \-\-not\-inside\-outer
-Caution, see warning section. Chaining order.
+Caution, see warning section.  Chaining order.
 .TP
 .B \-\-nested
-Caution, see warning section. Every partition is contained in the
+Caution, see warning section.  Every partition is contained in the
 surrounding partitions and is disjoint from all others.
 .TP
 .B \-\-chained
-Caution, see warning section. Every data partition is contained in
+Caution, see warning section.  Every data partition is contained in
 the surrounding partitions and disjoint from all others, but
 extended partitions may lie outside (insofar as allowed by
 all_logicals_inside_outermost_extended).
 .TP
 .B \-\-onesector
-Caution, see warning section. All data partitions are mutually
+Caution, see warning section.  All data partitions are mutually
 disjoint; extended partitions each use one sector only (except
 perhaps for the outermost one).
 .TP
@@ -355,7 +356,7 @@ resides on another disk, or on a floppy).
 After destroying your filesystems with an unfortunate
 .B sfdisk
 command, you would have been able to restore the old situation
-if only you had preserved it using the \-O flag.
+if only you had preserved it using the \fB\-O\fR flag.
 
 .SH THEORY
 Block 0 of a disk (the Master Boot Record) contains among
@@ -506,10 +507,10 @@ and terminate with end-of-file (^D).
 .B sfdisk
 will assume that your input line represents the first of four,
 that the second one is extended, and the 3rd and 4th are empty.)
-.SH "CAUTION WARNIGNS"
+.SH "CAUTION WARNINGS"
 
 The options marked with caution in the manual page are dangerous.
-For example all functionality is not completely implemented,
+For example not all functionality is completely implemented,
 which can be a reason for unexpected results.
 .SH "DOS 6.x WARNING"
 
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-sfdisk-slice-help-text-into-small-chunks-and-improve.patch --]
[-- Type: text/x-patch; name="0002-sfdisk-slice-help-text-into-small-chunks-and-improve.patch", Size: 6385 bytes --]

From 86e3cb5853e6488bece669112ed30d5fc74005db Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Tue, 16 Aug 2011 20:53:21 +0200
Subject: [PATCH 2/2] sfdisk: slice help text into small chunks and improve its wording

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 fdisk/sfdisk.c |   67 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 08e1b0c..b32482b 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -2333,52 +2333,53 @@ usage(FILE * out) {
 	    program_invocation_short_name);
     fprintf(out, _("Device is something like /dev/hda or /dev/sda\n"));
 
-    fprintf(out, _("\nOptions:\n"
-		   "  -s, --show-size         list size of a partition\n"
+    fprintf(out, _("\nOptions:\n"));
+    fprintf(out, _("  -s, --show-size         list size of a partition\n"
 		   "  -c, --id                change or print partition Id\n"
 		   "      --change-id         change Id\n"
-		   "      --print-id          print Id\n"
-		   "  -l, --list              list partitions of each device\n"
+		   "      --print-id          print Id\n"));
+    fprintf(out, _("  -l, --list              list partitions of each device\n"
 		   "  -d, --dump              idem, but in a format suitable for later input\n"
 		   "  -i, --increment         number cylinders etc. from 1 instead of from 0\n"
-		   "  -u, --unit=[SBCM]       units in sectors, blocks, cylinders or MB\n"
-		   "  -1, --one-only          reserved option that does nothing currently\n"
+		   "  -u, --unit=LETTER       units to be used; LETTER can be one of\n"
+		   "                            S (sectors), C (cylinders), B (blocks), or M (MB)\n"));
+    fprintf(out, _("  -1, --one-only          reserved option that does nothing currently\n"
 		   "  -T, --list-types        list the known partition types\n"
 		   "  -D, --DOS               for DOS-compatibility: waste a little space\n"
 		   "  -E, --DOS-extended      DOS extended partition compatibility\n"
-		   "  -R, --re-read           make kernel reread partition table\n"
-		   "  -N=NUM                  change only the partition with number NUM\n"
+		   "  -R, --re-read           make the kernel reread the partition table\n"));
+    fprintf(out, _("  -N NUMBER               change only the partition with this NUMBER\n"
 		   "  -n                      do not actually write to disk\n"
-		   "  -O FILE                 save the sectors that will be overwritten to file\n"
-		   "  -I FILE                 restore sectors from file\n"
-		   "  -V, --verify            check that listed partition is reasonable\n"
-		   "  -v, --version           print version\n"
-		   "  -h, --help              print this message\n"));
-
-    fprintf(out, _("\nDangerous options:\n"
-		   "  -f, --force             disable all consistency checking\n"
+		   "  -O FILE                 save the sectors that will be overwritten to FILE\n"
+		   "  -I FILE                 restore sectors from FILE\n"));
+    fprintf(out, _("  -V, --verify            check that the listed partitions are reasonable\n"
+		   "  -v, --version           display version information and exit\n"
+		   "  -h, --help              display this help text and exit\n"));
+
+    fprintf(out, _("\nDangerous options:\n"));
+    fprintf(out, _("  -f, --force             disable all consistency checking\n"
 		   "      --no-reread         do not check whether the partition is in use\n"
-		   "  -g, --show-geometry     print the kernel's idea of the geometry\n"
-		   "  -G, --show-pt-geometry  print geometry guessed from the partition table\n"
-		   "  -A, --activate[=device] activate bootable flag\n"
-		   "  -U, --unhide[=device]   set partition unhidden\n"
+		   "  -q, --quiet             suppress warning messages\n"
+		   "  -L, --Linux             do not complain about things irrelevant for Linux\n"));
+    fprintf(out, _("  -g, --show-geometry     print the kernel's idea of the geometry\n"
+		   "  -G, --show-pt-geometry  print geometry guessed from the partition table\n"));
+    fprintf(out, _("  -A, --activate[=DEVICE] activate bootable flag\n"
+		   "  -U, --unhide[=DEVICE]   set partition unhidden\n"
 		   "  -x, --show-extended     also list extended partitions in the output,\n"
-		   "                            or expect descriptors for them in the input\n"
-		   "      --leave-last        do not allocate the last cylinder\n"
-		   "      --IBM               same as --leave-last\n"
-		   "      --in-order          partitions are in order\n"
+		   "                            or expect descriptors for them in the input\n"));
+    fprintf(out, _("      --leave-last        do not allocate the last cylinder\n"
+		   "      --IBM               same as --leave-last\n"));
+    fprintf(out, _("      --in-order          partitions are in order\n"
 		   "      --not-in-order      partitions are not in order\n"
 		   "      --inside-outer      all logicals inside outermost extended\n"
-		   "      --not-inside-outer  not all logicals inside outermost extended\n"
-		   "      --nested            every partition is disjoint from all others\n"
+		   "      --not-inside-outer  not all logicals inside outermost extended\n"));
+    fprintf(out, _("      --nested            every partition is disjoint from all others\n"
 		   "      --chained           like nested, but extended partitions may lie outside\n"
-		   "      --onesector         partitions are mutually disjoint\n"
-		   "  -L, --Linux             do not complain about things irrelevant for Linux\n"
-		   "  -q, --quiet             suppress warning messages\n"
-		   "\n  Override the detected geometry using:\n"
-		   "  -C, --cylinders=NUM     set the number of cylinders to use\n"
-		   "  -H, --heads=NUM         set the number of heads to use\n"
-		   "  -S, --sectors=NUM       set the number of sectors to use\n\n"));
+		   "      --onesector         partitions are mutually disjoint\n"));
+    fprintf(out, _("\n  Override the detected geometry using:\n"
+		   "  -C, --cylinders=NUMBER  set the number of cylinders to use\n"
+		   "  -H, --heads=NUMBER      set the number of heads to use\n"
+		   "  -S, --sectors=NUMBER    set the number of sectors to use\n\n"));
 
     exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
-- 
1.7.0.4


^ permalink raw reply related

* Re: [PATCH] partx: support loop devices
From: Karel Zak @ 2011-08-16 15:03 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux
In-Reply-To: <1313500807.2586.1.camel@offbook>

On Tue, Aug 16, 2011 at 09:20:07AM -0400, Davidlohr Bueso wrote:
> On Mon, 2011-08-15 at 13:58 +0200, Karel Zak wrote:
> > On Mon, Aug 15, 2011 at 12:11:17AM -0400, Davidlohr Bueso wrote:
> > > @@ -800,14 +857,23 @@ int main(int argc, char **argv)
> > >  	if (what == ACT_ADD || what == ACT_DELETE) {
> > >  		struct stat x;
> > >  
> > > -		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode))
> > > -			errx(EXIT_FAILURE, _("%s: not a block device"), wholedisk);
> > > +		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode)) {
> > 
> >   && S_ISREG() :-)
> > 
> > > +			/* not a blkdev, try to associate it to a loop device */
> > 
> >             if (what == ACT_DELETE)
> >                 errx(EXIT_FAILURE, _("%s: cannot delete partitions"), wholedisk);
> > 
> > > +			if (!loopmod_supports_parts())
> > > +				errx(EXIT_FAILURE, _("%s: does not support loop device partitions"), 
> > > +				     wholedisk);
> > > +			assoc_loopdev(wholedisk);
> > > +			wholedisk = xstrdup(lc.device);
> > > +		}
> > >  	}
> > >  	if ((fd = open(wholedisk, O_RDONLY)) == -1)
> > >  		err(EXIT_FAILURE, _("%s: open failed"), wholedisk);
> > >  
> > > -	if (what == ACT_DELETE)
> > > +	if (what == ACT_DELETE) {
> > > +		if (loopdev)
> > > +			errx(EXIT_FAILURE, _("%s: cannot delete partitions"), wholedisk);
> > >  		rc = del_parts(fd, wholedisk, disk_devno, lower, upper);
> > > +	}
> > 
> >  Does it make sense to initialize loop device if ACT_DELETE is requested?
> 
> Ah, yes, good catch. Below is the corrected patch, do you think this
> feature could go into 2.20?

 2.21, for 2.20 is too late

    Karel

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

^ permalink raw reply

* Re: [PATCH] partx: support loop devices
From: Davidlohr Bueso @ 2011-08-16 13:20 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110815115855.GE1843@nb.net.home>

On Mon, 2011-08-15 at 13:58 +0200, Karel Zak wrote:
> On Mon, Aug 15, 2011 at 12:11:17AM -0400, Davidlohr Bueso wrote:
> > @@ -800,14 +857,23 @@ int main(int argc, char **argv)
> >  	if (what == ACT_ADD || what == ACT_DELETE) {
> >  		struct stat x;
> >  
> > -		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode))
> > -			errx(EXIT_FAILURE, _("%s: not a block device"), wholedisk);
> > +		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode)) {
> 
>   && S_ISREG() :-)
> 
> > +			/* not a blkdev, try to associate it to a loop device */
> 
>             if (what == ACT_DELETE)
>                 errx(EXIT_FAILURE, _("%s: cannot delete partitions"), wholedisk);
> 
> > +			if (!loopmod_supports_parts())
> > +				errx(EXIT_FAILURE, _("%s: does not support loop device partitions"), 
> > +				     wholedisk);
> > +			assoc_loopdev(wholedisk);
> > +			wholedisk = xstrdup(lc.device);
> > +		}
> >  	}
> >  	if ((fd = open(wholedisk, O_RDONLY)) == -1)
> >  		err(EXIT_FAILURE, _("%s: open failed"), wholedisk);
> >  
> > -	if (what == ACT_DELETE)
> > +	if (what == ACT_DELETE) {
> > +		if (loopdev)
> > +			errx(EXIT_FAILURE, _("%s: cannot delete partitions"), wholedisk);
> >  		rc = del_parts(fd, wholedisk, disk_devno, lower, upper);
> > +	}
> 
>  Does it make sense to initialize loop device if ACT_DELETE is requested?

Ah, yes, good catch. Below is the corrected patch, do you think this
feature could go into 2.20?


From: Davidlohr Bueso <dave@gnu.org>
Date: Tue, 16 Aug 2011 09:17:10 -0400
Subject: [PATCH] partx: support loop devices

Add support for loop devices to add partitions. For now we make use of the max_part parameter from the loop kernel module,
otherwise the feature is disabled.

Below an example output:

root@offbook:~/projects/util-linux/partx# ./partx -a -n 1:5 images-pt/dos+bsd.img
root@offbook:~/projects/util-linux/partx# ls /dev/loop0* -ltr
brw-rw---- 1 root disk 7, 0 2011-08-15 00:07 /dev/loop0
brw-rw---- 1 root disk 7, 5 2011-08-15 00:07 /dev/loop0p5
brw-rw---- 1 root disk 7, 2 2011-08-15 00:07 /dev/loop0p2
brw-rw---- 1 root disk 7, 1 2011-08-15 00:07 /dev/loop0p1

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
---
 partx/Makefile.am |    2 +
 partx/partx.c     |   75 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 74 insertions(+), 3 deletions(-)

diff --git a/partx/Makefile.am b/partx/Makefile.am
index 6a72942..080bc47 100644
--- a/partx/Makefile.am
+++ b/partx/Makefile.am
@@ -11,6 +11,8 @@ partx_SOURCES = partx.c partx.h \
 		$(top_srcdir)/lib/at.c \
 		$(top_srcdir)/lib/mbsalign.c \
 		$(top_srcdir)/lib/strutils.c \
+		$(top_srcdir)/lib/canonicalize.c \
+		$(top_srcdir)/lib/loopdev.c \
 		$(top_srcdir)/lib/linux_version.c
 
 partx_CFLAGS = -I$(ul_libblkid_incdir)
diff --git a/partx/partx.c b/partx/partx.c
index 0b35f9f..8a4a23c 100644
--- a/partx/partx.c
+++ b/partx/partx.c
@@ -31,6 +31,7 @@
 #include "xalloc.h"
 #include "partx.h"
 #include "sysfs.h"
+#include "loopdev.h"
 #include "at.h"
 
 /* this is the default upper limit, could be modified by --nr */
@@ -88,7 +89,49 @@ static int columns[__NCOLUMNS], ncolumns;
 
 static int verbose;
 static int partx_flags;
+static struct loopdev_cxt lc;
+static int loopdev = 0;
 
+/*
+ * Check if the kernel supports partitioned loop devices.
+ * In a near future (around linux 3.2, hopefully) this will come
+ * always out of the box, until then we need to check.
+ */
+static int loopmod_supports_parts(void)
+{
+	int rc, ret = 0;
+	FILE *f = fopen("/sys/module/loop/parameters/max_part", "r");
+	
+	if (!f)
+		return 0;
+	rc = fscanf(f, "%d", &ret);
+	fclose(f);
+	return ret;
+}
+
+static void assoc_loopdev(const char *fname)
+{
+	int rc;
+
+	loopcxt_init(&lc, 0);
+	
+	rc = loopcxt_find_unused(&lc);
+	if (rc)
+		err(EXIT_FAILURE, "failed to find unused device");
+
+	if (verbose)
+		printf("Trying to use '%s' for the loop device\n", loopcxt_get_device(&lc));
+	
+	if (loopcxt_set_backing_file(&lc, fname))
+		err(EXIT_FAILURE, "failed to set backing file");
+
+	rc = loopcxt_setup_device(&lc);
+
+	if (rc == -EBUSY)
+		err(EXIT_FAILURE, "failed to setup device for %s", fname);
+
+	loopdev = 1;
+}
 
 static inline int get_column_id(int num)
 {
@@ -278,6 +321,7 @@ static int del_parts(int fd, const char *device, dev_t devno,
 	return rc;
 }
 
+
 static void add_parts_warnx(const char *device, int first, int last)
 {
 	if (first == last)
@@ -288,7 +332,7 @@ static void add_parts_warnx(const char *device, int first, int last)
 }
 
 static int add_parts(int fd, const char *device,
-			blkid_partlist ls, int lower, int upper)
+		     blkid_partlist ls, int lower, int upper)
 {
 	int i, nparts, rc = 0, errfirst = 0, errlast = 0;
 
@@ -338,6 +382,19 @@ static int add_parts(int fd, const char *device,
 
 	if (errfirst)
 		add_parts_warnx(device, errfirst, errlast);
+
+	/* the kernel adds *all* loopdev partitions, so we should delete
+	   any extra, unwanted ones, when the -n option is passed */
+	if (loopdev && (lower || upper)) {
+		for (i = 0; i < nparts; i++) {
+			blkid_partition par = blkid_partlist_get_partition(ls, i);
+			int n = blkid_partition_get_partno(par);
+			
+			if (n < lower || n > upper)
+				partx_del_partition(fd, n);
+		}
+	}
+
 	return rc;
 }
 
@@ -800,8 +857,17 @@ int main(int argc, char **argv)
 	if (what == ACT_ADD || what == ACT_DELETE) {
 		struct stat x;
 
-		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode))
-			errx(EXIT_FAILURE, _("%s: not a block device"), wholedisk);
+		if (stat(wholedisk, &x) || !S_ISBLK(x.st_mode) && S_ISREG(x.st_mode)) {
+			/* not a blkdev, try to associate it to a loop device */
+			if (what == ACT_DELETE)
+				errx(EXIT_FAILURE, _("%s: cannot delete partitions"), wholedisk);
+
+			if (!loopmod_supports_parts())
+				errx(EXIT_FAILURE, _("%s: does not support loop device partitions"), 
+				     wholedisk);
+			assoc_loopdev(wholedisk);
+			wholedisk = xstrdup(lc.device);
+		}
 	}
 	if ((fd = open(wholedisk, O_RDONLY)) == -1)
 		err(EXIT_FAILURE, _("%s: open failed"), wholedisk);
@@ -846,6 +912,9 @@ int main(int argc, char **argv)
 		blkid_free_probe(pr);
 	}
 
+	if (loopdev)
+		loopcxt_deinit(&lc);
+
 	close(fd);
 	return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }
-- 
1.7.4.1

^ permalink raw reply related

* Re: [patches] small fixes to some messages and man pages, and some questions
From: Karel Zak @ 2011-08-16 12:57 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Util-Linux
In-Reply-To: <1313433269.27812.140258129893485@webmail.messagingengine.com>

On Mon, Aug 15, 2011 at 08:34:29PM +0200, Benno Schulenberg wrote:
> 
> > > Also I do not understand the descriptions of the new options --nested,
> > > --chained, and --onesector.  [...]
> > 
> > The original comment from code: 
> > 
> > /* [...]
> > NESTED: every partition is contained in the surrounding partitions
> >    and is disjoint from all others.
> 
> I still fail to understand. 

 The each logical partition is defined by extended partition table
 (EBR) http://en.wikipedia.org/wiki/Extended_boot_record

 EBR contains usually two partitions:
    1/ data partition (used as a logical partition)
    2/ extended partition (used as a pointer to the next EBR)

 so if you have 5 logical partitions then there is usually 5 small
 partition tables and 5 extended partitions :-) The partitions are
 usually NESTED. 
 
 The top-level (outermost) extended partition is the partition 
 visible for end-users in fdisk output.

> If "contained in the surrounding partitions"
> means "contained in the containing partitions", it says nothing.  If it
> means "contained in the partitions that come before and after", this
> seems impossible to me.  The only way I can make sense of the
> above comment is to read it as follows:
> 
> NESTED: every extended partition is contained within a surrounding
> extended partition [except of course the outermost one] and is disjoint
> from all other extended partitions at the same nesting level.
> 
> (Here I take "disjoint" to mean "does not overlap", but then I still fail
> to understand how "mutually disjoint" is different.)

 NESTED: every extended partition is contained within a parental 
         extended partition. 

 IMHO nothing other is usable in Linux.

> 
> > CHAINED: every data partition is contained in the surrounding partitions
> >    and disjoint from all others, but extended partitions may lie outside
> 
> Is a data partition the same as a logical partition?

Yes. 

IMHO the comment is mess as well as the implementation :-) Don't think
about it too much. We need to rewrite sfdisk and cfdisk....

> >    scriptreplay [options] [-t] timingfile [typescript [divisor]]

 Fixed in the usage().

    Karel

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

^ permalink raw reply

* Re: [patches] small fixes to some help texts and man pages
From: Karel Zak @ 2011-08-16 12:33 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Util-Linux
In-Reply-To: <1313434832.3403.140258129904445@webmail.messagingengine.com>

On Mon, Aug 15, 2011 at 09:00:32PM +0200, Benno Schulenberg wrote:
> Attached bunch of patches correct some small mistakes in some
> help texts and man pages, and additionally make several small
> improvements in wording and formatting.  They also slice up some
> help texts into small chunks, to make things easier to handle for
> translators.

 Good idea. Thanks.

> In the source tree there are two mount.c files: mount/mount.c
> and libmount/samples/mount.c.  Is the latter a future replacement
> of the first?  Or is it a version that can already be used instead of
> the former one?  If both are valid versions, then the sixth patch
> should not be applied and the seventh yes.  If the mount.c in
> libmount/ is just sample code or a future replacement, then
> please apply the sixth patch (although you may want to change
> the actual mechanism of the exclusion).

 All applied :-) The libmount/sample/mount.c is a future replacement.
 It's good idea to ignore */samples/* directories.

    Karel

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

^ permalink raw reply

* Re: man-pages and usage() howto
From: Karel Zak @ 2011-08-16 10:46 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: kerolasa, util-linux
In-Reply-To: <1313485424.19019.140258130122469@webmail.messagingengine.com>

On Tue, Aug 16, 2011 at 11:03:44AM +0200, Benno Schulenberg wrote:
> > >        command [options] file
> 
> If in the usage() help text the arguments of options are written in
> uppercase, wouldn't it be more consistent to then also write the

 It depends, Semi's version is uppercase, but my (findmnt, blkid,
 lsblk, ...) is <lowercase> :-) 

> About the other things I have not yet an opinion.

 I made the decision, --option <argument>. We can play with it little
 bit more in the next release. Now I'd like to release it...

 It would be also nice to sync man pages with usage() format. Note
 that man pages changes are acceptable for -rc2.

    Karel

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

^ permalink raw reply

* Re: man-pages and usage() howto
From: Karel Zak @ 2011-08-16 10:39 UTC (permalink / raw)
  To: kerolasa; +Cc: Benno Schulenberg, util-linux
In-Reply-To: <CAG27Bk0LpsVdCJhvOAstC_OpckzfBB05kcZcN_ByF_i_JQU6SQ@mail.gmail.com>

On Mon, Aug 15, 2011 at 09:12:16PM +0200, Sami Kerola wrote:
> On Mon, Aug 15, 2011 at 16:19, Karel Zak <kzak@redhat.com> wrote:
> > Sami is already working on some howtos, what we need is some
> > consensus about a way how describe options.
> 
> What I wrote about various things can be found from github. I'd say
> that so far the Documentation directory patch set is a proposal, which
> can and should change.

 Yep, I think we can make it "perfect" in your githup repository
 before we merge it upstream ;-)

> I used GNU notation which has 'unnecessary' equals sign.

[...]

> IMHO the visual unity is better.

 I understand, but I'm not sure about readability... well, I have asked
 my colleagues and the winer is:

    --date <time>
    
 the important is visual difference between static option name and variable
 option argument.

 You can hate me, but we need any decision. I'll cleanup the usage()
 strings now.

> So the howto should tell how do you know you are dealing with
> fundamental difference of outcome, which requires multiple synopsis
> lines. Obvious trap seems to be such hermeneutic circle that no-one
> understands what the howto tries to say. Rigour rejection until the
> text is good is needed.

 I think we have to use common sense here. Sometimes multiple synopsis
 lines makes sense (losetup -h ?). There is not necessary any strict
 rule.

 [...]

> Assuming this approach sounds good the question is shall we write
> shortest or longest possible list of well known options list? I'm in
> favour of short list because it requires less maintenance.

 Sure, I agree.

 I'm just working on Benno's patches and I found that we need some
 explicitly defined rules for usage():

    - "Usage:" and "Options:" use separate lines and strings, before
       the sections has to be empty line:

       fputs(_("\nUsage:\n"), out);
       ...
       fputs(_("\nOptions:\n"), out);

     (so this two string will be translated only once)

   - all lines with options and synopsis are prefixed 
     by ***one*** space (0x40):

       fputs(_("\nUsage:\n"), out);
       fprintf(out,
             _(" %s [options]\n"), something);

       fputs(_("\nOptions:\n"), out);
       fputs(_(" -b, --bar            this is bar\n");

   - in the code all strings with options have to start at the same
     position. It means:

     fprintf(out, _(" -x[=<foo>]   default foo is %s"), x);
     fputs(       _(" -y         some text"), out);

   - the first and last usage() output line is empty

   - the last line does not have to be empty if there is additional
     info about a man page "For more details see foo(1)."

   - use manageable chunks for the usage strings (one or few lines)

   - separator between short and long options is comma and one space:
     " -x, --long-x "

 Comments?

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

^ permalink raw reply

* Re: man-pages and usage() howto
From: Benno Schulenberg @ 2011-08-16  9:03 UTC (permalink / raw)
  To: kerolasa; +Cc: Karel Zak, util-linux
In-Reply-To: <CAG27Bk0LpsVdCJhvOAstC_OpckzfBB05kcZcN_ByF_i_JQU6SQ@mail.gmail.com>


On Mon, 15 Aug 2011 21:12 +0200, "Sami Kerola" <kerolasa@iki.fi> wrote:
> On Mon, Aug 15, 2011 at 16:19, Karel Zak <kzak@redhat.com> wrote:
> > =C2=A0* argument required:
> >
> > =C2=A0 -o, --option FILE =C2=A0 =C2=A0# usage()
> > =C2=A0 -o, --option file =C2=A0 =C2=A0# man page
>=20
> I used GNU notation which has 'unnecessary' equals sign.
>=20
> -o, --option=3DFILE

The full GNU style seems to be this (for example in 'man grep'):

  -o FILE, --option=3DFILE

Since the util-linux man pages don't put the argument after the short
version of the option, the '  -o, --option FILE' variant would be for me
the logical condensed intersection.  Also, why give the impression
that the equals sign is needed when it is not?
=20
> The only reason I can think of why the equal sign is there is visual
> similarity with optional argument... [...]
>=20
> I also acknowledge the fact that no-one will ever use equals sign when
> giving required argument. The practise of dropping it is a rational
> reason not to specify it to usage() or man. I would say this is a
> question of choosing a convention in between visual symmetry or actual
> habits of people. IMHO the visual unity is better.

IMHO visual contrast is better.  When my fleeting glance sees an equals
sign OR square brackets, I know the argument is optional; when it does
not see an equals sign OR does not see square brackets, the argument is
required.  Redundancy is good.


> > =C2=A0 =C2=A0 =C2=A0 =C2=A0command [options] file

If in the usage() help text the arguments of options are written in
uppercase, wouldn't it be more consistent to then also write the
arguments of the command itself in uppercase (as for example
'man -h' and 'grep --help' do)?

        command [OPTIONS] FILE

(Also, to be fully correct, it would have to say "[OPTION...]" instead,
but I will let that go.)

About the other things I have not yet an opinion.

Regards,

Benno

--=20
http://www.fastmail.fm - Access all of your messages and folders
                          wherever you are

^ permalink raw reply

* Re: man-pages and usage() howto
From: Sami Kerola @ 2011-08-15 19:12 UTC (permalink / raw)
  To: Karel Zak; +Cc: Benno Schulenberg, util-linux
In-Reply-To: <20110815141948.GH2038@nb.net.home>

On Mon, Aug 15, 2011 at 16:19, Karel Zak <kzak@redhat.com> wrote:
> Sami is already working on some howtos, what we need is some
> consensus about a way how describe options.

What I wrote about various things can be found from github. I'd say
that so far the Documentation directory patch set is a proposal, which
can and should change.

https://github.com/kerolasa/lelux-utiliteetit/blob/docs-dir/Documentation/h=
owto-usage-function.txt

> My suggestion:
>
> =A0* argument required:
>
> =A0 -o, --option FILE =A0 =A0# usage()
> =A0 -o, --option file =A0 =A0# man page

I used GNU notation which has 'unnecessary' equals sign.

-o, --option=3DFILE

The only reason I can think of why the equal sign is there is visual
similarity with optional argument...

> =A0* optional argument:
>
> =A0 -o, --option[=3DFILE] =A0# usage()
> =A0 -o, --option[=3Dfile] =A0# man page

...because with optional arguments one must use =3D and that make the
[=3DFILE] notation correct. For example see the output of the following.

lscpu -p=3DCPU
lscpu -p CPU

I also acknowledge the fact that no-one will ever use equals sign when
giving required argument. The practise of dropping it is a rational
reason not to specify it to usage() or man. I would say this is a
question of choosing a convention in between visual symmetry or actual
habits of people. IMHO the visual unity is better.

> =A0* synopsis
>
> =A0 - without individual options, bad example:
>
> =A0 =A0 =A0 =A0command [-o offset] [--sizelimit size] [-p pfd] [-r] file
>
> =A0 - [options] is better:
>
> =A0 =A0 =A0 =A0command [options] file

I agree.

> =A0 - use more synopsis lines if the command supports more separated mode=
s.
>
> =A0 =A0 =A0 command --add file
> =A0 =A0 =A0 command --del file
>
> =A0 =A0 (use common sense! ... if there is too many modes, then use [opti=
ons])
>
> =A0 =A0 The options specific to the mode are allowed in the synopsis or
> =A0 =A0 in the man page should be per-mode section with description about
> =A0 =A0 the options.

I did not think multiple modes when I  wrote howto-usage. Manual page
of man seems to be good example of extensive synopsis. If I've not
gone crazy the point of modes seems to point out that some options,
arguments, etc mean outcome of an execution is fundamentally
different, for example

man -k basename
man -w basename

So the howto should tell how do you know you are dealing with
fundamental difference of outcome, which requires multiple synopsis
lines. Obvious trap seems to be such hermeneutic circle that no-one
understands what the howto tries to say. Rigour rejection until the
text is good is needed.

> =A0* common options:
>
> =A0 -V, --version
> =A0 -h, --help

I would call these two options explicitly reserved. The `-?' should
not be a synonym of `-h' but an invalid option in common case.

> =A0* suggestions:
>
> =A0 -a, --all
> =A0 -o, --output <list>
> =A0 -r, --raw
> =A0 -f, --force
> =A0 -b, --bytes =A0 (don't print SIZE in human readable format)

Eric S. Raymond's The Art of Unix Programming is proposing something simila=
r.

http://www.faqs.org/docs/artu/ch10s05.html

In nutshell one should think carefully before using a short option
against it's well known other use.

I can think immediately an annoyance in the rule of well known. Well
known to who, in what context and is it even relevant? Could good go
around for this problem is to give a concrete list of short & long
options which in context of this package are well-known, and nothing
else is. That will also allow several well known definitions to a
single short option, which I like. For example

-s, --size
-s, --silent  (prefer -q)
-q, --quiet

Assuming this approach sounds good the question is shall we write
shortest or longest possible list of well known options list? I'm in
favour of short list because it requires less maintenance.

> =A0* We also need any consensus about groff formatting, the ideal
> =A0 solution would be add any Documentation/example.man

Here's my proposal, which without doubt needs honing.

https://github.com/kerolasa/lelux-utiliteetit/blob/docs-dir/Documentation/h=
owto-man-page.txt

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

^ permalink raw reply

* [patches] small fixes to some help texts and man pages
From: Benno Schulenberg @ 2011-08-15 19:00 UTC (permalink / raw)
  To: Util-Linux

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


Hi,

Attached bunch of patches correct some small mistakes in some
help texts and man pages, and additionally make several small
improvements in wording and formatting.  They also slice up some
help texts into small chunks, to make things easier to handle for
translators.

In the source tree there are two mount.c files: mount/mount.c
and libmount/samples/mount.c.  Is the latter a future replacement
of the first?  Or is it a version that can already be used instead of
the former one?  If both are valid versions, then the sixth patch
should not be applied and the seventh yes.  If the mount.c in
libmount/ is just sample code or a future replacement, then
please apply the sixth patch (although you may want to change
the actual mechanism of the exclusion).

Regards,

Benno

-- 
http://www.fastmail.fm - Faster than the air-speed velocity of an
                          unladen european swallow


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-fsck-in-usage-unmark-type-as-optional-for-the-t-opti.patch --]
[-- Type: text/x-patch; name="0001-fsck-in-usage-unmark-type-as-optional-for-the-t-opti.patch", Size: 1960 bytes --]

From 7963665645c2c94f67c0dd5114e575bbc73b3035 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 13 Aug 2011 17:15:42 +0200
Subject: [PATCH 01/11] fsck: in usage() unmark type as optional for the -t option

Also fix "specity" typo, spell "filesystem" consistently as one word,
swap the wording of one phrase, and use some semicolons for clarity.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 fsck/fsck.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 88a67c8..387b5b9 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -1215,17 +1215,17 @@ static void __attribute__((__noreturn__)) usage(void)
 		program_invocation_short_name);
 
 	puts(_(	"\nOptions:\n"
-		"  -A         check all file systems\n"
-		"  -R         skip root, useful only with -A\n"
+		"  -A         check all filesystems\n"
+		"  -R         skip root filesystem; useful only with `-A'\n"
 		"  -M         do not check mounted filesystems\n"
-		"  -t [type]  specity file system types to be checked\n"
-		"             type is allowed to be comma-separated list\n"
-		"  -P         check file systems in parallel, including root\n"
+		"  -t type    specify filesystem types to be checked;\n"
+		"               type is allowed to be comma-separated list\n"
+		"  -P         check filesystems in parallel, including root\n"
 		"  -s         serialize fsck operations\n"
-		"  -l         use flock to lock device\n"
+		"  -l         lock the device using flock()\n"
 		"  -N         do not execute, just show what would be done\n"
 		"  -T         do not show the title on startup\n"
-		"  -C [fd]    display progress bar, file descriptor is for GUIs\n"
+		"  -C [fd]    display progress bar; file descriptor is for GUIs\n"
 		"  -V         explain what is being done\n"
 		"  -?         display this help and exit\n\n"
 		"See fsck.* commands for fs-options."));
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-fsck-in-man-page-say-that-options-take-arguments-not.patch --]
[-- Type: text/x-patch; name="0002-fsck-in-man-page-say-that-options-take-arguments-not.patch", Size: 11664 bytes --]

From 7106f9fa136cf527d2186d0584d591ee878b875b Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 13 Aug 2011 17:53:09 +0200
Subject: [PATCH 02/11] fsck: in man page say that "options take arguments", not vice versa

Also spell "filesystem" consistently as a single word, improve some
wordings here and there, and fix a few formatting and spacing issues.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 fsck/fsck.8 |  103 ++++++++++++++++++++++++++++------------------------------
 1 files changed, 50 insertions(+), 53 deletions(-)

diff --git a/fsck/fsck.8 b/fsck/fsck.8
index 40fe625..07eaaea 100644
--- a/fsck/fsck.8
+++ b/fsck/fsck.8
@@ -4,7 +4,7 @@
 .\"
 .TH FSCK 8 "February 2009" "Linux" "MAINTENANCE COMMANDS"
 .SH NAME
-fsck \- check and repair a Linux file system
+fsck \- check and repair a Linux filesystem
 .SH SYNOPSIS
 .B fsck
 .RB [ \-lsAVRTMNP ]
@@ -17,7 +17,7 @@ fsck \- check and repair a Linux file system
 .RI [ fs-specific-options ]
 .SH DESCRIPTION
 .B fsck
-is used to check and optionally repair one or more Linux file systems.
+is used to check and optionally repair one or more Linux filesystems.
 .I filesys
 can be a device name (e.g.
 .IR /dev/hdc1 ", " /dev/sdb2 ),
@@ -28,8 +28,7 @@ UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root).
 Normally, the
 .B fsck
 program will try to handle filesystems on different physical disk drives
-in parallel to reduce the total amount of time needed to check all of the
-filesystems.
+in parallel to reduce the total amount of time needed to check all of them.
 .PP
 If no filesystems are specified on the command line, and the
 .B \-A
@@ -47,11 +46,11 @@ is the sum of the following conditions:
 .br
 \	0\	\-\ No errors
 .br
-\	1\	\-\ File system errors corrected
+\	1\	\-\ Filesystem errors corrected
 .br
 \	2\	\-\ System should be rebooted
 .br
-\	4\	\-\ File system errors left uncorrected
+\	4\	\-\ Filesystem errors left uncorrected
 .br
 \	8\	\-\ Operational error
 .br
@@ -59,36 +58,36 @@ is the sum of the following conditions:
 .br
 \	32\	\-\ Fsck canceled by user request
 .br
-\	128\	\-\ Shared library error
+\	128\	\-\ Shared-library error
 .br
-The exit code returned when multiple file systems are checked
+The exit code returned when multiple filesystems are checked
 is the bit-wise OR of the exit codes for each
-file system that is checked.
+filesystem that is checked.
 .PP
 In actuality,
 .B fsck
-is simply a front-end for the various file system checkers
-(\fBfsck\fR.\fIfstype\fR) available under Linux.  The file
-system-specific checker is searched for in
+is simply a front-end for the various filesystem checkers
+(\fBfsck\fR.\fIfstype\fR) available under Linux.  The
+filesystem-specific checker is searched for in
 .I /sbin
 first, then in
 .I /etc/fs
 and
 .IR /etc ,
 and finally in the directories listed in the PATH environment
-variable.  Please see the file system-specific checker manual pages for
+variable.  Please see the filesystem-specific checker manual pages for
 further details.
 .SH OPTIONS
 .TP
 .B \-l
-Lock whole-disk device by exclusive
+Lock the whole-disk device by an 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
+This option can be used with one device only (this means that \fB-A\fR and
+\fB-l\fR 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
+instances are executed in the same time.  The option is ignored when used for
+multiple devices or for non-rotating disks.  \fBfsck\fR does not lock underlying
+devices when executed to check stacked devices (e.g. MD or DM) -- this feature is
 not implemented yet.
 .TP
 .B \-s
@@ -108,7 +107,7 @@ option, if you wish for errors to be corrected automatically, or the
 option if you do not.)
 .TP
 .BI \-t " fslist"
-Specifies the type(s) of file system to be checked.  When the
+Specifies the type(s) of filesystem to be checked.  When the
 .B \-A
 flag is specified, only filesystems that match
 .I fslist
@@ -122,12 +121,9 @@ or
 .RB ' ! ',
 which requests that only those filesystems not listed in
 .I fslist
-will be checked.  If all of the filesystems in
-.I fslist
-are not prefixed by a negation operator, then only those filesystems
-listed
-in
+will be checked.  If none of the filesystems in
 .I fslist
+is prefixed by a negation operator, then only those listed filesystems
 will be checked.
 .sp
 Options specifiers may be included in the comma-separated
@@ -180,16 +176,16 @@ given as an argument to the
 option,
 .B fsck
 will use the specified filesystem type.  If this type is not
-available, then the default file system type (currently ext2) is used.
+available, then the default filesystem type (currently ext2) is used.
 .TP
 .B \-A
 Walk through the
 .I /etc/fstab
-file and try to check all file systems in one run.  This option is
+file and try to check all filesystems in one run.  This option is
 typically used from the
 .I /etc/rc
 system initialization file, instead of multiple commands for checking
-a single file system.
+a single filesystem.
 .sp
 The root filesystem will be checked first unless the
 .B \-P
@@ -213,7 +209,7 @@ 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
+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
@@ -234,9 +230,9 @@ excessive paging is a concern.
 .sp
 .B fsck
 normally does not check whether the device actually exists before
-calling a file system specific checker. Therefore non-existing
-devices may cause the system to enter file system repair mode during
-boot if the filesystem specific checker returns a fatal error. The
+calling a filesystem specific checker.  Therefore non-existing
+devices may cause the system to enter filesystem repair mode during
+boot if the filesystem specific checker returns a fatal error.  The
 .B /etc/fstab
 mount option
 .B nofail
@@ -244,7 +240,7 @@ may be used to have
 .B fsck
 skip non-existing devices.
 .B fsck
-also skips non-existing devices that have the special file system type
+also skips non-existing devices that have the special filesystem type
 .B auto
 .
 .TP
@@ -275,15 +271,16 @@ for those sysadmins who don't want to repartition the root
 filesystem to be small and compact (which is really the right solution).
 .TP
 .B \-R
-When checking all file systems with the
+When checking all filesystems with the
 .B \-A
-flag, skip the root file system (in case it's already mounted read-write).
+flag, skip the root filesystem.  (This is useful in case the root
+filesystem has already been mounted read-write.)
 .TP
 .B \-T
 Don't show the title on startup.
 .TP
 .B \-V
-Produce verbose output, including all file system-specific commands
+Produce verbose output, including all filesystem-specific commands
 that are executed.
 .TP
 .B fs-specific-options
@@ -294,20 +291,20 @@ are passed to the filesystem-specific checker.  These arguments
 not take arguments, as there is no
 way for
 .B fsck
-to be able to properly guess which arguments take options and which
+to be able to properly guess which options take arguments and which
 don't.
 .IP
 Options and arguments which follow the
 .B \-\-
-are treated as file system-specific options to be passed to the
-file system-specific checker.
+are treated as filesystem-specific options to be passed to the
+filesystem-specific checker.
 .IP
 Please note that fsck is not
 designed to pass arbitrarily complicated options to filesystem-specific
 checkers.  If you're doing something complicated, please just
 execute the filesystem-specific checker directly.  If you pass
 .B fsck
-some horribly complicated option and arguments, and it doesn't do
+some horribly complicated options and arguments, and it doesn't do
 what you expect,
 .B don't bother reporting it as a bug.
 You're almost certainly doing something that you shouldn't be doing
@@ -317,20 +314,20 @@ with
 Options to different filesystem-specific fsck's are not standardized.
 If in doubt, please consult the man pages of the filesystem-specific
 checker.  Although not guaranteed, the following options are supported
-by most file system checkers:
+by most filesystem checkers:
 .TP
 .B \-a
-Automatically repair the file system without any questions (use
+Automatically repair the filesystem without any questions (use
 this option with caution).  Note that
 .BR e2fsck (8)
 supports
 .B \-a
-for backwards compatibility only.  This option is mapped to
+for backward compatibility only.  This option is mapped to
 .BR e2fsck 's
 .B \-p
 option which is safe to use, unlike the
 .B \-a
-option that some file system checkers support.
+option that some filesystem checkers support.
 .TP
 .B \-n
 For some filesystem-specific checkers, the
@@ -350,7 +347,7 @@ Interactively repair the filesystem (ask for confirmations).  Note: It
 is generally a bad idea to use this option if multiple fsck's are being
 run in parallel.  Also note that this is
 .BR e2fsck 's
-default behavior; it supports this option for backwards compatibility
+default behavior; it supports this option for backward compatibility
 reasons only.
 .TP
 .B \-y
@@ -364,7 +361,7 @@ all filesystem-specific checkers implement this option.  In particular
 .BR fsck.minix (8)
 and
 .BR fsck.cramfs (8)
-does not support the
+do not support the
 .B -y
 option as of this writing.
 .SH AUTHOR
@@ -382,32 +379,32 @@ program's behavior is affected by the following environment variables:
 .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
+will attempt to check 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.
+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
+This environment variable will limit the maximum number of filesystem
 checkers that can be running at one time.  This allows configurations
 which have a large number of disks to avoid
 .B fsck
-starting too many file system checkers at once, which might overload
+starting too many filesystem checkers at once, which might overload
 CPU and memory resources available on the system.  If this value is
 zero, then an unlimited number of processes can be spawned.  This is
 currently the default, but future versions of
 .B fsck
-may attempt to automatically determine how many file system checks can
+may attempt to automatically determine how many filesystem checks can
 be run based on gathering accounting data from the operating system.
 .TP
 .B PATH
 The
 .B PATH
-environment variable is used to find file system checkers.  A set of
+environment variable is used to find filesystem checkers.  A set of
 system directories are searched first:
 .BR /sbin ,
 .BR /sbin/fs.d ,
-.BR  /sbin/fs ,
+.BR /sbin/fs ,
 .BR /etc/fs ,
 and
 .BR /etc .
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-getopt-do-not-bundle-help-text-lines-into-a-single-u.patch --]
[-- Type: text/x-patch; name="0003-getopt-do-not-bundle-help-text-lines-into-a-single-u.patch", Size: 3061 bytes --]

From f713493ce0219119aed2f180e4f9bf7b2233b8c1 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 13 Aug 2011 20:11:21 +0200
Subject: [PATCH 03/11] getopt: do not bundle help text lines into a single unwieldy chunk

This undoes part of commit 283f8f0256655b73071290b92c58d998e883260a.
Help text lines are best gettextized separately, or in small chunks
of three to five lines, which are easily managed by translators.
Bundling text lines when nothing in those texts changed is discarding
translators' work unnecessarily.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 getopt/getopt.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/getopt/getopt.c b/getopt/getopt.c
index a211bcb..8da3178 100644
--- a/getopt/getopt.c
+++ b/getopt/getopt.c
@@ -313,20 +313,20 @@ static void __attribute__ ((__noreturn__)) print_help(void)
 {
 	fprintf(stderr, _("Usage: %1$s optstring parameters\n"
 			  "       %1$s [options] [--] optstring parameters\n"
-			  "       %1$s [options] -o|--options optstring [options] [--] parameters\n"
-			  "\nOptions:\n"
-			  "  -a, --alternative            Allow long options starting with single -\n"
-			  "  -h, --help                   This small usage guide\n"
-			  "  -l, --longoptions=longopts   Long options to be recognized\n"
-			  "  -n, --name=progname          The name under which errors are reported\n"
-			  "  -o, --options=optstring      Short options to be recognized\n"
-			  "  -q, --quiet                  Disable error reporting by getopt(3)\n"
-			  "  -Q, --quiet-output           No normal output\n"
-			  "  -s, --shell=shell            Set shell quoting conventions\n"
-			  "  -T, --test                   Test for getopt(1) version\n"
-			  "  -u, --unquote                Do not quote the output\n"
-			  "  -V, --version                Output version information\n\n"),
+			  "       %1$s [options] -o|--options optstring [options] [--] parameters\n",
 		program_invocation_short_name);
+	fputs(_("\nOptions:\n"),stderr);
+	fputs(_("  -a, --alternative            Allow long options starting with single -\n"),stderr);
+	fputs(_("  -h, --help                   This small usage guide\n"),stderr);
+	fputs(_("  -l, --longoptions=longopts   Long options to be recognized\n"),stderr);
+	fputs(_("  -n, --name=progname          The name under which errors are reported\n"),stderr);
+	fputs(_("  -o, --options=optstring      Short options to be recognized\n"),stderr);
+	fputs(_("  -q, --quiet                  Disable error reporting by getopt(3)\n"),stderr);
+	fputs(_("  -Q, --quiet-output           No normal output\n"),stderr);
+	fputs(_("  -s, --shell=shell            Set shell quoting conventions\n"),stderr);
+	fputs(_("  -T, --test                   Test for getopt(1) version\n"),stderr);
+	fputs(_("  -u, --unquote                Do not quote the output\n"),stderr);
+	fputs(_("  -V, --version                Output version information\n"),stderr);
 
 	exit(PARAMETER_EXIT_CODE);
 }
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #5: 0004-hwclock-when-cutting-up-help-texts-anyway-do-it-into.patch --]
[-- Type: text/x-patch; name="0004-hwclock-when-cutting-up-help-texts-anyway-do-it-into.patch", Size: 5079 bytes --]

From e833ffd88dfe68ea1b5e3d3a4b9fba191d080e74 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 13 Aug 2011 21:02:15 +0200
Subject: [PATCH 04/11] hwclock: when cutting up help texts anyway, do it into small chunks

Also do it at sensible boundaries, improve some of the wording, and
indent continuation lines for clarity.  Also document -V instead of
-v for --version, to conform to the majority of utilities.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 hwclock/hwclock.c |   54 ++++++++++++++++++++++++++++------------------------
 1 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/hwclock/hwclock.c b/hwclock/hwclock.c
index 021e5ac..7bcb20c 100644
--- a/hwclock/hwclock.c
+++ b/hwclock/hwclock.c
@@ -1372,26 +1372,30 @@ static void usage(const char *fmt, ...)
 	usageto = fmt ? stderr : stdout;
 
 	fprintf(usageto,
-		_("hwclock - query and set the hardware clock (RTC)\n\n"
-		  "Usage: hwclock [function] [options...]\n\n" "Functions:\n"
-		  "  -h | --help         show this help\n"
+		_("Usage: hwclock [function] [option...]\n\n"
+		  "Query or set the hardware clock (the RTC).\n\n"));
+	fprintf(usageto,
+		_( "Functions:\n"
+		  "  -h | --help         show this help text and exit\n"
 		  "  -r | --show         read hardware clock and print result\n"
-		  "       --set          set the rtc to the time given with --date\n"
-		  "  -s | --hctosys      set the system time from the hardware clock\n"
-		  "  -w | --systohc      set the hardware clock to the current system time\n"
+		  "       --set          set the RTC to the time given with --date\n"));
+	fprintf(usageto,
+		_("  -s | --hctosys      set the system time from the hardware clock\n"
+		  "  -w | --systohc      set the hardware clock from the current system time\n"
 		  "       --systz        set the system time based on the current timezone\n"
-		  "       --adjust       adjust the rtc to account for systematic drift since\n"
-		  "                      the clock was last set or adjusted\n"));
+		  "       --adjust       adjust the RTC to account for systematic drift since\n"
+		  "                        the clock was last set or adjusted\n"));
 #ifdef __linux__
 	fprintf(usageto,
 		_("       --getepoch     print out the kernel's hardware clock epoch value\n"
 		  "       --setepoch     set the kernel's hardware clock epoch value to the \n"
-		  "                      value given with --epoch\n"));
+		  "                        value given with --epoch\n"));
 #endif
 	fprintf(usageto,
-		_("       --predict      predict rtc reading at time given with --date\n"
-		  "  -v | --version      print out the version of hwclock to stdout\n"
-		  "\nOptions: \n"
+		_("       --predict      predict RTC reading at time given with --date\n"
+		  "  -V | --version      display version information and exit\n"));
+	fprintf(usageto,
+		_("\nOptions:\n"
 		  "  -u | --utc          the hardware clock is kept in UTC\n"
 		  "       --localtime    the hardware clock is kept in local time\n"));
 #ifdef __linux__
@@ -1400,22 +1404,22 @@ static void usage(const char *fmt, ...)
 #endif
 	fprintf(usageto,
 		_("       --directisa    access the ISA bus directly instead of %s\n"
-		  "       --badyear      ignore rtc's year because the bios is broken\n"
-		  "       --date         specifies the time to which to set the hardware clock\n"
-		  "       --epoch=year   specifies the year which is the beginning of the \n"
-		  "                      hardware clock's epoch value\n"
-		  "       --noadjfile    do not access %s. Requires the use of\n"
-		  "                      either --utc or --localtime\n"
-		  "       --adjfile=path specifies the path to the adjust file (default is\n"
-		  "                      %s)\n"
-		  "       --test         do everything except actually updating the hardware\n"
-		  "                      clock or anything else\n"
-		  "  -D | --debug        debug mode\n" "\n"), _PATH_RTC_DEV,
-		 _PATH_ADJPATH, _PATH_ADJPATH);
+		  "       --badyear      ignore RTC's year because the BIOS is broken\n"
+		  "       --date=time    specifies the time to which to set the hardware clock\n"
+		  "       --epoch=year   specifies the year which is the beginning of the\n"
+		  "                        hardware clock's epoch value\n"), _PATH_RTC_DEV);
+	fprintf(usageto,
+		_("       --noadjfile    do not access %s; this requires the use of\n"
+		  "                        either --utc or --localtime\n"
+		  "       --adjfile=path specifies the path to the adjust file;\n"
+		  "                        the default is %s\n"), _PATH_ADJPATH, _PATH_ADJPATH);
+	fprintf(usageto,
+		_("       --test         do not update anything, just show what would happen\n"
+		  "  -D | --debug        debugging mode\n" "\n"));
 #ifdef __alpha__
 	fprintf(usageto,
 		_("  -J|--jensen, -A|--arc, -S|--srm, -F|--funky-toy\n"
-		  "       tell hwclock the type of alpha you have (see hwclock(8))\n"
+		  "       tell hwclock the type of Alpha you have (see hwclock(8))\n"
 		  "\n"));
 #endif
 
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 0005-hwclock-in-man-page-move-date-and-epoch-from-Functio.patch --]
[-- Type: text/x-patch; name="0005-hwclock-in-man-page-move-date-and-epoch-from-Functio.patch", Size: 9537 bytes --]

From 8cbc1eec2557de210a51d992b79493134acf6ae8 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 13 Aug 2011 22:00:41 +0200
Subject: [PATCH 05/11] hwclock: in man page move --date and --epoch from Functions to Options

Also improve the synopsis and some wording and a bit of formatting,
add the --help option, and say that --show is the default function.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 hwclock/hwclock.8 |  118 +++++++++++++++++++++++++++++------------------------
 1 files changed, 65 insertions(+), 53 deletions(-)

diff --git a/hwclock/hwclock.8 b/hwclock/hwclock.8
index b693ae2..5134403 100644
--- a/hwclock/hwclock.8
+++ b/hwclock/hwclock.8
@@ -1,23 +1,23 @@
-.TH HWCLOCK 8 "06 August 2008"
+.TH HWCLOCK 8 "August 2011"
 .SH NAME
-hwclock \- query and set the hardware clock (RTC)
+hwclock \- query or set the hardware clock (RTC)
 .SH SYNOPSIS
 .B hwclock
-.RI [ functions ]
-.RI [ options ]
+.RI [ function ]
+.RI [ option ...]
 
 .SH DESCRIPTION
 .B hwclock
 is a tool for accessing the Hardware Clock.  You can display the
 current time, set the Hardware Clock to a specified time, set the
-Hardware Clock to the System Time, and set the System Time from the
+Hardware Clock from the System Time, or set the System Time from the
 Hardware Clock.
 .PP
 You can also run
 .B hwclock
-periodically to insert or remove time from the Hardware Clock to
-compensate for systematic drift (where the clock consistently gains or
-loses time at a certain rate if left to run).
+periodically to add or subtract time from the Hardware Clock to
+compensate for systematic drift (where the clock consistently loses or
+gains time at a certain rate when left to run).
 
 .SH FUNCTIONS
 You need exactly one of the following options to tell
@@ -26,11 +26,12 @@ what function to perform:
 .PP
 .TP
 .BR \-r , \ \-\-show
-Read the Hardware Clock and print the time on Standard Output.
+Read the Hardware Clock and print the time on standard output.
 The time shown is always in local time, even if you keep your Hardware Clock
 in Coordinated Universal Time.  See the
 .B \-\-utc
 option.
+Showing the Hardware Clock time is the default when no function is specified.
 
 .TP
 .B \-\-set
@@ -48,7 +49,7 @@ as
 .BR tzset (3)
 would interpret them.
 The obsolete tz_dsttime field of the kernel's timezone value is set
-to DST_NONE. (For details on what this field used to mean, see
+to DST_NONE.  (For details on what this field used to mean, see
 .BR settimeofday (2).)
 
 This is a good option to use in one of the system startup scripts.
@@ -66,7 +67,7 @@ as
 .BR tzset (3)
 would interpret them.
 The obsolete tz_dsttime field of the kernel's timezone value is set
-to DST_NONE. (For details on what this field used to mean, see
+to DST_NONE.  (For details on what this field used to mean, see
 .BR settimeofday (2).)
 
 This is an alternate option to
@@ -85,10 +86,12 @@ Print the kernel's Hardware Clock epoch value to standard output.
 This is the number of years into AD to which a zero year value in the
 Hardware Clock refers.  For example, if you are using the convention
 that the year counter in your Hardware Clock contains the number of
-full years since 1952, then the kernel's Hardware Counter epoch value
+full years since 1952, then the kernel's Hardware Clock epoch value
 must be 1952.
 
-This epoch value is used whenever hwclock reads or sets the Hardware Clock.
+This epoch value is used whenever
+.B hwclock
+reads or sets the Hardware Clock.
 .TP
 .B \-\-setepoch
 Set the kernel's Hardware Clock epoch value to the value specified by the
@@ -96,25 +99,44 @@ Set the kernel's Hardware Clock epoch value to the value specified by the
 option.  See the
 .B \-\-getepoch
 option for details.
+
+.TP
+.BI \-\-predict
+Predict what the RTC will read at time given by the
+.B \-\-date
+option based on the adjtime file. This is useful for example if you
+need to set an RTC wakeup time to distant future and want to account
+for the RTC drift.
 .TP
-.BR \-v , \ \-\-version
-Print the version of
+.BR \-h , \ \-\-help
+Display a help text and exit.
+.TP
+.BR \-V , \ \-\-version
+Display the version of
 .B hwclock
-on Standard Output.
+and exit.
+
+.SH OPTIONS
+.PP
+The first two options apply to just a few specific functions,
+the others apply to most functions.
 .TP
 .BI \-\-date= date_string
 You need this option if you specify the
 .B \-\-set
-option.  Otherwise, it is ignored.
-This specifies the time to which to set the Hardware Clock.
+or
+.B \-\-predict
+functions, otherwise it is ignored.
+It specifies the time to which to set the Hardware Clock, or the
+time for which to predict the Hardware Clock reading.
 The value of this option is an argument to the
 .BR date (1)
 program.
-For example,
+For example:
 .sp
-.I hwclock --set --date="9/22/96 16:45:05"
+.B "    hwclock" --set --date="2011-08-14 16:45:05"
 .sp
-The argument is in local time, even if you keep your Hardware Clock in
+The argument must be in local time, even if you keep your Hardware Clock in
 Coordinated Universal time.  See the
 .B \-\-utc
 option.
@@ -122,28 +144,17 @@ option.
 .TP
 .BI \-\-epoch= year
 Specifies the year which is the beginning of the Hardware Clock's
-epoch.  I.e. the number of years into AD to which a zero value in the
-Hardware Clock's year counter refers. It is used together with
-the \-\-setepoch option to set the kernel's idea of the epoch of the
+epoch, that is the number of years into AD to which a zero value in the
+Hardware Clock's year counter refers.  It is used together with
+the \fB\-\-setepoch\fR option to set the kernel's idea of the epoch of the
 Hardware Clock, or otherwise to specify the epoch for use with
 direct ISA access.
 
 For example, on a Digital Unix machine:
 .sp
-.I hwclock --setepoch --epoch=1952
+.B "    hwclock" --setepoch --epoch=1952
 
 .TP
-.BI \-\-predict
-Predict what the RTC will read at time given by the
-.B \-\-date
-option based on the adjtime file. This is useful for example if you
-need to set an RTC wakeup time to distant future and want to account
-for the RTC drift.
-
-.SH OPTIONS
-.PP
-The following options apply to most functions.
-.TP
 .BR \-u , \ \-\-utc
 .TP
 .B \-\-localtime
@@ -160,10 +171,12 @@ will be messed up.
 If you specify neither
 .B \-\-utc
 nor
-.B \-\-localtime
-, the default is whichever was specified the last time
+.BR \-\-localtime ,
+the default is whichever was specified the last time
 .B hwclock
-was used to set the clock (i.e. hwclock was successfully run with the
+was used to set the clock (i.e.
+.B hwclock
+was successfully run with the
 .BR \-\-set ,
 .BR \-\-systohc ,
 or
@@ -173,10 +186,10 @@ exist, the default is UTC time.
 
 .TP
 .B \-\-noadjfile
-disables the facilities provided by
+Disables the facilities provided by
 .IR /etc/adjtime .
 .B hwclock
-will not read nor write to that file with this option. Either
+will not read nor write to that file with this option.  Either
 .B \-\-utc
 or
 .B \-\-localtime
@@ -184,11 +197,11 @@ must be specified when using this option.
 
 .TP
 .BI \-\-adjfile= filename
-overrides the default /etc/adjtime.
+Overrides the default /etc/adjtime.
 
 .TP
 .BR \-f , \ \-\-rtc=\fIfilename\fB
-overrides the default /dev file name, which is
+Overrides the default /dev file name, which is
 .IR /dev/rtc
 on many platforms but may be
 .IR /dev/rtc0 ,
@@ -197,8 +210,8 @@ and so on.
 
 .TP
 .B \-\-directisa
-is meaningful only on an ISA machine or an Alpha (which implements enough
-of ISA to be, roughly speaking, an ISA machine for
+This option is meaningful only on an ISA machine or an Alpha (which implements
+enough of ISA to be, roughly speaking, an ISA machine for
 .BR hwclock 's
 purposes).  For other machines, it has no effect.  This option tells
 .B hwclock
@@ -206,10 +219,9 @@ to use explicit I/O instructions to access the Hardware Clock.
 Without this option,
 .B hwclock
 will try to use the /dev/rtc device (which it assumes to be driven by the
-rtc device driver).  If it is unable to open the device (for read), it will
+RTC device driver).  If it is unable to open the device (for reading), it will
 use the explicit I/O instructions anyway.
 
-The rtc device driver was new in Linux Release 2.
 .TP
 .B \-\-badyear
 Indicates that the Hardware Clock is incapable of storing years outside
@@ -231,9 +243,9 @@ knows it's working with a brain-damaged clock, it ignores the year part of
 the Hardware Clock value and instead tries to guess the year based on the
 last calibrated date in the adjtime file, by assuming that that date is
 within the past year.  For this to work, you had better do a
-.I hwclock \-\-set
+.B hwclock \-\-set
 or
-.I hwclock \-\-systohc
+.B hwclock \-\-systohc
 at least once a year!
 
 Though
@@ -278,14 +290,14 @@ is mounted.
 (If you find you need one of these options to make
 .B hwclock
 work, contact the maintainer to see if the program can be improved
-to detect your system automatically. Output of `hwclock --debug'
+to detect your system automatically.  Output of `hwclock --debug'
 and `cat /proc/cpuinfo' may be of interest.)
 
+Option
 .B \-\-jensen
-means you are running on a Jensen model.
-
+means you are running on a Jensen model.  And
 .B \-\-funky\-toy
-means that on your machine, one has to use the UF bit instead
+means that on your machine one has to use the UF bit instead
 of the UIP bit in the Hardware Clock to detect a time transition.  "Toy"
 in the option name refers to the Time Of Year facility of the machine.
 
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: 0006-po-do-not-search-samples-subdirectories-for-translat.patch --]
[-- Type: text/x-patch; name="0006-po-do-not-search-samples-subdirectories-for-translat.patch", Size: 867 bytes --]

From 62b1bfe5111d1c9b9d2f5eb0f6a752f900bc7eb6 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 15 Aug 2011 13:00:18 +0200
Subject: [PATCH 06/11] po: do not search /samples/ subdirectories for translatable strings

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 po/update-potfiles |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/po/update-potfiles b/po/update-potfiles
index 6cabe71..2a3ff58 100755
--- a/po/update-potfiles
+++ b/po/update-potfiles
@@ -5,6 +5,7 @@
 
 # find all *.c files, 
 # sort the list
+# exclude /samples/ subdirectories
 # exclude ./tests/ from the list 
 #         and remove "./" prefix
 
@@ -13,5 +14,6 @@
 
 find -name "*.c" | \
   sort | \
+  sed ':/samples/:d' | \
   gawk '! /^\.\/tests\// { print gensub(/^\.\//, "", 1) }' \
   > po/POTFILES.in
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: 0007-libmount-cut-up-mount-s-help-text-into-manageable-ch.patch --]
[-- Type: text/x-patch; name="0007-libmount-cut-up-mount-s-help-text-into-manageable-ch.patch", Size: 4213 bytes --]

From c36a17ce553478d73cfb3509bf3bc11b5cafaf20 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 15 Aug 2011 13:09:42 +0200
Subject: [PATCH 07/11] libmount: cut up mount's help text into manageable chunks

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 libmount/samples/mount.c |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/libmount/samples/mount.c b/libmount/samples/mount.c
index 30c2610..891c471 100644
--- a/libmount/samples/mount.c
+++ b/libmount/samples/mount.c
@@ -202,43 +202,50 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
 	fprintf(out, _(
 	"\nOptions:\n"
 	" -a, --all               mount all filesystems mentioned in fstab\n"
-	" -f, --fake              dry run, skip mount(2) syscall\n"
-	" -F, --fork              fork off for each device (use with -a)\n"
-	" -h, --help              this help\n"
-	" -n, --no-mtab           don't write to /etc/mtab\n"
-	" -r, --read-only         mount the filesystem read-only (same as -o ro)\n"
-	" -v, --verbose           verbose mode\n"
-	" -V, --version           print version string\n"
-	" -w, --read-write        mount the filesystem read-write (default)\n"
-	" -o, --options <list>    comma separated string of mount options\n"
-	" -O, --test-opts <list>  limit the set of filesystems (use with -a)\n"
-	" -t, --types <list>      indicate the filesystem type\n"
 	" -c, --no-canonicalize   don't canonicalize paths\n"
+	" -f, --fake              dry run; skip the mount(2) syscall\n"
+	" -F, --fork              fork off for each device (use with -a)\n"));
+	fprintf(out, _(
+	" -h, --help              display this help text and exit\n"
 	" -i, --internal-only     don't call the mount.<type> helpers\n"
 	" -l, --show-labels       lists all mounts with LABELs\n"
+	" -n, --no-mtab           don't write to /etc/mtab\n"));
+	fprintf(out, _(
+	" -o, --options <list>    comma-separated list of mount options\n"
+	" -O, --test-opts <list>  limit the set of filesystems (use with -a)\n"
+	" -r, --read-only         mount the filesystem read-only (same as -o ro)\n"
+	" -t, --types <list>      limit the set of filesystem types\n"));
+	fprintf(out, _(
+	" -v, --verbose           say what is being done\n"
+	" -V, --version           display version information and exit\n"
+	" -w, --read-write        mount the filesystem read-write (default)\n"));
 
+	fprintf(out, _(
 	"\nSource:\n"
 	" -L, --label <label>     synonym for LABEL=<label>\n"
 	" -U, --uuid <uuid>       synonym for UUID=<uuid>\n"
 	" LABEL=<label>           specifies device by filesystem label\n"
-	" UUID=<uuid>             specifies device by filesystem UUID\n"
+	" UUID=<uuid>             specifies device by filesystem UUID\n"));
+	fprintf(out, _(
 	" <device>                specifies device by path\n"
 	" <directory>             mountpoint for bind mounts (see --bind/rbind)\n"
-	" <file>                  regular file for loopdev setup\n"
+	" <file>                  regular file for loopdev setup\n"));
 
+	fprintf(out, _(
 	"\nOperations:\n"
 	" -B, --bind              mount a subtree somewhere else (same as -o bind)\n"
 	" -M, --move              move a subtree to some other place\n"
-	" -R, --rbind             mount a subtree and all submounts somewhere else\n"
+	" -R, --rbind             mount a subtree and all submounts somewhere else\n"));
+	fprintf(out, _(
 	" --make-shared           mark a subtree as shared\n"
 	" --make-slave            mark a subtree as slave\n"
 	" --make-private          mark a subtree as private\n"
-	" --make-unbindable       mark a subtree as unbindable\n"
+	" --make-unbindable       mark a subtree as unbindable\n"));
+	fprintf(out, _(
 	" --make-rshared          recursively mark a whole subtree as shared\n"
 	" --make-rslave           recursively mark a whole subtree as slave\n"
 	" --make-rprivate         recursively mark a whole subtree as private\n"
-	" --make-runbindable      recursively mark a whole subtree as unbindable\n"
-	));
+	" --make-runbindable      recursively mark a whole subtree as unbindable\n"));
 
 	fprintf(out, _("\nFor more information see mount(8).\n"));
 
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #9: 0008-findmnt-improve-spelling-wording-and-order-of-help-t.patch --]
[-- Type: text/x-patch; name="0008-findmnt-improve-spelling-wording-and-order-of-help-t.patch", Size: 3257 bytes --]

From 8030c398c77fbea8d25d8bfe61a4d8a7a47738ab Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 15 Aug 2011 13:36:50 +0200
Subject: [PATCH 08/11] findmnt: improve spelling, wording and order of help text

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 misc-utils/findmnt.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 7e6a8f5..e919a96 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -772,31 +772,31 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
 	"\nOptions:\n"
 	" -s, --fstab            search in static table of filesystems\n"
 	" -m, --mtab             search in table of mounted filesystems\n"
-	" -k, --kernel           search in kernel table of mounted \n"
-        "                        filesystems (default)\n\n"
+	" -k, --kernel           search in kernel table of mounted\n"
+        "                          filesystems (default)\n\n"
 
 	" -p, --poll[=<list>]    monitor changes in table of mounted filesystems\n"
-	" -w, --timeout <num>    upper limit in millisecods which --poll will block\n\n"
+	" -w, --timeout <num>    upper limit in milliseconds that --poll will block\n\n"
 
+	" -a, --ascii            use ASCII chars for tree formatting\n"
 	" -c, --canonicalize     canonicalize printed paths\n"
-	" -d, --direction <word> search direction - 'forward' or 'backward'\n"
-	" -e, --evaluate         print all TAGs (LABEL/UUID) evaluated\n"
+	" -d, --direction <word> direction of search, 'forward' or 'backward'\n"
+	" -e, --evaluate         convert tags (LABEL/UUID) to device names\n"
         " -f, --first-only       print the first found filesystem only\n"
-	" -h, --help             print this help\n"
-	" -i, --invert           invert sense of matching\n"
+	" -h, --help             display this help text and exit\n"
+	" -i, --invert           invert the sense of matching\n"
 	" -l, --list             use list format output\n"
-	" -n, --noheadings       don't print headings\n"
+	" -n, --noheadings       don't print column headings\n"
 	" -u, --notruncate       don't truncate text in columns\n"
 	" -O, --options <list>   limit the set of filesystems by mount options\n"
-	" -o, --output <list>    output columns\n"
+	" -o, --output <list>    the output columns to be shown\n"
 	" -P, --pairs            use key=\"value\" output format\n"
 	" -r, --raw              use raw output format\n"
-	" -a, --ascii            use ascii chars for tree formatting\n"
-	" -t, --types <list>     limit the set of filesystem by FS types\n"
+	" -t, --types <list>     limit the set of filesystems by FS types\n"
 	" -v, --nofsroot         don't print [/dir] for bind or btrfs mounts\n"
-	" -R, --submounts        print all submount for the matching filesystems\n"
-	" -S, --source <string>  device, LABEL= or UUID=device\n"
-	" -T, --target <string>  mountpoint\n\n"));
+	" -R, --submounts        print all submounts for the matching filesystems\n"
+	" -S, --source <string>  the device to mount (by name, LABEL= or UUID=)\n"
+	" -T, --target <string>  the mountpoint to use\n\n"));
 
 
 	fprintf(out, _("\nAvailable columns:\n"));
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #10: 0009-findmnt-slice-up-the-help-text-into-manageable-chunk.patch --]
[-- Type: text/x-patch; name="0009-findmnt-slice-up-the-help-text-into-manageable-chunk.patch", Size: 2704 bytes --]

From a24233277a30792a77b7a577bc7baa7753d63615 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 15 Aug 2011 13:39:33 +0200
Subject: [PATCH 09/11] findmnt: slice up the help text into manageable chunks

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 misc-utils/findmnt.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index e919a96..2c1b20c 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -773,26 +773,32 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
 	" -s, --fstab            search in static table of filesystems\n"
 	" -m, --mtab             search in table of mounted filesystems\n"
 	" -k, --kernel           search in kernel table of mounted\n"
-        "                          filesystems (default)\n\n"
+        "                          filesystems (default)\n\n"));
 
+	fprintf(out, _(
 	" -p, --poll[=<list>]    monitor changes in table of mounted filesystems\n"
-	" -w, --timeout <num>    upper limit in milliseconds that --poll will block\n\n"
+	" -w, --timeout <num>    upper limit in milliseconds that --poll will block\n\n"));
 
+	fprintf(out, _(
 	" -a, --ascii            use ASCII chars for tree formatting\n"
 	" -c, --canonicalize     canonicalize printed paths\n"
 	" -d, --direction <word> direction of search, 'forward' or 'backward'\n"
 	" -e, --evaluate         convert tags (LABEL/UUID) to device names\n"
-        " -f, --first-only       print the first found filesystem only\n"
+	" -f, --first-only       print the first found filesystem only\n"));
+
+	fprintf(out, _(
 	" -h, --help             display this help text and exit\n"
 	" -i, --invert           invert the sense of matching\n"
 	" -l, --list             use list format output\n"
 	" -n, --noheadings       don't print column headings\n"
-	" -u, --notruncate       don't truncate text in columns\n"
+	" -u, --notruncate       don't truncate text in columns\n"));
+	fprintf(out, _(
 	" -O, --options <list>   limit the set of filesystems by mount options\n"
 	" -o, --output <list>    the output columns to be shown\n"
 	" -P, --pairs            use key=\"value\" output format\n"
 	" -r, --raw              use raw output format\n"
-	" -t, --types <list>     limit the set of filesystems by FS types\n"
+	" -t, --types <list>     limit the set of filesystems by FS types\n"));
+	fprintf(out, _(
 	" -v, --nofsroot         don't print [/dir] for bind or btrfs mounts\n"
 	" -R, --submounts        print all submounts for the matching filesystems\n"
 	" -S, --source <string>  the device to mount (by name, LABEL= or UUID=)\n"
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #11: 0010-logger-improve-sort-and-slice-up-usage-help-text.patch --]
[-- Type: text/x-patch; name="0010-logger-improve-sort-and-slice-up-usage-help-text.patch", Size: 2188 bytes --]

From 729474d404a5dbb1c2f8f661bc4f29eb1aafbee4 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 15 Aug 2011 14:04:20 +0200
Subject: [PATCH 10/11] logger: improve, sort and slice up usage() help text

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 misc-utils/logger.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 5ecec76..5ad4ae8 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -137,22 +137,24 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
 {
 	fprintf(out,
 		_("\nUsage:\n"
-		  " %s [options] message\n"),
+		  "  %s [options] [message]\n"),
 		  program_invocation_short_name);
 
 	fprintf(out, _(
 		"\nOptions:\n"
-		" -i, --id            log process id\n"
-		" -s, --stderr        log message to standard error as well\n"
-		" -f, --file FILE     log contents of the specified file\n"
-		" -p, --priority PRI  enter message priority\n"
-		" -t, --tag TAG       mark every line with tag\n"
-		" -u, --socket SOCK   write to socket\n"
-		" -d, --udp           use udp (tcp is default)\n"
-		" -n, --server ADDR   write to remote syslog server\n"
-		" -P, --port          define port number\n"
-		" -V, --version       output version information and exit\n"
-		" -h, --help          display this help and exit\n\n"));
+		"  -d, --udp            use UDP (TCP is default)\n"
+		"  -i, --id             log the process ID too\n"
+		"  -f, --file FILE      log the contents of this file\n"
+		"  -h, --help           display this help text and exit\n"));
+	fprintf(out, _(
+		"  -n, --server NAME    write to this remote syslog server\n"
+		"  -P, --port NUMBER    use this UDP port\n"
+		"  -p, --priority PRIO  mark given message with this priority\n"
+		"  -s, --stderr         output message to standard error as well\n"));
+	fprintf(out, _(
+		"  -t, --tag TAG        mark every line with this tag\n"
+		"  -u, --socket SOCKET  write to this Unix socket\n"
+		"  -V, --version        output version information and exit\n\n"));
 
 	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
-- 
1.7.0.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #12: 0011-logger-improve-descriptions-on-man-page-sort-the-opt.patch --]
[-- Type: text/x-patch; name="0011-logger-improve-descriptions-on-man-page-sort-the-opt.patch", Size: 3961 bytes --]

From 64ef557cc7999cd0c61df8476e431b782135833b Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 15 Aug 2011 14:25:44 +0200
Subject: [PATCH 11/11] logger: improve descriptions on man page, sort the options, add -h and -V

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
---
 misc-utils/logger.1 |   71 ++++++++++++++++++++++++++-------------------------
 1 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/misc-utils/logger.1 b/misc-utils/logger.1
index 4312551..ea634e5 100644
--- a/misc-utils/logger.1
+++ b/misc-utils/logger.1
@@ -41,16 +41,16 @@
 .Nd a shell command interface to the syslog(3) system log module
 .Sh SYNOPSIS
 .Nm logger
-.Op Fl isd
+.Op Fl dhisV
 .Op Fl f Ar file
+.Op Fl n Ar server
+.Op Fl P Ar port
 .Op Fl p Ar pri
 .Op Fl t Ar tag
 .Op Fl u Ar socket
-.Op Fl n Ar server
-.Op Fl P Ar udpport
-.Op Ar message ...
+.Op Ar message
 .Sh DESCRIPTION
-.Nm Logger
+.Nm logger
 makes entries in the system log.
 It provides a shell command interface to the
 .Xr syslog  3
@@ -59,41 +59,42 @@ system log module.
 Options:
 .Pp
 .Bl -tag -width "message"
+.It Fl d, Fl Fl udp
+Use datagram (UDP) instead of the default stream connection (TCP).
 .It Fl i, Fl Fl id
-Log the process id of the logger process
-with each line.
-.It Fl s, Fl Fl stderr
-Log the message to standard error, as well as the system log.
+Log the process ID of the logger process with each line.
 .It Fl f, Fl Fl file Ar file
-Log contents of the specified file. This option cannot be
-combined with command line message.
-.It Fl p, Fl Fl priority Ar pri
-Enter the message with the specified priority.
-The priority may be specified numerically or as a ``facility.level''
+Log the contents of the specified \fIfile\fR.  This option cannot be
+combined with a command-line message.
+.It Fl h, Fl Fl help
+Display a help text and exit.
+.It Fl n, Fl Fl server Ar server
+Write to the specified remote syslog
+.Ar server
+using UDP instead of to the builtin syslog routines.
+.It Fl P, Fl Fl port Ar port
+Use the specified UDP
+.Ar port  .
+The default port number is 514.
+.It Fl p, Fl Fl priority Ar priority
+Enter the message into the log with the specified
+.Ar priority  .
+The priority may be specified numerically or as a \fIfacility.level\fR
 pair.
-For example, ``\-p local3.info'' logs the message(s) as
-.Ar info Ns rmational
-level in the
-.Ar local3
-facility.
-The default is ``user.notice.''
+For example, \fB-p local3.info\fR logs the message as
+informational in the local3 facility.
+The default is \fIuser.notice\fR.
+.It Fl s, Fl Fl stderr
+Output the message to standard error as well as to the system log.
 .It Fl t, Fl Fl tag Ar tag
-Mark every line in the log with the specified
+Mark every line to be logged with the specified
 .Ar tag  .
-.It Fl u, Fl Fl socket Ar sock
-Write to socket as specified with
+.It Fl u, Fl Fl socket Ar socket
+Write to the specified
 .Ar socket
-instead of builtin syslog routines.
-.It Fl d, Fl Fl udp
-Use a datagram instead of a stream connection to this socket.
-.It Fl n, Fl Fl server Ar serv
-Write to remote syslog server using UDP as specified with
-.Ar server
-instead of builtin syslog routines.
-.It Fl P, Fl Fl port Ar port
-Change UDP port to the value as specified with
-.Ar udpport  .
-Default port number is 514.
+instead of to the builtin syslog routines.
+.It Fl V, Fl Fl version
+Display version information and exit.
 .It --
 End the argument list. This is to allow the
 .Ar message
@@ -114,7 +115,7 @@ sensitive nature), cron, daemon, ftp, kern (can’t be generated from user
 process), lpr, mail, news, security (deprecated synonym for auth), syslog,
 user, uucp, and local0 to local7, inclusive.
 .Pp
-Valid level names are):
+Valid level names are:
 alert, crit, debug, emerg, err, error (deprecated synonym for err),
 info, notice, panic (deprecated synonym for emerg), warning,
 warn (deprecated synonym for warning).
-- 
1.7.0.4


^ permalink raw reply related

* Re: [patches] small fixes to some messages and man pages, and some questions
From: Benno Schulenberg @ 2011-08-15 18:34 UTC (permalink / raw)
  To: Karel Zak; +Cc: Util-Linux
In-Reply-To: <20110815133430.GG1843@nb.net.home>


> > Also I do not understand the descriptions of the new options --nested,
> > --chained, and --onesector.  [...]
> 
> The original comment from code: 
> 
> /* [...]
> NESTED: every partition is contained in the surrounding partitions
>    and is disjoint from all others.

I still fail to understand.  If "contained in the surrounding partitions"
means "contained in the containing partitions", it says nothing.  If it
means "contained in the partitions that come before and after", this
seems impossible to me.  The only way I can make sense of the
above comment is to read it as follows:

NESTED: every extended partition is contained within a surrounding
extended partition [except of course the outermost one] and is disjoint
from all other extended partitions at the same nesting level.

(Here I take "disjoint" to mean "does not overlap", but then I still fail
to understand how "mutually disjoint" is different.)

> CHAINED: every data partition is contained in the surrounding partitions
>    and disjoint from all others, but extended partitions may lie outside

Is a data partition the same as a logical partition?


> > However, I find this a bit misleading: the timingfile is only optional when
> > it is specified via the -t option.  Wouldn't it be better to describe the
> > command with two alternative synopses, as follows?
> > 
> >   Usage: scriptreplay timingfile [typescript [divisor]]
> >      or: scriptreplay [options] [timingfile] [typescript] [divisor]
> 
>    scriptreplay [options] [-t] timingfile [typescript [divisor]]

Yes, that would do.  It does not cover the possibilty of the typescript
file being passed with option -s and the divisor as a direct argument,
but it's good enough for my taste.

Regards,

Benno

-- 
http://www.fastmail.fm - Same, same, but different...

^ permalink raw reply

* [PATCH/RFC 2/2] chcpu: new tool
From: Heiko Carstens @ 2011-08-15 15:24 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux, Heiko Carstens
In-Reply-To: <20110815152453.052584040@de.ibm.com>

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

The chcpu lets a user configure CPUs. In this first version all that
is possible is to enable or disable CPUs (set them online of offline).
This is quite useful if you work a lot with virtual servers, since
enabling and disabling cpus via sysfs becomes tiring.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 sys-utils/.gitignore  |    1 +
 sys-utils/Makefile.am |    3 +
 sys-utils/chcpu.1     |   56 ++++++++++++
 sys-utils/chcpu.c     |  222 +++++++++++++++++++++++++++++++++++++++++++++++++
 sys-utils/lscpu.1     |    2 +
 5 files changed, 284 insertions(+), 0 deletions(-)
 create mode 100644 sys-utils/chcpu.1
 create mode 100644 sys-utils/chcpu.c

diff --git a/sys-utils/.gitignore b/sys-utils/.gitignore
index 3ae7e4a..febeb38 100644
--- a/sys-utils/.gitignore
+++ b/sys-utils/.gitignore
@@ -41,3 +41,4 @@ switch_root
 tunelp
 unshare
 x86_64.8
+chcpu
diff --git a/sys-utils/Makefile.am b/sys-utils/Makefile.am
index feb5888..da05dac 100644
--- a/sys-utils/Makefile.am
+++ b/sys-utils/Makefile.am
@@ -21,6 +21,9 @@ if HAVE_CPU_SET_T
 usrbin_exec_PROGRAMS += lscpu
 lscpu_SOURCES = lscpu.c $(top_srcdir)/lib/cpuset.c $(top_srcdir)/lib/strutils.c
 dist_man_MANS += lscpu.1
+sbin_PROGRAMS += chcpu
+chcpu_SOURCES = chcpu.c $(top_srcdir)/lib/cpuset.c
+dist_man_MANS += chcpu.1
 endif
 
 endif
diff --git a/sys-utils/chcpu.1 b/sys-utils/chcpu.1
new file mode 100644
index 0000000..0b9e98a
--- /dev/null
+++ b/sys-utils/chcpu.1
@@ -0,0 +1,56 @@
+.TH CHCPU 1 "August 2011" Linux "User Manuals"
+.SH NAME
+chcpu \- CPU configuration utility
+.SH SYNOPSIS
+.B chcpu
+.RB [ \-hvV ]
+.RB [ \-d
+.IR cpulist ]
+.RB [ \-e
+.IR cpulist ]
+.SH DESCRIPTION
+.B chcpu
+is used to configure CPUs. It can enable and disable CPUs by writing to the
+per CPU sysfs file attributes.
+Some options have a \fIcpu-list\fP argument. A \fIcpu-list\fP may specify
+multiple CPUs, separated by comma, and ranges.  For example,
+.BR 0,5,7,9-11 .
+.SH OPTIONS
+The --disable and --enable options are mutually exclusive.
+.TP
+.BR \-d , " \-\-disable " \fIcpu-list\fP
+disable all CPUs specified with \fIcpu-list\fP. If
+.BR chcpu
+fails to disable a CPU specified in the \fIcpu-list\fP it will skip that
+CPU and continue with the next one until all specified CPUs have been
+processed.
+.TP
+.BR \-e , " \-\-enable " \fIcpu-list\fP
+enable all CPUs specified with \fIcpu-list\fP. If
+.BR chcpu
+fails to enable a CPU specified in the \fIcpu-list\fP it will skip that
+CPU and continue with the next one until all specified CPUs have been
+processed.
+.TP
+.BR \-h , " \-\-help"
+Print a help text and exit.
+.TP
+.BR \-v , " \-\-verbose"
+Verbose execution. When specified
+.B chcpu
+will output the result of the configuration changes for each CPU.
+.TP
+.BR \-V , " \-\-version"
+Output version information and exit.
+.SH AUTHOR
+.nf
+Heiko Carstens <heiko.carstens@de.ibm.com>
+.fi
+.SH COPYRIGHT
+Copyright IBM Corp. 2011
+.br
+.SH "SEE ALSO"
+.BR lscpu (1)
+.SH AVAILABILITY
+The chcpu command is part of the util-linux package and is available from
+ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c
new file mode 100644
index 0000000..6e4392d
--- /dev/null
+++ b/sys-utils/chcpu.c
@@ -0,0 +1,222 @@
+/*
+ * chcpu - CPU configuration tool
+ *
+ * Copyright IBM Corp. 2011
+ * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "cpuset.h"
+#include "nls.h"
+#include "xalloc.h"
+#include "c.h"
+#include "strutils.h"
+#include "bitops.h"
+
+#define _PATH_SYS_CPU	"/sys/devices/system/cpu"
+
+static char pathbuf[PATH_MAX];
+static int verbose;
+
+enum {
+	CMD_CPU_ENABLE	= 0,
+	CMD_CPU_DISABLE,
+};
+
+static int path_open(mode_t mode, const char *path, ...)
+{
+	va_list ap;
+	int fd;
+
+	va_start(ap, path);
+	vsnprintf(pathbuf, sizeof(pathbuf), path, ap);
+	va_end(ap);
+	fd = open(pathbuf, mode);
+	if (fd == -1)
+		err(EXIT_FAILURE, "error: cannot open %s", pathbuf);
+	return fd;
+}
+
+static int path_exist(const char *path, ...)
+{
+	va_list ap;
+
+	va_start(ap, path);
+	vsnprintf(pathbuf, sizeof(pathbuf), path, ap);
+	va_end(ap);
+	return access(pathbuf, F_OK) == 0;
+}
+
+static void print_v(const char *str, ...)
+{
+	va_list ap;
+
+	if (!verbose)
+		return;
+	va_start(ap, str);
+	vprintf(str, ap);
+	va_end(ap);
+}
+
+static int cpu_enable(cpu_set_t *cpu_set, size_t setsize, int enable)
+{
+	unsigned int cpu;
+	int fd, rc;
+	char c;
+
+	for (cpu = 0; cpu < setsize; cpu++) {
+		if (!CPU_ISSET(cpu, cpu_set))
+			continue;
+		if (!path_exist(_PATH_SYS_CPU "/cpu%d", cpu)) {
+			print_v(_("CPU %d does not exist\n"), cpu);
+			continue;
+		}
+		if (!path_exist(_PATH_SYS_CPU "/cpu%d/online", cpu)) {
+			print_v(_("CPU %d is not hot pluggable\n"), cpu);
+			continue;
+		}
+		fd = path_open(O_RDWR, _PATH_SYS_CPU "/cpu%d/online", cpu);
+		if (read(fd, &c, 1) == -1)
+			err(EXIT_FAILURE, "error: cannot read from %s", pathbuf);
+		if ((c == '1') && (enable == 1)) {
+			print_v(_("CPU %d already enabled\n"), cpu);
+			continue;
+		}
+		if ((c == '0') && (enable == 0)) {
+			print_v(_("CPU %d already disabled\n"), cpu);
+			continue;
+		}
+		if (enable) {
+			rc = write(fd, "1", 1);
+			if (rc == -1)
+				print_v(_("CPU %d enable failed (%s)\n"), cpu,
+					strerror(errno));
+			else
+				print_v(_("CPU %d enabled\n"), cpu);
+		} else {
+			rc = write(fd, "0", 1);
+			if (rc == -1)
+				print_v(_("CPU %d disable failed (%s)\n"), cpu,
+					strerror(errno));
+			else
+				print_v(_("CPU %d disabled\n"), cpu);
+		}
+		close(fd);
+	}
+	return EXIT_SUCCESS;
+}
+
+static void __attribute__((__noreturn__)) usage(FILE *out)
+{
+	fprintf(out, _(
+		"\nUsage:\n"
+		" %s [options] [cpu-list]\n"), program_invocation_short_name);
+
+	puts(_(	"\nOptions:\n"
+		"  -h, --help         print this help\n"
+		"  -e, --enable       enable cpus\n"
+		"  -d, --disable      disable cpus\n"
+		"  -v, --verbose      explain what is being done\n"
+		"  -V, --version      output version information and exit\n"));
+
+	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+}
+
+int main(int argc, char *argv[])
+{
+	cpu_set_t *cpu_set;
+	unsigned int ncpus;
+	size_t setsize;
+	int cmd = -1;
+	int c;
+
+	static const struct option longopts[] = {
+		{ "disable",	required_argument, 0, 'd' },
+		{ "enable",	required_argument, 0, 'e' },
+		{ "help",	no_argument,       0, 'h' },
+		{ "verbose",	no_argument,       0, 'v' },
+		{ "version",	no_argument,       0, 'V' },
+		{ NULL,		0, 0, 0 }
+	};
+
+	setlocale(LC_ALL, "");
+	bindtextdomain(PACKAGE, LOCALEDIR);
+	textdomain(PACKAGE);
+
+	ncpus = get_max_number_of_cpus();
+	if (ncpus <= 0)
+		errx(EXIT_FAILURE, _("cannot determine NR_CPUS; aborting"));
+	setsize = CPU_ALLOC_SIZE(ncpus);
+	cpu_set = CPU_ALLOC(ncpus);
+	if (!cpu_set)
+		err(EXIT_FAILURE, _("cpuset_alloc failed"));
+
+	while ((c = getopt_long(argc, argv, "he:d:vV", longopts, NULL)) != -1) {
+		if (cmd != -1 && strchr("de", c))
+			errx(EXIT_FAILURE,
+			     _("disable and enable are mutually exclusive"));
+		switch (c) {
+		case 'h':
+			usage(stdout);
+		case 'e':
+			cmd = CMD_CPU_ENABLE;
+			if (cpulist_parse(argv[optind - 1], cpu_set, setsize, 1))
+				errx(EXIT_FAILURE, _("failed to parse CPU list: %s"),
+				     argv[optind -1 ]);
+			break;
+		case 'd':
+			cmd = CMD_CPU_DISABLE;
+			if (cpulist_parse(argv[optind - 1], cpu_set, setsize, 1))
+				errx(EXIT_FAILURE, _("failed to parse CPU list: %s"),
+				     argv[optind -1 ]);
+			break;
+		case 'v':
+			verbose = 1;
+			break;
+		case 'V':
+			printf(_("%s from %s\n"), program_invocation_short_name,
+			       PACKAGE_STRING);
+			return EXIT_SUCCESS;
+		default:
+			usage(stderr);
+		}
+	}
+
+	if ((argc == 1) || (argc != optind))
+		usage(stderr);
+
+	switch (cmd) {
+	case CMD_CPU_ENABLE:
+		return cpu_enable(cpu_set, ncpus, 1);
+	case CMD_CPU_DISABLE:
+		return cpu_enable(cpu_set, ncpus, 0);
+	}
+	return EXIT_SUCCESS;
+}
diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
index 4795e91..39246c9 100644
--- a/sys-utils/lscpu.1
+++ b/sys-utils/lscpu.1
@@ -56,6 +56,8 @@ Sometimes in Xen Dom0 the kernel reports wrong data.
 Cai Qian <qcai@redhat.com>
 Karel Zak <kzak@redhat.com>
 .fi
+.SH "SEE ALSO"
+.BR chcpu (1)
 .SH AVAILABILITY
 The lscpu command is part of the util-linux package and is available from
 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
-- 
1.7.5.4

^ permalink raw reply related

* [PATCH/RFC 1/2] cpuset: add option to allow cpulist_parse() to fail
From: Heiko Carstens @ 2011-08-15 15:24 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux, Heiko Carstens
In-Reply-To: <20110815152453.052584040@de.ibm.com>

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

This is a preparation patch for chcpu. If a cpu should be added to
a cpu_set where the cpu doesn't fit into the cpu_set this got silently
ignored.
Since the cpu-list is user space provided it should be checked if cpus
are specified that are completely out of range of the system.
In order to do that add a parameter which specifies if cpulist_parse()
should fail if it parses a cpu-list with "impossible" cpus.
The current callers have been converted so they behave like before.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
 include/cpuset.h     |    2 +-
 lib/cpuset.c         |    7 +++++--
 schedutils/taskset.c |    2 +-
 sys-utils/lscpu.c    |    2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/cpuset.h b/include/cpuset.h
index 9364660..f65c0ca 100644
--- a/include/cpuset.h
+++ b/include/cpuset.h
@@ -67,7 +67,7 @@ extern cpu_set_t *cpuset_alloc(int ncpus, size_t *setsize, size_t *nbits);
 extern void cpuset_free(cpu_set_t *set);
 
 extern char *cpulist_create(char *str, size_t len, cpu_set_t *set, size_t setsize);
-extern int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize);
+extern int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize, int fail);
 
 extern char *cpumask_create(char *str, size_t len, cpu_set_t *set, size_t setsize);
 extern int cpumask_parse(const char *str, cpu_set_t *set, size_t setsize);
diff --git a/lib/cpuset.c b/lib/cpuset.c
index 8aa296a..dd31f52 100644
--- a/lib/cpuset.c
+++ b/lib/cpuset.c
@@ -264,8 +264,9 @@ int cpumask_parse(const char *str, cpu_set_t *set, size_t setsize)
 /*
  * Parses string with CPUs mask.
  */
-int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize)
+int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize, int fail)
 {
+	size_t max = cpuset_nbits(setsize);
 	const char *p, *q;
 	q = str;
 
@@ -297,6 +298,8 @@ int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize)
 		if (!(a <= b))
 			return 1;
 		while (a <= b) {
+			if (fail && (a >= max))
+				return 1;
 			CPU_SET_S(a, setsize, set);
 			a += s;
 		}
@@ -359,7 +362,7 @@ int main(int argc, char *argv[])
 	if (mask)
 		rc = cpumask_parse(mask, set, setsize);
 	else
-		rc = cpulist_parse(range, set, setsize);
+		rc = cpulist_parse(range, set, setsize, 0);
 
 	if (rc)
 		errx(EXIT_FAILURE, "failed to parse string: %s", mask ? : range);
diff --git a/schedutils/taskset.c b/schedutils/taskset.c
index 1457c65..085675d 100644
--- a/schedutils/taskset.c
+++ b/schedutils/taskset.c
@@ -208,7 +208,7 @@ int main(int argc, char **argv)
 		ts.get_only = 1;
 
 	else if (ts.use_list) {
-		if (cpulist_parse(argv[optind], new_set, new_setsize))
+		if (cpulist_parse(argv[optind], new_set, new_setsize, 0))
 			errx(EXIT_FAILURE, _("failed to parse CPU list: %s"),
 			     argv[optind]);
 	} else if (cpumask_parse(argv[optind], new_set, new_setsize)) {
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 50daf3c..12779f1 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -304,7 +304,7 @@ path_cpuparse(int islist, const char *path, va_list ap)
 		err(EXIT_FAILURE, _("failed to callocate cpu set"));
 
 	if (islist) {
-		if (cpulist_parse(buf, set, setsize))
+		if (cpulist_parse(buf, set, setsize, 0))
 			errx(EXIT_FAILURE, _("failed to parse CPU list %s"), buf);
 	} else {
 		if (cpumask_parse(buf, set, setsize))
-- 
1.7.5.4

^ permalink raw reply related

* [PATCH/RFC 0/2] new chcpu tool
From: Heiko Carstens @ 2011-08-15 15:24 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux

This patch set introduces a new chcpu tool to util-linux. chcpu lets a user
configure CPUs. In this first version all that is possible is to enable or
disable CPUs (set them online of offline).
This is quite useful if you work a lot with virtual servers, since
enabling and disabling cpus manually via sysfs becomes tiring.

This first version is kept very simple so that I can easily change things
based on feedback/criticism before I add more functionality.
More features that I would like to add are

- rescan cpus: trigger the kernel to trigger a rescan of cpus. Necessary
  because not all hypervisors on s390 generate a guest event if a new
  cpu becomes visible to a guest.

- configure/deconfigure cpus: if cpus are offline the resources taken by
  the hypervisor can be freed if the cpus are deconfigured. Makes sense
  if a cpus are given dedicated to a logical partition. Deconfigured cpus
  can be given to other logical partitions.

- set dispatch mode: if the underlying hypervisor is PR/SM (LPAR hypervisor)
  it is possible to configure it's scheduling algorithm for the virtual cpus
  of the own logical partition.

Other architectures might add own features...

Any feedback and/or criticism would be welcome.

A usage example with a logical partition with 20 virtual cpus:

[root@r35lp37]# chcpu --help

Usage:
 chcpu [options] [cpu-list]

Options:
  -h, --help         print this help
  -e, --enable       enable cpus
  -d, --disable      disable cpus
  -v, --verbose      explain what is being done
  -V, --version      output version information and exit

[root@r35lp37]# cat /proc/cpuinfo
vendor_id       : IBM/S390
# processors    : 4
bogomips per cpu: 14367.00
features        : esan3 zarch stfle msa ldisp eimm dfp etf3eh highgprs 
processor 1: version = 00,  identification = 279F25,  machine = 2817
processor 10: version = 00,  identification = 279F25,  machine = 2817
processor 11: version = 00,  identification = 279F25,  machine = 2817
processor 12: version = 00,  identification = 279F25,  machine = 2817

[root@r35lp37]# ./chcpu -v -e 0-20
CPU 0 enabled
CPU 1 already enabled
CPU 2 enabled
CPU 3 enabled
CPU 4 enabled
CPU 5 enabled
CPU 6 enabled
CPU 7 enabled
CPU 8 enabled
CPU 9 enabled
CPU 10 already enabled
CPU 11 already enabled
CPU 12 already enabled
CPU 13 enabled
CPU 14 enabled
CPU 15 enabled
CPU 16 enabled
CPU 17 enabled
CPU 18 enabled
CPU 19 enabled
CPU 20 does not exist

[root@r35lp37]# cat /proc/cpuinfo 
vendor_id       : IBM/S390
# processors    : 20
bogomips per cpu: 14367.00
features        : esan3 zarch stfle msa ldisp eimm dfp etf3eh highgprs 
processor 0: version = 00,  identification = 279F25,  machine = 2817
processor 1: version = 00,  identification = 279F25,  machine = 2817
processor 2: version = 00,  identification = 279F25,  machine = 2817
processor 3: version = 00,  identification = 279F25,  machine = 2817
processor 4: version = 00,  identification = 279F25,  machine = 2817
processor 5: version = 00,  identification = 279F25,  machine = 2817
processor 6: version = 00,  identification = 279F25,  machine = 2817
processor 7: version = 00,  identification = 279F25,  machine = 2817
processor 8: version = 00,  identification = 279F25,  machine = 2817
processor 9: version = 00,  identification = 279F25,  machine = 2817
processor 10: version = 00,  identification = 279F25,  machine = 2817
processor 11: version = 00,  identification = 279F25,  machine = 2817
processor 12: version = 00,  identification = 279F25,  machine = 2817
processor 13: version = 00,  identification = 279F25,  machine = 2817
processor 14: version = 00,  identification = 279F25,  machine = 2817
processor 15: version = 00,  identification = 279F25,  machine = 2817
processor 16: version = 00,  identification = 279F25,  machine = 2817
processor 17: version = 00,  identification = 279F25,  machine = 2817
processor 18: version = 00,  identification = 279F25,  machine = 2817
processor 19: version = 00,  identification = 279F25,  machine = 2817

Thanks,
Heiko

^ permalink raw reply

* man-pages and usage() howto
From: Karel Zak @ 2011-08-15 14:19 UTC (permalink / raw)
  To: Benno Schulenberg, Sami Kerola; +Cc: util-linux


 Hi,

Sami is already working on some howtos, what we need is some
consensus about a way how describe options.

My suggestion:

 * argument required:

   -o, --option FILE    # usage()
   -o, --option file    # man page

 * optional argument:

   -o, --option[=FILE]  # usage()
   -o, --option[=file]  # man page


 * synopsis

   - without individual options, bad example:
   
        command [-o offset] [--sizelimit size] [-p pfd] [-r] file

   - [options] is better:

        command [options] file

   - use more synopsis lines if the command supports more separated modes.

       command --add file
       command --del file

     (use common sense! ... if there is too many modes, then use [options])

     The options specific to the mode are allowed in the synopsis or
     in the man page should be per-mode section with description about
     the options.


 * common options:

   -V, --version
   -h, --help

 * suggestions:

   -a, --all
   -o, --output <list>
   -r, --raw
   -f, --force
   -b, --bytes   (don't print SIZE in human readable format)


 * We also need any consensus about groff formatting, the ideal
   solution would be add any Documentation/example.man

    Karel

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

^ permalink raw reply

* Re: [patches] small fixes to some messages and man pages, and some questions
From: Karel Zak @ 2011-08-15 13:56 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Util-Linux
In-Reply-To: <1313094127.6807.140258128661629@webmail.messagingengine.com>

On Thu, Aug 11, 2011 at 10:22:07PM +0200, Benno Schulenberg wrote:
> Attached bunch of patches improve or correct several error messages
> or usage synopses.

 All applied, but except patches 0015,0016 (the scriptreplay changes)
 -- I'll wait for your feedback about this issue.

    Karel

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

^ permalink raw reply

* Re: [patches] small fixes to some messages and man pages, and some questions
From: Karel Zak @ 2011-08-15 13:34 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Util-Linux
In-Reply-To: <1313094127.6807.140258128661629@webmail.messagingengine.com>

> About the fourth patch I'm unsure.  The current description of the option
> '--no-reread' is "skip partition re-read at boot".  With "boot" is meant
> "program startup", so that needs to be corrected.  But the real effect of
> --no-reread seems to be to just check that the relevant partition is not
> in use.  Is that correct?

 Yes.

> By the way, I don't understand why the options -g (--show-geometry) and
> -G (show-pt-geometry) are listed under "Dangerous options".  How can
> they be dangerous when they just show things?

 Hmm.. not sure.

> Also I do not understand the descriptions of the new options --nested,
> --chained, and --onesector.  How is "disjoint" different from "mutually
> disjoint"?  Would the following attempts at description be correct?
>
> --nested     each logical and extended partition falls within an extended one
> --chained     each logical partition falls within an extended one
> --onesector   not any partition falls within another

The original comment from code:

/* There are two common ways to structure extended partitions:
   as nested boxes, and as a chain. Sometimes the partitions
   must be given in order. Sometimes all logical partitions
   must lie inside the outermost extended partition.
NESTED: every partition is contained in the surrounding partitions
   and is disjoint from all others.
CHAINED: every data partition is contained in the surrounding partitions
   and disjoint from all others, but extended partitions may lie outside
   (insofar as allowed by all_logicals_inside_outermost_extended).
ONESECTOR: all data partitions are mutually disjoint; extended partitions
   each use one sector only (except perhaps for the outermost one).
*/

The default is NESTED and "inside the outermost extended partition".

> The fourteenth patch adds the missing "[options]" to the usage synopsis
> of scriptreplay, and also indicates the timingfile argument as optional.
> However, I find this a bit misleading: the timingfile is only optional when
> it is specified via the -t option.  Wouldn't it be better to describe the
> command with two alternative synopses, as follows?
> 
>   Usage: scriptreplay timingfile [typescript [divisor]]
>      or: scriptreplay [options] [timingfile] [typescript] [divisor]

   scriptreplay [options] [-t] timingfile [typescript [divisor]]

 ?

    Karel

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

^ permalink raw reply

* Re: [PATCH] partx: do not print null
From: Karel Zak @ 2011-08-15 12:36 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux
In-Reply-To: <1313177911.3305.10.camel@offbook>

On Fri, Aug 12, 2011 at 03:38:31PM -0400, Davidlohr Bueso wrote:
>  partx/partx.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

 Applied, thanks. 

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

^ permalink raw reply

* Re: [PATCH] grammar fixes
From: Karel Zak @ 2011-08-15 12:36 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux
In-Reply-To: <1313172465.3305.4.camel@offbook>

On Fri, Aug 12, 2011 at 02:07:45PM -0400, Davidlohr Bueso wrote:
>  libmount/src/context_umount.c  |    4 ++--
>  tests/ts/hwclock/systohc       |    2 +-
>  tests/ts/libmount/context      |   10 +++++-----
>  tests/ts/libmount/context-utab |    8 ++++----
>  tests/ts/mount/devname         |    6 +++---
>  5 files changed, 15 insertions(+), 15 deletions(-)

 Applied, thanks.

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

^ 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