Util-Linux package development
 help / color / mirror / Atom feed
* example in flock manpage still not useful.
From: Pierre Gaston @ 2011-08-25 12:26 UTC (permalink / raw)
  To: util-linux

I can see why the following change has been made but, as it is, it
doesn't work at all

http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commitdiff;h=c348d9346ae60b78a03d6dcd964e23fb40a625df

(
   flock -n 9
   # ... commands executed under lock ...

) 9>/var/lock/mylockfile\fP

flock -n 9 does nothing here besides testing the lock.

I suggest to revert to flock -s 9...or rather to just flock 9, since a
shared lock doesn't indeed seems very useful either here.

The example can be fixed using {   ;} instead of a subshell and adding
flock -n 9 || exit 1, but I think it doesn't match
the intention of the committer which was to show a way to avoid 2
concurrent executions of a script.

If  you want an example exiting the script, I suggest adding an example like:

exec 9>/var/lock/mylockfile  # open the file descriptor for the
duration of the script
flock -n 9 || exit 1                 # exit if the lock can't be acquire.

Pierre

^ permalink raw reply

* Re: [PATCH] Documentation: add debugging doc
From: Davidlohr Bueso @ 2011-08-23 21:46 UTC (permalink / raw)
  To: kerolasa; +Cc: Karel Zak, util-linux
In-Reply-To: <CAG27Bk16rT3vJYy0N=fYaBFd6RX1HvoD5_TbO5uLhby+=bnBWg@mail.gmail.com>

On Tue, 2011-08-23 at 21:41 +0200, Sami Kerola wrote:
> On Tue, Aug 23, 2011 at 12:47, Karel Zak <kzak@redhat.com> wrote:
> >  Semi, could you add howto-debug to your docs branch?
> 
> I could. I also modestly edit the patch; see addition in commit
> message what I did & how the file looks in general.

Changes look good, thanks. BTW I had no idea I had a github account :)

> 
> https://github.com/kerolasa/lelux-utiliteetit/commit/1b1ea43afb0c0d6c3bf386e85e03c03b975194a5
> 

^ permalink raw reply

* Re: [PATCH] Documentation: add debugging doc
From: Sami Kerola @ 2011-08-23 19:41 UTC (permalink / raw)
  To: Karel Zak; +Cc: Davidlohr Bueso, util-linux
In-Reply-To: <20110823104732.GE20457@nb.net.home>

On Tue, Aug 23, 2011 at 12:47, Karel Zak <kzak@redhat.com> wrote:
> =A0Semi, could you add howto-debug to your docs branch?

I could. I also modestly edit the patch; see addition in commit
message what I did & how the file looks in general.

https://github.com/kerolasa/lelux-utiliteetit/commit/1b1ea43afb0c0d6c3bf386=
e85e03c03b975194a5

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

^ permalink raw reply

* Re: man-pages and usage() howto
From: Sami Kerola @ 2011-08-23 19:34 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Karel Zak, util-linux
In-Reply-To: <1314125747.31287.140258132893109@webmail.messagingengine.com>

On Tue, Aug 23, 2011 at 20:55, Benno Schulenberg <bensberg@justemail.net> w=
rote:
> On Tue, 23 Aug 2011 10:15 +0200, "Sami Kerola" <kerolasa@iki.fi> wrote:
>> On Mon, Aug 22, 2011 at 22:38, Benno Schulenberg <bensberg@justemail.net=
> wrote:
>> > (I do not understand your comment about some macros not being
>> > visually different from plain .B or .I.)
>>
>> Either my term, groff or pager is/are broken, or I have wooden eyes or
>> the different highlights do not stand out, see yourself:
>>
>> http://ut3.org/~kerolasa/groff-highlight.png
>>
>> What I tried to say; Do not get fooled that different macros will look
>> different so that you can refer visually in between different text
>> elements.
>
> Hmm, maybe you misunderstand what for example the .BI macro does?
> It does not mean "bold _plus_ italic" but "alternate bold and italic". =
=A0And it
> does that perfectly. =A0See for example the attached example file.

Indeed I have. Thank you clarifying that, and as obvious the strange
(wrong) instruction in howto-man-page.txt is gone.

>> > Another thing: the man page formatter itself puts a double space after=
 a
>> > period when in the man page source the next sentence begins on a new
>> > line. =A0So when in the source a new sentence begins somewhere midline=
,
>> > it should use a double space before its initial letter.
>>
>> Are you sure it does that?
>
> Yes, it does that here, on Ubuntu Lucid 10.10, with man 2.5.7.
>
>> See the screenshot notes section third
>> paragraph line two, words `macros. See' has only single space in
>> between them.
>
> Yes, but in the source it says "appropriate groff macros. See" on a singl=
e
> line. =A0When you put the "See" on a line by itself, you wil see two spac=
es
> appear before it. =A0See the attached example file.

I'm quite near to say groff is a stupid program. Well, it seems that
the instructions should indeed tell to use french spacing e.g. two
spaces after a dot. After all it would be even more ridiculous to ask
people to use dot only at middle of line so that groff will never add
two spaces.

>> Even there would be two spaces I do not agree that groff
>> input writer should imitate output. It should be enough that words and
>> sentences are white space separated, groff will take care the rest.
>
> Well, being a doublespacer myself, I notice it when some sentences are
> single-spaced and others double; it irks. =A0But never mind.

Quite the opposite, I did not know I where talking. Thanks again
pointing out how wrong I where.

p.s. The usage() option thing is fixed as well.

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

^ permalink raw reply

* Re: man-pages and usage() howto
From: Benno Schulenberg @ 2011-08-23 18:55 UTC (permalink / raw)
  To: kerolasa; +Cc: Karel Zak, util-linux
In-Reply-To: <CAG27Bk2NS7-tRH4Acp-_WFhAmxELm4cCZ79mwgbXWnDJ7gFAfw@mail.gmail.com>

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


On Tue, 23 Aug 2011 10:15 +0200, "Sami Kerola" <kerolasa@iki.fi> wrote:
> On Mon, Aug 22, 2011 at 22:38, Benno Schulenberg <bensberg@justemail.net> wrote:
> > (I do not understand your comment about some macros not being
> > visually different from plain .B or .I.)
> 
> Either my term, groff or pager is/are broken, or I have wooden eyes or
> the different highlights do not stand out, see yourself:
> 
> http://ut3.org/~kerolasa/groff-highlight.png
> 
> What I tried to say; Do not get fooled that different macros will look
> different so that you can refer visually in between different text
> elements.

Hmm, maybe you misunderstand what for example the .BI macro does?
It does not mean "bold _plus_ italic" but "alternate bold and italic".  And it
does that perfectly.  See for example the attached example file.

> > Another thing: the man page formatter itself puts a double space after a
> > period when in the man page source the next sentence begins on a new
> > line.  So when in the source a new sentence begins somewhere midline,
> > it should use a double space before its initial letter.
> 
> Are you sure it does that?

Yes, it does that here, on Ubuntu Lucid 10.10, with man 2.5.7.

> See the screenshot notes section third
> paragraph line two, words `macros. See' has only single space in
> between them.

Yes, but in the source it says "appropriate groff macros. See" on a single
line.  When you put the "See" on a line by itself, you wil see two spaces
appear before it.  See the attached example file.

> Even there would be two spaces I do not agree that groff
> input writer should imitate output. It should be enough that words and
> sentences are white space separated, groff will take care the rest.

Well, being a doublespacer myself, I notice it when some sentences are
single-spaced and others double; it irks.  But never mind.

Regards,

Benno

-- 
http://www.fastmail.fm - A fast, anti-spam email service.


[-- Attachment #2: junk.1 --]
[-- Type: application/octet-stream, Size: 549 bytes --]

.TH JUNK 1 "Today" "Example" "Spaciousness"
.SH NAME
junk \- do nothing
.SH DESCRIPTION
.B junk
does nothing.
Just show.
That.
After.
.PP
Each period.
Plus newline.
Follow two spaces.
.SH FORMATTING
.PP
.BR \.BR\  alternate\  bold\  and\  normal\  and\  so\  on\  and\  so\  on
.PP
.BI \.BI\  alternate\  bold\  and\  italic
.PP
.IB \.IB\  alternate\  italic\  and\  bold
.PP
.IR \.IR\  alternate\  italic\  and\  normal
.PP
.RB \.RB\  alternate\  normal\  and\  bold
.PP
.RI \.RI\  alternate\  normal\  and\  italic\  and\  so\  on\  and\  so\  on

^ permalink raw reply

* Re: [PATCH] Documentation: add debugging doc
From: Karel Zak @ 2011-08-23 10:47 UTC (permalink / raw)
  To: Davidlohr Bueso, Sami Kerola; +Cc: util-linux
In-Reply-To: <1312678772.3408.3.camel@offbook>


 Semi, could you add howto-debug to your docs branch?

    Karel

On Sat, Aug 06, 2011 at 08:59:32PM -0400, Davidlohr Bueso wrote:
> From: Davidlohr Bueso <dave@gnu.org>
> 
> Layout the base for tips on debugging util-linux programs/wrappers.
> 
> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
> ---
>  Documentation/README.debug |   30 ++++++++++++++++++++++++++++++
>  1 files changed, 30 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/README.debug
> 
> diff --git a/Documentation/README.debug b/Documentation/README.debug
> new file mode 100644
> index 0000000..7ead12f
> --- /dev/null
> +++ b/Documentation/README.debug
> @@ -0,0 +1,30 @@
> +Debugging util-linux programs
> +-----------------------------
> +
> +There are considerations to be made when profiling or debugging some programs found
> +in the util-linux package. Because wrapper scripts are used for the binaries to make
> +sure all library dependencies are met, you cannot use tools such as gdb or valgrind
> +directly with them.
> +
> +Let's take for example the mount command:
> +
> +$> file /path/util-linux/mount/mount
> +mount: Bourne-Again shell script text executable
> +
> +The binary itself is located in the .libs/ dir:
> +
> +$> file /path/util-linux/mount/.libs/mount
> +mount: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
> +
> +When this command is run, there's a library dependency error:
> +./mount: /lib/x86_64-linux-gnu/libblkid.so.1: version `BLKID_2.20' not found (required by ./mount)
> +
> +To overcome this we need set the LD_LIBRARY_PATH variable to read the path of the shared lib found in
> +the sources, and not system-wide:
> +
> +$> export LD_LIBRARY_PATH=/path/util-linux/libblkid/src/.libs/:$LD_LIBRARY_PATH
> +
> +Now external debugging tools can be run on the binary.
> +
> +Happy hacking!
> +Davidlohr Bueso, August 2011
> -- 
> 1.7.4.1
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

^ permalink raw reply

* Re: [PATCH] lomount: correct qsort compare function
From: Karel Zak @ 2011-08-23 10:22 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: util-linux
In-Reply-To: <m2obzhywq0.fsf@igel.home>

On Mon, Aug 22, 2011 at 11:15:03PM +0200, Andreas Schwab wrote:
> ---
>  mount/lomount.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

 Very good catch! Applied, thanks.

    Karel

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

^ permalink raw reply

* Re: [PATCH] sfdisk: make some tests conditional to !Linux
From: Karel Zak @ 2011-08-23 10:21 UTC (permalink / raw)
  To: giulioo; +Cc: util-linux
In-Reply-To: <20110818073019.B70AFF815@i3.golden.dom>

On Thu, Aug 18, 2011 at 09:30:30AM +0200, Giulio wrote:
> --- a/fdisk/sfdisk.c	2011-08-17 17:17:43.000000000 +0200
> +++ b/fdisk/sfdisk.c	2011-08-17 22:48:52.000000000 +0200

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

^ permalink raw reply

* Re: [PATCH] new chcpu tool
From: Heiko Carstens @ 2011-08-23  8:45 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110822132817.GD20457@nb.net.home>

On Mon, Aug 22, 2011 at 03:28:17PM +0200, Karel Zak wrote:
> On Mon, Aug 22, 2011 at 02:06:41PM +0200, Heiko Carstens wrote:
> > Do you think it would be ok to have it in util-linux? Or should it live
> > somewhere else?
> 
> It makes sense to have it in util-linux. I'm going to merge it after
> v2.20 release.

Ok, great!

I set up a chcpu git branch where you could pull the chcpu stuff easily:

  git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux.git chcpu

It contains just the two patches posted here and doesn't interfer with the
lscpu branch that is also there.

Heiko Carstens (2):
      cpuset: add option to allow cpulist_parse() to fail
      chcpu: new tool

 include/cpuset.h      |    2 +-
 lib/cpuset.c          |    7 +-
 schedutils/taskset.c  |    2 +-
 sys-utils/.gitignore  |    1 +
 sys-utils/Makefile.am |    3 +
 sys-utils/chcpu.1     |   94 ++++++++++++++
 sys-utils/chcpu.c     |  337 +++++++++++++++++++++++++++++++++++++++++++++++++
 sys-utils/lscpu.1     |    2 +
 sys-utils/lscpu.c     |    2 +-
 9 files changed, 445 insertions(+), 5 deletions(-)
 create mode 100644 sys-utils/chcpu.1
 create mode 100644 sys-utils/chcpu.c

> > +static int path_exist(const char *path, ...)
> 
>  It seems that we need to move the path_*() functions from lscpu(1) to
>  lib/ and hare the stuff.

Yes, I thought so as well. But laziness won ;)

Thanks,
Heiko

^ permalink raw reply

* Re: man-pages and usage() howto
From: Sami Kerola @ 2011-08-23  8:15 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Karel Zak, util-linux
In-Reply-To: <1314045499.25233.140258132498281@webmail.messagingengine.com>

On Mon, Aug 22, 2011 at 22:38, Benno Schulenberg <bensberg@justemail.net> w=
rote:
> On Sat, 20 Aug 2011 21:08 +0200, "Sami Kerola" <kerolasa@iki.fi> wrote:
>> To me it does not sound a big deal if --help and --version
>> description begins from different indent than rest of lines. I
>> wrote example output that way, so that you can judge how that
>> will look.
>
> When --help and --version are always the last two options of the
> usage help text, a differing indentation is acceptable. =A0But if --help
> is ordered alphabetically, it will look broken.

True, and that's why I wrote they should be last entries.

>> \fB\-o\fR, \fB\-\-optional\fR[=3D<\fIarg\fR>]
>> This option uses optional argument.
>
> As Karel said, the majority convention now is to not use pointy brackets
> for arguments in man pages. =A0The italics/underlining is enough to make
> them stand out.

I guess you did not read from git the section.

.SH OPTIONS
.TP
\fB\-n\fR, \fB\-\-no\-argument\fR
This option does not use argument.
.TP
\fB\-o\fR, \fB\-\-optional\fR [\fIarg\fR]
Tell in description an
.I arg
is optional, and what happens when is or is not given.
.TP
\fB\-r\fR, \fB\-\-required\fR \fIarg\fR
Tell in description option
.I arg
is required.

As you can see no diamond brackets there.

> I would also suggest to not use "arg" but the full word "argument", so as
> to encourage writers to not unnecessarily abbreviate the argument name,
> to use for example "seconds" and not "secs", use "number" and not "num".

Good point. I will fix that when I'm at home again.

> A thing about the formatting: why us \fB and \fR and \fB and \fR?
> Why not use the macro .BR at the start of the line instead?

No matter how I tried to use various .B, .BR

> (I do not understand your comment about some macros not being
> visually different from plain .B or .I.)

Either my term, groff or pager is/are broken, or I have wooden eyes or
the different highlights do not stand out, see yourself:

http://ut3.org/~kerolasa/groff-highlight.png

What I tried to say; Do not get fooled that different macros will look
different so that you can refer visually in between different text
elements. For example in the screen shot on top the required argument
has same appearance when it is next to switch & in text. I think that
sort of consistency in style makes things more understandable.

> Another thing: the man page formatter itself puts a double space after a
> period when in the man page source the next sentence begins on a new
> line. =A0So when in the source a new sentence begins somewhere midline,
> it should use a double space before its initial letter.

Are you sure it does that? See the screenshot notes section third
paragraph line two, words `macros. See' has only single space in
between them. Even there would be two spaces I do not agree that groff
input writer should imitate output. It should be enough that words and
sentences are white space separated, groff will take care the rest.

> From your usage howto:
>> =A0-n, --no-argument option requires no_argument
>> =A0-o, --optional[=3D<arg>] option has optional_argument
>> =A0-r, --required <arg> option requires required_argument
>
> Why the underscores? =A0I would suggest the following:
>
> =A0-n, --no-argument =A0 =A0 =A0 option takes no argument
> =A0-o, --optional[=3D<arg>] =A0option takes optional argument
> =A0-r, --required <arg> =A0 =A0option requires an argument
>
> (As in a usage text space is limited, abbreviations are okay.)

The weird underscores are used in option structure. Now when you
mention that I think having such unexplained reference is not good.
I'll write the description using ordinary text.

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

^ permalink raw reply

* [PATCH] lomount: correct qsort compare function
From: Andreas Schwab @ 2011-08-22 21:15 UTC (permalink / raw)
  To: util-linux

Return the correct value from comparing the operands.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
---
 mount/lomount.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mount/lomount.c b/mount/lomount.c
index 34d151a..fad58d5 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -285,7 +285,7 @@ name2minor(int hasprefix, const char *name)
 static int
 cmpnum(const void *p1, const void *p2)
 {
-	return (* (int *) p1) > (* (int *) p2);
+	return (*(int *) p1 > *(int *) p2) - (*(int *) p1 < *(int *) p2);
 }
 
 /*
-- 
1.7.6


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply related

* Re: man-pages and usage() howto
From: Benno Schulenberg @ 2011-08-22 20:38 UTC (permalink / raw)
  To: kerolasa; +Cc: Karel Zak, util-linux
In-Reply-To: <CAG27Bk0m45JFtP2MNz27tgJ=-f5XZDHUtd1C9O4X0ALO52-BVA@mail.gmail.com>


On Sat, 20 Aug 2011 21:08 +0200, "Sami Kerola" <kerolasa@iki.fi> wrote:
> On Sat, Aug 20, 2011 at 11:10, Benno Schulenberg <bensberg@justemail.net> wrote:
> > On Wed, 17 Aug 2011 15:07 +0200, "Sami Kerola" <kerolasa@iki.fi> wrote:
> >> Having also definition for OPTION_HELP && OPTION_VERSION would be
> >> good.
> >
> > That won't work -- the amount of indentation for the option description
> > is not the same for all utilities.  And to make it the same for all would
> > create ugly and unneeded wide open text spaces for some tools.
> 
> To me it does not sound a big deal if --help and --version
> description begins from different indent than rest of lines. I
> wrote example output that way, so that you can judge how that
> will look.

When --help and --version are always the last two options of the
usage help text, a differing indentation is acceptable.  But if --help
is ordered alphabetically, it will look broken.

> \fB\-o\fR, \fB\-\-optional\fR[=<\fIarg\fR>]
> This option uses optional argument.

As Karel said, the majority convention now is to not use pointy brackets
for arguments in man pages.  The italics/underlining is enough to make
them stand out.

I would also suggest to not use "arg" but the full word "argument", so as
to encourage writers to not unnecessarily abbreviate the argument name,
to use for example "seconds" and not "secs", use "number" and not "num".

A thing about the formatting: why us \fB and \fR and \fB and \fR?
Why not use the macro .BR at the start of the line instead?
(I do not understand your comment about some macros not being
visually different from plain .B or .I.)

Another thing: the man page formatter itself puts a double space after a
period when in the man page source the next sentence begins on a new
line.  So when in the source a new sentence begins somewhere midline,
it should use a double space before its initial letter.

>From your usage howto:
>  -n, --no-argument option requires no_argument
>  -o, --optional[=<arg>] option has optional_argument
>  -r, --required <arg> option requires required_argument

Why the underscores?  I would suggest the following:

  -n, --no-argument       option takes no argument
  -o, --optional[=<arg>]  option takes optional argument
  -r, --required <arg>    option requires an argument

(As in a usage text space is limited, abbreviations are okay.)

Regards,

Benno

-- 
http://www.fastmail.fm - Access your email from home and the web

^ permalink raw reply

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

On Mon, Aug 22, 2011 at 10:16, Karel Zak <kzak@redhat.com> wrote:
>> IMHO the following looks quite ok, and not too different to
>> usage().
>>
>> .TP
>> \fB\-n\fR, \fB\-\-no\-argument\fR
>> This option does not use argument.
>> .TP
>> \fB\-o\fR, \fB\-\-optional\fR[=3D<\fIarg\fR>]
>> This option uses optional argument.
>> .TP
>> \fB\-r\fR, \fB\-\-required\fR <\fIarg\fR>
>> This option requires an argument.
>
> =A0I have no strong opinion about it. Benno is probably right that
> =A0italics for the arguments is enough.
>
> =A0We already use option arguments without diamond brackets in our man
> =A0pages, so let's continue with this convention to minimize number of
> =A0changes in the man pages ;-)

The howto-man-page.txt now has arguments underlined without diamond
brackets. Optional argument has square brackets surrounding it.

Is the patch set ready now? Have a look, and in absence of comments
merge might be reasonable thing to do after few days.

https://github.com/kerolasa/lelux-utiliteetit/tree/docs-dir/Documentation

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

^ permalink raw reply

* Re: [PATCH] sfdisk: make some tests conditional to !Linux
From: Giulio Orsero @ 2011-08-22 18:46 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110822083206.GA20457@nb.net.home>

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

This patch makes the following tests/actions conditional to "!Linux":

- Force cylinders as format instead of MB, even if user asked for MB.
This solves a bug where if you use "-L -uM", set 1 as starting MB and the
disk is larger than a certain size (about 1GB) the partition would start at
sector 1 instead of 1MB due to cyl rounding.

- Warn about partitions not starting/ending on cyl boundaries.

- Check if CHS is ok.

I used the "!Linux" notation since it was already used elsewhere in the
code.

Sorry, I don't use git, hope this is ok.

Signed-off-by: Giulio Orsero <giulioo@pobox.com>
-- 
giulioo@pobox.com

[-- Attachment #2: sfdisk.linux-compat2.diff --]
[-- Type: application/octet-stream, Size: 1943 bytes --]

--- a/fdisk/sfdisk.c	2011-08-17 17:17:43.000000000 +0200
+++ b/fdisk/sfdisk.c	2011-08-22 14:59:26.000000000 +0200
@@ -1315,7 +1315,7 @@ partitions_ok(struct disk_desc *z) {
      * The first partition starts after MBR.
      * Logical partitions start slightly after the containing extended partn.
      */
-    if (B.cylindersize) {
+    if (B.cylindersize && !Linux) {
 	for (p = partitions; p < partitions + partno; p++)
 	    if (p->size) {
 		if (p->start % B.cylindersize != 0
@@ -1325,14 +1325,12 @@ partitions_ok(struct disk_desc *z) {
 		    && (p->p.start_sect >= B.cylindersize)) {
 		    my_warn(_("Warning: partition %s does not start "
 			      "at a cylinder boundary\n"), PNO(p));
-		    if (!Linux)
-			return 0;
+		    return 0;
 		}
 		if ((p->start + p->size) % B.cylindersize) {
 		    my_warn(_("Warning: partition %s does not end "
 			      "at a cylinder boundary\n"), PNO(p));
-		    if (!Linux)
-			return 0;
+		    return 0;
 		}
 	    }
     }
@@ -1378,7 +1376,7 @@ partitions_ok(struct disk_desc *z) {
 	    b = p->p.begin_chs;
 	    aa = chs_to_longchs(a);
 	    bb = chs_to_longchs(b);
-	    if (!chs_ok(b, PNO(p), _("start")))
+	    if (!Linux && !chs_ok(b, PNO(p), _("start")))
 		return 0;
 	    if (a.s && !is_equal_chs(a, b))
 		my_warn(_
@@ -1388,7 +1386,7 @@ partitions_ok(struct disk_desc *z) {
 	    b = p->p.end_chs;
 	    aa = chs_to_longchs(a);
 	    bb = chs_to_longchs(b);
-	    if (!chs_ok(b, PNO(p), _("end")))
+	    if (!Linux && !chs_ok(b, PNO(p), _("end")))
 		return 0;
 	    if (a.s && !is_equal_chs(a, b))
 		my_warn(_
@@ -2087,7 +2085,7 @@ read_line(int pno, struct part_desc *ep,
 
     /* use specified format, but round to cylinders if F_MEGABYTE specified */
     format = 0;
-    if (B.cylindersize && specified_format == F_MEGABYTE)
+    if (B.cylindersize && specified_format == F_MEGABYTE && !Linux)
 	format = F_CYLINDER;
 
     orig = (one_only ? &(oldp.partitions[pno]) : 0);

^ permalink raw reply

* Re: [PATCH] sfdisk: make some tests conditional to !Linux
From: Giulio Orsero @ 2011-08-22 18:45 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110822083206.GA20457@nb.net.home>

On Mon, 22 Aug 2011 10:32:06 +0200, Karel Zak <kzak@redhat.com> wrote:

>On Thu, Aug 18, 2011 at 09:30:30AM +0200, Giulio wrote:
>> +	    if (!chs_ok(b, PNO(p), _("start")) && !Linux)
>[...]
>> +	    if (!chs_ok(b, PNO(p), _("end")) && !Linux)
>would be better to use
>    if (!Linux && chs_ok(b, PNO(p), ....)
>so the chs_ok() will not called on Linux at all?

Maybe the compiler reordered it since it didn't print those messages =
anymore
anyway; for clarity I redordered the tests.

^ permalink raw reply

* Re: [PATCH] new chcpu tool
From: Karel Zak @ 2011-08-22 13:28 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: util-linux
In-Reply-To: <20110822120641.GA7549@osiris.boeblingen.de.ibm.com>

On Mon, Aug 22, 2011 at 02:06:41PM +0200, Heiko Carstens wrote:
> Do you think it would be ok to have it in util-linux? Or should it live
> somewhere else?

It makes sense to have it in util-linux. I'm going to merge it after
v2.20 release.

> Another reason for trying to add it to util-linux is that we want to avoid
> doing the same mistake we did already with the "lsmem" and "chmem" tools
> which can configure hotplug memory. These tools are completely architecture
> independent, but we put them into our "s390-tools" package.
> I think both of them should live in util-linux instead... But that's
> something we could address later anyway :)

 OK :-)

> +static int path_exist(const char *path, ...)

 It seems that we need to move the path_*() functions from lscpu(1) to
 lib/ and hare the stuff.

    Karel

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

^ permalink raw reply

* Re: PAM-only login(1)
From: Ludwig Nussel @ 2011-08-22 12:34 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux, Thorsten Kukuk
In-Reply-To: <20110822120123.GC20457@nb.net.home>

Karel Zak wrote:
> On Mon, Aug 22, 2011 at 01:19:44PM +0200, Ludwig Nussel wrote:
>> Karel Zak wrote:
>>>   I'd like to clean up login(1) code for v2.21. The current code is
>>>   mess with many #ifdef and support for some unused (and badly tested) 
>>>   features (e.g. non-PAM support for /etc/securetty and /etc/usertty).
>>>
>>>   What about to finally create nice and readable PAM-only login(1) for
>>>   Linux?
>>
>> +1
>>
>> On openSUSE we already use a pam-only login program¹. It was forked
> 
> It would be nice to merge all back to util-linux and share the code
> rather than maintain forks.

Sure.

>> from util-linux > ten years ago AFAICT. It also includes features
>> from shadow-utils, like reading settings from /etc/login.defs.
> 
> Does make anything other than MAIL_DIR sense for login(1)?

That one isn't even used by our login. AFAICT the following settings are
honored:

DEFAULT_HOME
ENV_PATH
ENV_ROOTPATH
FAIL_DELAY
HUSHLOGIN_FILE
LOGIN_TIMEOUT
LOG_UNKFAIL_ENAB
MOTD_FILE
TTYGROUP
TTYPERM
TTYTYPE_FILE

I agree that most of them are either superfluous or could be handled by
pam modules. Probably interesting are LOGIN_TIMEOUT and
LOG_UNKFAIL_ENAB. The former is hard-coded in util-linux and the latter
feature is missing. It replaces unknown user names with "UNKNOWN" in the
logs.

cu
Ludwig

-- 
 (o_   Ludwig Nussel
 //\
 V_/_  http://www.suse.de/
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) 

^ permalink raw reply

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

Hi Karel,

here is an updated version of the chcpu tool that includes all the features
I described in my previous mail.
Do you think it would be ok to have it in util-linux? Or should it live
somewhere else?

The rationale why I think it should be within util-linux is simply that
lscpu is already there. Parts of the tool are architecture/hypervisor
dependent, but some things are useful for most architectures, I think.
At least for those architectures that support virtualization quite a few
features are (or will be) common.

Another reason for trying to add it to util-linux is that we want to avoid
doing the same mistake we did already with the "lsmem" and "chmem" tools
which can configure hotplug memory. These tools are completely architecture
independent, but we put them into our "s390-tools" package.
I think both of them should live in util-linux instead... But that's
something we could address later anyway :)

Anyway, what do you think?

Thanks,
Heiko

----

Subject: [PATCH] chcpu: new tool

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

chcpu can modify the logical state of CPUs. It can enable and disable CPUs,
scan for new CPUs, change the CPU dispatching mode of the underlying
hypervisor and request (configure) or give logical CPUs back (deconfigure)
to the the underlying hypervisor.

This is quite useful if you work a lot with virtual servers, since doing all
the configuration stuff directly via sysfs becomes a pain.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---

 sys-utils/.gitignore  |    1 
 sys-utils/Makefile.am |    3 
 sys-utils/chcpu.1     |   94 +++++++++++++
 sys-utils/chcpu.c     |  337 ++++++++++++++++++++++++++++++++++++++++++++++++++
 sys-utils/lscpu.1     |    2 
 5 files changed, 437 insertions(+)

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..9417a72
--- /dev/null
+++ b/sys-utils/chcpu.1
@@ -0,0 +1,94 @@
+.TH CHCPU 1 "August 2011" Linux "User Manuals"
+.SH NAME
+chcpu \- CPU configuration utility
+.SH SYNOPSIS
+.B chcpu
+\fB-c\fP|\fB\-d\fP|\fB\-e\fP|\fB\-g\fP
+.IR cpu-list
+.br
+.B
+\fBchcpu \-p\fP \fImode\fP
+.br
+.B chcpu
+.RB [ \-rhV\ ]
+.br
+.SH DESCRIPTION
+.B chcpu
+can modify the logical state of CPUs. It can enable and disable CPUs, scan
+for new CPUs, change the CPU dispatching mode of the underlying hypervisor
+and request (configure) or give logical CPUs back (deconfigure) to the
+the underlying hypervisor.
+
+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 --configure, --deconfigure, --disable, --dispatch, --enable and --rescan
+options are mutually exclusive.
+.TP
+.BR \-c , " \-\-configure " <\fIcpu-list\fP>
+Configure all CPUs specified with \fIcpu-list\fP. If
+.BR chcpu
+fails to configure 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.
+.br
+Configuring a CPU means that the underlying hypervisor is informed that
+a logical CPU within a guest should be used. If the hypervisor has enough
+resources the request will succeed.
+.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.
+.br
+When a CPU has been disabled its state is offline.
+.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.
+.br
+When a CPU has been enabled its state is online.
+.TP
+.BR \-g , " \-\-deconfigure " <\fIcpu-list\fP>
+Deconfigure all CPUs specified with \fIcpu-list\fP. If
+.BR chcpu
+fails to deconfigure 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. Only disabled (offline) CPUs can be deconfigured.
+.br
+Deconfiguring a CPU means that the underlying hypervisor is informed that
+the CPU will not be used anymore and that the hypervisor can add the CPU
+back to its CPU pool.
+.TP
+.BR \-h , " \-\-help"
+Print a help text and exit.
+.TP
+.BR \-p , " \-\-dispatch " <\fImode\fP>
+Set the CPU dispatching \fImode\fP if the underlying hypervisor supports this.
+\fImode\fP may be horizontal or vertical.
+.TP
+.BR \-r , " \-\-rescan"
+Trigger a rescan of CPUs. If new CPUs have been attached to the system the
+kernel will detect them. On some systems no event will be generated if a
+CPU gets attached. In that case a CPU rescan must be manually triggered.
+.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..2d5725f
--- /dev/null
+++ b/sys-utils/chcpu.c
@@ -0,0 +1,337 @@
+/*
+ * 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"
+#define _PATH_SYS_CPU_RESCAN	_PATH_SYS_CPU "/rescan"
+#define _PATH_SYS_CPU_DISPATCH	_PATH_SYS_CPU "/dispatching"
+
+static char pathbuf[PATH_MAX];
+
+enum {
+	CMD_CPU_ENABLE	= 0,
+	CMD_CPU_DISABLE,
+	CMD_CPU_CONFIGURE,
+	CMD_CPU_DECONFIGURE,
+	CMD_CPU_RESCAN,
+	CMD_CPU_DISPATCH_HORIZONTAL,
+	CMD_CPU_DISPATCH_VERTICAL,
+};
+
+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 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)) {
+			printf(_("CPU %d does not exist\n"), cpu);
+			continue;
+		}
+		if (!path_exist(_PATH_SYS_CPU "/cpu%d/online", cpu)) {
+			printf(_("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)) {
+			printf(_("CPU %d is already enabled\n"), cpu);
+			continue;
+		}
+		if ((c == '0') && (enable == 0)) {
+			printf(_("CPU %d is already disabled\n"), cpu);
+			continue;
+		}
+		if (enable) {
+			rc = write(fd, "1", 1);
+			if (rc == -1)
+				printf(_("CPU %d enable failed (%s)\n"), cpu,
+					strerror(errno));
+			else
+				printf(_("CPU %d enabled\n"), cpu);
+		} else {
+			rc = write(fd, "0", 1);
+			if (rc == -1)
+				printf(_("CPU %d disable failed (%s)\n"), cpu,
+					strerror(errno));
+			else
+				printf(_("CPU %d disabled\n"), cpu);
+		}
+		close(fd);
+	}
+	return EXIT_SUCCESS;
+}
+
+static int cpu_rescan(void)
+{
+	int fd;
+
+	if (!path_exist(_PATH_SYS_CPU_RESCAN))
+		errx(EXIT_FAILURE, _("This system does not support rescanning of CPUs"));
+	fd = path_open(O_WRONLY, _PATH_SYS_CPU_RESCAN);
+	if (write(fd, "1", 1) == -1)
+		err(EXIT_FAILURE, _("Failed to trigger rescan of CPUs"));
+	close(fd);
+	return EXIT_SUCCESS;
+}
+
+static int cpu_set_dispatch(int mode)
+{
+	int fd;
+
+	if (!path_exist(_PATH_SYS_CPU_DISPATCH))
+		errx(EXIT_FAILURE, _("This system does not support setting "
+				     "the dispatching mode of CPUs"));
+	fd = path_open(O_WRONLY, _PATH_SYS_CPU_DISPATCH);
+	if (mode == 0) {
+		if (write(fd, "0", 1) == -1)
+			err(EXIT_FAILURE, _("Failed to set horizontal dispatch mode"));
+		printf(_("Succesfully set horizontal dispatching mode\n"));
+	} else {
+		if (write(fd, "1", 1) == -1)
+			err(EXIT_FAILURE, _("Failed to set vertical dispatch mode"));
+		printf(_("Succesfully set vertical dispatching mode\n"));
+	}
+	close(fd);
+	return EXIT_SUCCESS;
+}
+
+static int cpu_configure(cpu_set_t *cpu_set, size_t setsize, int configure)
+{
+	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)) {
+			printf(_("CPU %d does not exist\n"), cpu);
+			continue;
+		}
+		if (!path_exist(_PATH_SYS_CPU "/cpu%d/configure", cpu)) {
+			printf(_("CPU %d is not configurable\n"), cpu);
+			continue;
+		}
+		fd = path_open(O_RDWR, _PATH_SYS_CPU "/cpu%d/configure", cpu);
+		if (read(fd, &c, 1) == -1)
+			err(EXIT_FAILURE, "error: cannot read from %s", pathbuf);
+		if ((c == '1') && (configure == 1)) {
+			printf(_("CPU %d is already configured\n"), cpu);
+			continue;
+		}
+		if ((c == '0') && (configure == 0)) {
+			printf(_("CPU %d is already deconfigured\n"), cpu);
+			continue;
+		}
+		if (configure) {
+			rc = write(fd, "1", 1);
+			if (rc == -1)
+				printf(_("CPU %d configure failed (%s)\n"), cpu,
+					strerror(errno));
+			else
+				printf(_("CPU %d configured\n"), cpu);
+		} else {
+			rc = write(fd, "0", 1);
+			if (rc == -1)
+				printf(_("CPU %d deconfigure failed (%s)\n"), cpu,
+					strerror(errno));
+			else
+				printf(_("CPU %d deconfigured\n"), cpu);
+		}
+		close(fd);
+	}
+	return EXIT_SUCCESS;
+}
+
+static void __attribute__((__noreturn__)) usage(FILE *out)
+{
+	fprintf(out, _(
+		"\nUsage:\n"
+		" %s [options]\n"), program_invocation_short_name);
+
+	puts(_(	"\nOptions:\n"
+		"  -h, --help                    print this help\n"
+		"  -e, --enable <cpu-list>       enable cpus\n"
+		"  -d, --disable <cpu-list>      disable cpus\n"
+		"  -c, --configure <cpu-list>    configure cpus\n"
+		"  -g, --deconfigure <cpu-list>  deconfigure cpus\n"
+		"  -p, --dispatch <mode>         set dispatching mode\n"
+		"  -r, --rescan                  trigger rescan of cpus\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[] = {
+		{ "configure",	required_argument, 0, 'c' },
+		{ "deconfigure",required_argument, 0, 'g' },
+		{ "disable",	required_argument, 0, 'd' },
+		{ "dispatch",	required_argument, 0, 'p' },
+		{ "enable",	required_argument, 0, 'e' },
+		{ "help",	no_argument,       0, 'h' },
+		{ "rescan",	no_argument,       0, 'r' },
+		{ "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, "c:d:e:g:hp:rV", longopts, NULL)) != -1) {
+		if (cmd != -1 && strchr("cdegpr", c))
+			errx(EXIT_FAILURE,
+			     _("configure, deconfigure, disable, dispatch, enable "
+			       "and rescan are mutually exclusive"));
+		switch (c) {
+		case 'c':
+			cmd = CMD_CPU_CONFIGURE;
+			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 '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 'g':
+			cmd = CMD_CPU_DECONFIGURE;
+			if (cpulist_parse(argv[optind - 1], cpu_set, setsize, 1))
+				errx(EXIT_FAILURE, _("failed to parse CPU list: %s"),
+				     argv[optind -1 ]);
+			break;
+		case 'h':
+			usage(stdout);
+		case 'p':
+			if (strcmp("horizontal", argv[optind - 1]) == 0)
+				cmd = CMD_CPU_DISPATCH_HORIZONTAL;
+			else if (strcmp("vertical", argv[optind - 1]) == 0)
+				cmd = CMD_CPU_DISPATCH_VERTICAL;
+			else
+				errx(EXIT_FAILURE, _("unsupported argument: %s"),
+				     argv[optind -1 ]);
+			break;
+		case 'r':
+			cmd = CMD_CPU_RESCAN;
+			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);
+	case CMD_CPU_CONFIGURE:
+		return cpu_configure(cpu_set, ncpus, 1);
+	case CMD_CPU_DECONFIGURE:
+		return cpu_configure(cpu_set, ncpus, 0);
+	case CMD_CPU_RESCAN:
+		return cpu_rescan();
+	case CMD_CPU_DISPATCH_HORIZONTAL:
+		return cpu_set_dispatch(0);
+	case CMD_CPU_DISPATCH_VERTICAL:
+		return cpu_set_dispatch(1);
+	}
+	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/.

^ permalink raw reply related

* Re: PAM-only login(1)
From: Karel Zak @ 2011-08-22 12:01 UTC (permalink / raw)
  To: Ludwig Nussel; +Cc: util-linux, Thorsten Kukuk
In-Reply-To: <4E523B50.8080204@suse.de>

On Mon, Aug 22, 2011 at 01:19:44PM +0200, Ludwig Nussel wrote:
> Karel Zak wrote:
> >   I'd like to clean up login(1) code for v2.21. The current code is
> >   mess with many #ifdef and support for some unused (and badly tested) 
> >   features (e.g. non-PAM support for /etc/securetty and /etc/usertty).
> > 
> >   What about to finally create nice and readable PAM-only login(1) for
> >   Linux?
> 
> +1
> 
> On openSUSE we already use a pam-only login program¹. It was forked

It would be nice to merge all back to util-linux and share the code
rather than maintain forks.

> from util-linux > ten years ago AFAICT. It also includes features
> from shadow-utils, like reading settings from /etc/login.defs.

Does make anything other than MAIL_DIR sense for login(1)?

(IMHO the MAIL_DIR could be also defined by pam_env.)

    Karel

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

^ permalink raw reply

* Re: PAM-only login(1)
From: Ludwig Nussel @ 2011-08-22 11:19 UTC (permalink / raw)
  To: util-linux; +Cc: Thorsten Kukuk
In-Reply-To: <20110812115758.GC1843@nb.net.home>

Karel Zak wrote:
>   I'd like to clean up login(1) code for v2.21. The current code is
>   mess with many #ifdef and support for some unused (and badly tested) 
>   features (e.g. non-PAM support for /etc/securetty and /etc/usertty).
> 
>   What about to finally create nice and readable PAM-only login(1) for
>   Linux?

+1

On openSUSE we already use a pam-only login program¹. It was forked
from util-linux > ten years ago AFAICT. It also includes features
from shadow-utils, like reading settings from /etc/login.defs.

cu
Ludwig

[1] https://build.opensuse.org/package/files?package=login&project=Base%3ASystem

-- 
 (o_   Ludwig Nussel
 //\
 V_/_  http://www.suse.de/
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg) 

^ permalink raw reply

* Re: [patches] uniformizing the man page headers and footers
From: Karel Zak @ 2011-08-22  8:41 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Util-Linux
In-Reply-To: <1313833851.22309.140258131751361@webmail.messagingengine.com>

On Sat, Aug 20, 2011 at 11:50:51AM +0200, Benno Schulenberg wrote:
>  91 files changed, 143 insertions(+), 142 deletions(-)

 Applied, thanks!

    Karel

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

^ permalink raw reply

* Re: Subject: [PATCH] docs: update ReleaseNotes: fix typo in v2.20-ReleaseNotes
From: Karel Zak @ 2011-08-22  8:37 UTC (permalink / raw)
  To: Bernhard Voelker; +Cc: util-linux
In-Reply-To: <4E4D2FB6.7060001@bernhard-voelker.de>

On Thu, Aug 18, 2011 at 05:28:54PM +0200, Bernhard Voelker wrote:
>  docs/v2.20-ReleaseNotes |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

 Applied, thanks.

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

^ permalink raw reply

* Re: [PATCH] sfdisk: make some tests conditional to !Linux
From: Karel Zak @ 2011-08-22  8:32 UTC (permalink / raw)
  To: giulioo; +Cc: util-linux
In-Reply-To: <20110818073019.B70AFF815@i3.golden.dom>

On Thu, Aug 18, 2011 at 09:30:30AM +0200, Giulio wrote:
> +	    if (!chs_ok(b, PNO(p), _("start")) && !Linux)
[...]
> +	    if (!chs_ok(b, PNO(p), _("end")) && !Linux)

would be better to use

    if (!Linux && chs_ok(b, PNO(p), ....)

so the chs_ok() will not called on Linux at all?

    Karel

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

^ permalink raw reply

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

On Sat, Aug 20, 2011 at 09:08:08PM +0200, Sami Kerola wrote:
> On Sat, Aug 20, 2011 at 11:10, Benno Schulenberg <bensberg@justemail.net> wrote:
> > On Wed, 17 Aug 2011 15:07 +0200, "Sami Kerola" <kerolasa@iki.fi> wrote:
> >> On Tue, Aug 16, 2011 at 12:39, Karel Zak <kzak@redhat.com> wrote:
> >>>  It would be also nice to sync man pages with usage() format.
> >
> > Do you mean that you want to use "--option <argument>" also in the
> > man pages, Karel?  Or do we stick there to italics for arguments?
> > (Which translates to underlining on terminals.)

 I mean that we need to use the lowercase for the arguments in usage()
 as well as in man pages.

> IMHO the following looks quite ok, and not too different to
> usage().
> 
> .TP
> \fB\-n\fR, \fB\-\-no\-argument\fR
> This option does not use argument.
> .TP
> \fB\-o\fR, \fB\-\-optional\fR[=<\fIarg\fR>]
> This option uses optional argument.
> .TP
> \fB\-r\fR, \fB\-\-required\fR <\fIarg\fR>
> This option requires an argument.
> 
> Comments?

 I have no strong opinion about it. Benno is probably right that
 italics for the arguments is enough. 

 We already use option arguments without diamond brackets in our man
 pages, so let's continue with this convention to minimize number of
 changes in the man pages ;-)

    Karel

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

^ permalink raw reply

* Re: man-pages and usage() howto
From: Sami Kerola @ 2011-08-21 10:56 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: Karel Zak, util-linux
In-Reply-To: <CAG27Bk0m45JFtP2MNz27tgJ=-f5XZDHUtd1C9O4X0ALO52-BVA@mail.gmail.com>

On Sat, Aug 20, 2011 at 21:08, Sami Kerola <kerolasa@iki.fi> wrote:
> What ever was meant the howto is incomplete.
>
> https://github.com/kerolasa/lelux-utiliteetit/blob/docs-dir/Documentation=
/howto-man-page.txt

I took another look of the howto-man-page, and changed bits here and
there. Is that now better or worse? Should there be more examples
about some common thing I missed?

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

^ 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