Util-Linux package development
 help / color / mirror / Atom feed
* Re: [PATCH 6/6] sfdisk: fix for data type mismatches
From: Karel Zak @ 2011-06-29 10:50 UTC (permalink / raw)
  To: kerolasa; +Cc: util-linux
In-Reply-To: <BANLkTik2HR3BCHFta13hg_QK6nXEZm19Pw@mail.gmail.com>

On Tue, Jun 14, 2011 at 10:00:56PM +0200, Sami Kerola wrote:
> Yes are right, that was silly. I reviewed the patch and changed data
> types to size_t. The fix is pushed with force to my git.

 Merged.

> p.s. The style in the file is really horrible. How about doing the
> following, which will unify the style within the file without changing
> everything.
> 
> indent -linux -i4 -psl -brf sfdisk.c

 Hmm.. I don't like such patches, but you're right that the file is
 horrible. Fixed....

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

^ permalink raw reply

* Re: [PATCH 4/4] script: remove magic constants and a type mismatch fix
From: Karel Zak @ 2011-06-29  9:44 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux
In-Reply-To: <1309257806-1418-4-git-send-email-kerolasa@iki.fi>

On Tue, Jun 28, 2011 at 12:43:26PM +0200, Sami Kerola wrote:
>  term-utils/script.c |   68 ++++++++++++++++++++++++++------------------------
>  1 files changed, 35 insertions(+), 33 deletions(-)

 Applied.

>>  void
>  fail() {
>  
> -	kill(0, SIGTERM);
> +	kill(getpid(), SIGTERM);
>  	done();
>  }

 I think we want to use zero rather than getpid()...

    Karel

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

^ permalink raw reply

* Re: [PATCH 3/4] script: include-what-you-use header check
From: Karel Zak @ 2011-06-29  9:35 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux
In-Reply-To: <1309257806-1418-3-git-send-email-kerolasa@iki.fi>

On Tue, Jun 28, 2011 at 12:43:25PM +0200, Sami Kerola wrote:
>  term-utils/script.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)

 Applied, thanks.

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

^ permalink raw reply

* Re: [PATCH 2/4] script: remove unnecessary void casting
From: Karel Zak @ 2011-06-29  9:35 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux
In-Reply-To: <1309257806-1418-2-git-send-email-kerolasa@iki.fi>

On Tue, Jun 28, 2011 at 12:43:24PM +0200, Sami Kerola wrote:
>  term-utils/script.c |   56 +++++++++++++++++++++++++-------------------------
>  1 files changed, 28 insertions(+), 28 deletions(-)

 Applied, thanks.

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

^ permalink raw reply

* Re: [PATCH 1/4] script: option --force added
From: Karel Zak @ 2011-06-29  9:34 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux
In-Reply-To: <1309257806-1418-1-git-send-email-kerolasa@iki.fi>

On Tue, Jun 28, 2011 at 12:43:23PM +0200, Sami Kerola wrote:
> The --force will allow default output destination, e.g.
> typescript file, to be hard or symbolic link.

 Applied, thanks.

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

^ permalink raw reply

* Re: [PATCH] umount: do not hang with disconnected NFS mounts
From: Karel Zak @ 2011-06-29  9:12 UTC (permalink / raw)
  To: util-linux, Konstantin Khlebnikov
In-Reply-To: <20110629082408.GA27888@foxbat.suse.cz>

On Wed, Jun 29, 2011 at 10:24:09AM +0200, Petr Uzel wrote:
> Since util-linux commit f4612577c942a3683b97632ad0b49671897c2070,
> umount stat(2)s its argument to check whether it can be associated
> with some loop device. This could hang with broken NFS mounts.
> 
> Fix by first checking mtab if umount's argument is mounted and only if
> we fail, check if there is a loop device associated.
> 
> http://marc.info/?l=util-linux-ng&m=130924963804836&w=2
> 
> Reported-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
> ---
>  mount/umount.c |   42 ++++++++++++++++++++++--------------------
>  1 files changed, 22 insertions(+), 20 deletions(-)

 Applied, thanks (also to Konstantin)!

    Karel

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

^ permalink raw reply

* [PATCH] umount: do not hang with disconnected NFS mounts
From: Petr Uzel @ 2011-06-29  8:24 UTC (permalink / raw)
  To: util-linux; +Cc: Konstantin Khlebnikov

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

Since util-linux commit f4612577c942a3683b97632ad0b49671897c2070,
umount stat(2)s its argument to check whether it can be associated
with some loop device. This could hang with broken NFS mounts.

Fix by first checking mtab if umount's argument is mounted and only if
we fail, check if there is a loop device associated.

http://marc.info/?l=util-linux-ng&m=130924963804836&w=2

Reported-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
 mount/umount.c |   42 ++++++++++++++++++++++--------------------
 1 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/mount/umount.c b/mount/umount.c
index 0349cb3..96c940e 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -600,6 +600,7 @@ umount_file (char *arg) {
 	int fstab_has_user, fstab_has_users, fstab_has_owner, fstab_has_group;
 	int ok, status = 0;
 	struct stat statbuf;
+	char *loopdev = NULL;
 
 	if (!*arg) {		/* "" would be expanded to `pwd` */
 		die(2, _("Cannot unmount \"\"\n"));
@@ -608,26 +609,7 @@ umount_file (char *arg) {
 
 	file = canonicalize(arg); /* mtab paths are canonicalized */
 
-	/* if file is a regular file, check if it is associated
-	 * with some loop device
-	 */
-	if (!stat(file, &statbuf) && S_ISREG(statbuf.st_mode)) {
-		char *loopdev = NULL;
-		switch (find_loopdev_by_backing_file(file, &loopdev)) {
-		case 0:
-			if (verbose)
-				printf(_("%s is associated with %s, trying to unmount it\n"),
-				       arg, loopdev);
-			file = loopdev;
-			break;
-		case 2:
-			if (verbose)
-				printf(_("%s is associated with more than one loop device: not unmounting\n"),
-				       arg);
-			break;
-		}
-	}
-
+try_loopdev:
 	if (verbose > 1)
 		printf(_("Trying to unmount %s\n"), file);
 
@@ -659,6 +641,26 @@ umount_file (char *arg) {
 	if (!mc && verbose)
 		printf(_("Could not find %s in mtab\n"), file);
 
+	/* not found in mtab - check if it is associated with some loop device
+	 * (only if it is a regular file)
+	 */
+	if (!mc && !loopdev && !stat(file, &statbuf) && S_ISREG(statbuf.st_mode)) {
+		switch (find_loopdev_by_backing_file(file, &loopdev)) {
+		case 0:
+			if (verbose)
+				printf(_("%s is associated with %s\n"),
+				       arg, loopdev);
+			file = loopdev;
+			goto try_loopdev;
+			break;
+		case 2:
+			if (verbose)
+				printf(_("%s is associated with more than one loop device: not unmounting\n"),
+				       arg);
+			break;
+		}
+	}
+
 	if (mc) {
 		/*
 		 * helper - umount helper (e.g. pam_mount)
-- 
1.7.3.4


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode

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

^ permalink raw reply related

* Re: [BUG] umount does not work for disconected nfs mounts
From: Mike Frysinger @ 2011-06-29  6:44 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: util-linux, khlebnikov
In-Reply-To: <4E099B86.1030802@parallels.com>

On Tue, Jun 28, 2011 at 05:14, Konstantin Khlebnikov wrote:
> Petr Uzel wrote:
>> On Tue, Jun 28, 2011 at 12:18:03PM +0400, Konstantin Khlebnikov wrote:
>>> commit 33cee6675edecbd27c0628f8b7c74c7d88fc02b2
>>>
>>> http://git.kernel.org/?p=utils/util-linux/util-linux-ng.git;a=commitdiff;h=33cee6675edecbd27c0628f8b7c74c7d88fc02b2;hp=fde25e6be6e00a0998eb58b4b9d0d0b9ad65dbfd
>>> "umount: allow unmounting loopdev specified by associated file"
>>> broke umounting (by mountpoint) for broken nfs mounts,
>>> because now umount always call stat() for target argument and umount hang
>>> inside nfs-rpc:
>>
>> Shouldn't this be handled in the kernel? Or is stat() really
>> supposed to fail in such way with broken nfs?
>
> It depends on used mount options, IIRR in "soft" mode it by default fail
> with EIO after 3-6 minutes timeout,
> in "hard" mode syscalls never returns EIO.

i noticed this recently.  one of the reasons i love `umount -lf` with
broken nfs mounts is that it works immediately.  any attempt to access
said broken mount in this situation is wrong as it inherently implies
it has to wait for a timeout (if one ever comes as Konstantin noted).

other than my personal usage on the command line, it makes shutdown
scripts obnoxiously slow to the point of being useless.
-mike

^ permalink raw reply

* Re: [BUG] umount does not work for disconected nfs mounts
From: Karel Zak @ 2011-06-29  6:40 UTC (permalink / raw)
  To: util-linux, khlebnikov
In-Reply-To: <20110628085724.GE22770@foxbat.suse.cz>

On Tue, Jun 28, 2011 at 10:57:24AM +0200, Petr Uzel wrote:
> > so mount /mnt/nfs get stuck, umounting by device is still possible.
> 
> We might first scan through mtab to check if umount arg is known
> mountpoint and only if we fail, we would look for associated loopfile.

 Yes, go ahead.

    Karel

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

^ permalink raw reply

* [PATCH 4/4] script: remove magic constants and a type mismatch fix
From: Sami Kerola @ 2011-06-28 10:43 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa
In-Reply-To: <1309257806-1418-1-git-send-email-kerolasa@iki.fi>

The type mismatch; doinput: int -> ssize_t

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/script.c |   68 ++++++++++++++++++++++++++------------------------
 1 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/term-utils/script.c b/term-utils/script.c
index 39bc5ef..fccc0c4 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -71,6 +71,8 @@
 #include <utempter.h>
 #endif
 
+#define DEFAULT_OUTPUT "typescript"
+
 void finish(int);
 void done(void);
 void fail(void);
@@ -164,16 +166,16 @@ main(int argc, char **argv) {
 	enum { FORCE_OPTION = CHAR_MAX + 1 };
 
 	static const struct option longopts[] = {
-		{ "append",	no_argument,	   0, 'a' },
-		{ "command",	required_argument, 0, 'c' },
-		{ "return",	no_argument,	   0, 'e' },
-		{ "flush",	no_argument,	   0, 'f' },
-		{ "force",	no_argument,	   0, FORCE_OPTION, },
-		{ "quiet",	no_argument,	   0, 'q' },
-		{ "timing",	optional_argument, 0, 't' },
-		{ "version",	no_argument,	   0, 'V' },
-		{ "help",	no_argument,	   0, 'h' },
-		{ NULL,		0, 0, 0 }
+		{ "append",	no_argument,	   NULL, 'a' },
+		{ "command",	required_argument, NULL, 'c' },
+		{ "return",	no_argument,	   NULL, 'e' },
+		{ "flush",	no_argument,	   NULL, 'f' },
+		{ "force",	no_argument,	   NULL, FORCE_OPTION, },
+		{ "quiet",	no_argument,	   NULL, 'q' },
+		{ "timing",	optional_argument, NULL, 't' },
+		{ "version",	no_argument,	   NULL, 'V' },
+		{ "help",	no_argument,	   NULL, 'h' },
+		{ NULL,		0, NULL, 0 }
 	};
 
 	setlocale(LC_ALL, "");
@@ -184,28 +186,28 @@ main(int argc, char **argv) {
 	while ((ch = getopt_long(argc, argv, "ac:efqt::Vh", longopts, NULL)) != -1)
 		switch(ch) {
 		case 'a':
-			aflg++;
+			aflg = 1;
 			break;
 		case 'c':
 			cflg = optarg;
 			break;
 		case 'e':
-			eflg++;
+			eflg = 1;
 			break;
 		case 'f':
-			fflg++;
+			fflg = 1;
 			break;
 		case FORCE_OPTION:
 			forceflg = 1;
 			break;
 		case 'q':
-			qflg++;
+			qflg = 1;
 			break;
 		case 't':
 			if (optarg)
 				if ((timingfd = fopen(optarg, "w")) == NULL)
 					err(EXIT_FAILURE, _("cannot open timing file %s"), optarg);
-			tflg++;
+			tflg = 1;
 			break;
 		case 'V':
 			printf(_("%s from %s\n"), program_invocation_short_name,
@@ -225,7 +227,7 @@ main(int argc, char **argv) {
 	if (argc > 0)
 		fname = argv[0];
 	else {
-		fname = "typescript";
+		fname = DEFAULT_OUTPUT;
 		die_if_link(fname);
 	}
 	if ((fscript = fopen(fname, aflg ? "a" : "w")) == NULL) {
@@ -289,20 +291,20 @@ main(int argc, char **argv) {
 
 void
 doinput() {
-	register int cc;
+	register ssize_t cc;
 	char ibuf[BUFSIZ];
 
 	fclose(fscript);
 
 	while (die == 0) {
-		if ((cc = read(0, ibuf, BUFSIZ)) > 0) {
+		if ((cc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) {
 			ssize_t wrt = write(master, ibuf, cc);
-			if (wrt == -1) {
+			if (wrt < 0) {
 				warn (_("write failed"));
 				fail();
 			}
 		}
-		else if (cc == -1 && errno == EINTR && resized)
+		else if (cc < 0 && errno == EINTR && resized)
 			resized = 0;
 		else
 			break;
@@ -329,7 +331,7 @@ void
 resize(int dummy __attribute__ ((__unused__))) {
 	resized = 1;
 	/* transmit window change information to the child */
-	ioctl(0, TIOCGWINSZ, (char *)&win);
+	ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&win);
 	ioctl(slave, TIOCSWINSZ, (char *)&win);
 }
 
@@ -353,7 +355,7 @@ dooutput(FILE *timingfd) {
 	ssize_t wrt;
 	ssize_t fwrt;
 
-	close(0);
+	close(STDIN_FILENO);
 #ifdef HAVE_LIBUTIL
 	close(slave);
 #endif
@@ -388,7 +390,7 @@ dooutput(FILE *timingfd) {
 			fprintf(timingfd, "%f %zd\n", newtime - oldtime, cc);
 			oldtime = newtime;
 		}
-		wrt = write(1, obuf, cc);
+		wrt = write(STDOUT_FILENO, obuf, cc);
 		if (wrt < 0) {
 			warn (_("write failed"));
 			fail();
@@ -424,9 +426,9 @@ doshell() {
 	getslave();
 	close(master);
 	fclose(fscript);
-	dup2(slave, 0);
-	dup2(slave, 1);
-	dup2(slave, 2);
+	dup2(slave, STDIN_FILENO);
+	dup2(slave, STDOUT_FILENO);
+	dup2(slave, STDERR_FILENO);
 	close(slave);
 
 	master = -1;
@@ -453,13 +455,13 @@ fixtty() {
 	rtt = tt;
 	cfmakeraw(&rtt);
 	rtt.c_lflag &= ~ECHO;
-	tcsetattr(0, TCSANOW, &rtt);
+	tcsetattr(STDIN_FILENO, TCSANOW, &rtt);
 }
 
 void
 fail() {
 
-	kill(0, SIGTERM);
+	kill(getpid(), SIGTERM);
 	done();
 }
 
@@ -479,7 +481,7 @@ done() {
 
 		master = -1;
 	} else {
-		tcsetattr(0, TCSADRAIN, &tt);
+		tcsetattr(STDIN_FILENO, TCSADRAIN, &tt);
 		if (!qflg)
 			printf(_("Script done, file is %s\n"), fname);
 #ifdef HAVE_LIBUTEMPTER
@@ -500,8 +502,8 @@ done() {
 void
 getmaster() {
 #if HAVE_LIBUTIL && HAVE_PTY_H
-	tcgetattr(0, &tt);
-	ioctl(0, TIOCGWINSZ, (char *)&win);
+	tcgetattr(STDIN_FILENO, &tt);
+	ioctl(STDIN_FILENO, TIOCGWINSZ, (char *)&win);
 	if (openpty(&master, &slave, NULL, &tt, &win) < 0) {
 		warn(_("openpty failed"));
 		fail();
@@ -528,8 +530,8 @@ getmaster() {
 				ok = access(line, R_OK|W_OK) == 0;
 				*tp = 'p';
 				if (ok) {
-					tcgetattr(0, &tt);
-					ioctl(0, TIOCGWINSZ,
+					tcgetattr(STDIN_FILENO, &tt);
+					ioctl(STDIN_FILENO, TIOCGWINSZ,
 						(char *)&win);
 					return;
 				}
-- 
1.7.5.2


^ permalink raw reply related

* [PATCH 3/4] script: include-what-you-use header check
From: Sami Kerola @ 2011-06-28 10:43 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa
In-Reply-To: <1309257806-1418-1-git-send-email-kerolasa@iki.fi>

The tool proposed;

script.c should add these lines:

script.c should remove these lines:
- #include <sys/file.h>  // lines 53-53
- #include <sys/types.h>  // lines 48-48
- #include "c.h"  // lines 61-61

and the change nearly did what the tool told. We should keep on
using c.h, not err.h. The config.h is not needed, it's added
automaticly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/script.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/term-utils/script.c b/term-utils/script.c
index 601a91d..39bc5ef 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -45,17 +45,20 @@
 #include <stdlib.h>
 #include <paths.h>
 #include <time.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
-#include <sys/file.h>
 #include <signal.h>
 #include <errno.h>
 #include <string.h>
 #include <getopt.h>
 #include <unistd.h>
+#include <fcntl.h>
+#include <libintl.h>
+#include <limits.h>
+#include <locale.h>
+#include <stddef.h>
 
 #include "nls.h"
 #include "c.h"
-- 
1.7.5.2


^ permalink raw reply related

* [PATCH 2/4] script: remove unnecessary void casting
From: Sami Kerola @ 2011-06-28 10:43 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa
In-Reply-To: <1309257806-1418-1-git-send-email-kerolasa@iki.fi>

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/script.c |   56 +++++++++++++++++++++++++-------------------------
 1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/term-utils/script.c b/term-utils/script.c
index 1753849..601a91d 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -289,7 +289,7 @@ doinput() {
 	register int cc;
 	char ibuf[BUFSIZ];
 
-	(void) fclose(fscript);
+	fclose(fscript);
 
 	while (die == 0) {
 		if ((cc = read(0, ibuf, BUFSIZ)) > 0) {
@@ -326,8 +326,8 @@ void
 resize(int dummy __attribute__ ((__unused__))) {
 	resized = 1;
 	/* transmit window change information to the child */
-	(void) ioctl(0, TIOCGWINSZ, (char *)&win);
-	(void) ioctl(slave, TIOCSWINSZ, (char *)&win);
+	ioctl(0, TIOCGWINSZ, (char *)&win);
+	ioctl(slave, TIOCSWINSZ, (char *)&win);
 }
 
 /*
@@ -350,9 +350,9 @@ dooutput(FILE *timingfd) {
 	ssize_t wrt;
 	ssize_t fwrt;
 
-	(void) close(0);
+	close(0);
 #ifdef HAVE_LIBUTIL
-	(void) close(slave);
+	close(slave);
 #endif
 	tvec = time((time_t *)NULL);
 	my_strftime(obuf, sizeof obuf, "%c\n", localtime(&tvec));
@@ -396,7 +396,7 @@ dooutput(FILE *timingfd) {
 			fail();
 		}
 		if (fflg)
-			(void) fflush(fscript);
+			fflush(fscript);
 	} while(1);
 
 	if (flgs)
@@ -413,18 +413,18 @@ doshell() {
 
 	t = open(_PATH_DEV_TTY, O_RDWR);
 	if (t >= 0) {
-		(void) ioctl(t, TIOCNOTTY, (char *)0);
-		(void) close(t);
+		ioctl(t, TIOCNOTTY, (char *)0);
+		close(t);
 	}
 #endif
 
 	getslave();
-	(void) close(master);
-	(void) fclose(fscript);
-	(void) dup2(slave, 0);
-	(void) dup2(slave, 1);
-	(void) dup2(slave, 2);
-	(void) close(slave);
+	close(master);
+	fclose(fscript);
+	dup2(slave, 0);
+	dup2(slave, 1);
+	dup2(slave, 2);
+	close(slave);
 
 	master = -1;
 
@@ -450,13 +450,13 @@ fixtty() {
 	rtt = tt;
 	cfmakeraw(&rtt);
 	rtt.c_lflag &= ~ECHO;
-	(void) tcsetattr(0, TCSANOW, &rtt);
+	tcsetattr(0, TCSANOW, &rtt);
 }
 
 void
 fail() {
 
-	(void) kill(0, SIGTERM);
+	kill(0, SIGTERM);
 	done();
 }
 
@@ -471,12 +471,12 @@ done() {
 			my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
 			fprintf(fscript, _("\nScript done on %s"), buf);
 		}
-		(void) fclose(fscript);
-		(void) close(master);
+		fclose(fscript);
+		close(master);
 
 		master = -1;
 	} else {
-		(void) tcsetattr(0, TCSADRAIN, &tt);
+		tcsetattr(0, TCSADRAIN, &tt);
 		if (!qflg)
 			printf(_("Script done, file is %s\n"), fname);
 #ifdef HAVE_LIBUTEMPTER
@@ -497,8 +497,8 @@ done() {
 void
 getmaster() {
 #if HAVE_LIBUTIL && HAVE_PTY_H
-	(void) tcgetattr(0, &tt);
-	(void) ioctl(0, TIOCGWINSZ, (char *)&win);
+	tcgetattr(0, &tt);
+	ioctl(0, TIOCGWINSZ, (char *)&win);
 	if (openpty(&master, &slave, NULL, &tt, &win) < 0) {
 		warn(_("openpty failed"));
 		fail();
@@ -525,12 +525,12 @@ getmaster() {
 				ok = access(line, R_OK|W_OK) == 0;
 				*tp = 'p';
 				if (ok) {
-					(void) tcgetattr(0, &tt);
-				    	(void) ioctl(0, TIOCGWINSZ, 
+					tcgetattr(0, &tt);
+					ioctl(0, TIOCGWINSZ,
 						(char *)&win);
 					return;
 				}
-				(void) close(master);
+				close(master);
 				master = -1;
 			}
 		}
@@ -550,9 +550,9 @@ getslave() {
 		warn(_("open failed: %s"), line);
 		fail();
 	}
-	(void) tcsetattr(slave, TCSANOW, &tt);
-	(void) ioctl(slave, TIOCSWINSZ, (char *)&win);
+	tcsetattr(slave, TCSANOW, &tt);
+	ioctl(slave, TIOCSWINSZ, (char *)&win);
 #endif
-	(void) setsid();
-	(void) ioctl(slave, TIOCSCTTY, 0);
+	setsid();
+	ioctl(slave, TIOCSCTTY, 0);
 }
-- 
1.7.5.2


^ permalink raw reply related

* [PATCH 1/4] script: option --force added
From: Sami Kerola @ 2011-06-28 10:43 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

The --force will allow default output destination, e.g.
typescript file, to be hard or symbolic link.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 term-utils/script.1 |    3 +++
 term-utils/script.c |   21 ++++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/term-utils/script.1 b/term-utils/script.1
index 725bdb2..f618ec3 100644
--- a/term-utils/script.1
+++ b/term-utils/script.1
@@ -84,6 +84,9 @@ termination on signal termination exit code is 128+n.
 Flush output after each write. This is nice for telecooperation:
 One person does `mkfifo foo; script -f foo' and another can
 supervise real-time what is being done using `cat foo'.
+.It Fl Fl force
+Allow default output destination, e.g. typescript file, to be
+hard or symbolic link. The command will follow symbolic link.
 .It Fl q, Fl Fl quiet
 Be quiet.
 .It Fl t, Fl Fl timing[=FILE]
diff --git a/term-utils/script.c b/term-utils/script.c
index 603d392..1753849 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -101,6 +101,7 @@ int	eflg = 0;
 int	fflg = 0;
 int	qflg = 0;
 int	tflg = 0;
+int	forceflg = 0;
 
 int die;
 int resized;
@@ -109,14 +110,13 @@ static void
 die_if_link(char *fn) {
 	struct stat s;
 
+	if (forceflg)
+		return;
 	if (lstat(fn, &s) == 0 && (S_ISLNK(s.st_mode) || s.st_nlink > 1))
-	        /* FIXME: there is no [options] to allow/force this to happen.  */
 		errx(EXIT_FAILURE,
-			_("Warning: `%s' is a link.\n"
-			  "Use `%s [options] %s' if you really "
-			  "want to use it.\n"
-			  "Program not started.\n"),
-			fn, program_invocation_short_name, fn);
+		     _("error: output file `%s' is a link\n"
+		       "Use --force if you really want to use it.\n"
+		       "Program not started."), fn);
 }
 
 static void __attribute__((__noreturn__))
@@ -132,6 +132,7 @@ usage(FILE *out)
 		" -c, --command COMMAND   run command rather than interactive shell\n"
 		" -r, --return            return exit code of the child process\n"
 		" -f, --flush             run flush after each write\n"
+		"     --force             use output file even it would be a link\n"
 		" -q, --quiet             be quiet\n"
 		" -t, --timing=FILE       output timing data to stderr, or to file\n"
 		" -V, --version           output version information and exit\n"
@@ -157,11 +158,14 @@ main(int argc, char **argv) {
 	int ch;
 	FILE *timingfd = stderr;
 
+	enum { FORCE_OPTION = CHAR_MAX + 1 };
+
 	static const struct option longopts[] = {
 		{ "append",	no_argument,	   0, 'a' },
 		{ "command",	required_argument, 0, 'c' },
 		{ "return",	no_argument,	   0, 'e' },
 		{ "flush",	no_argument,	   0, 'f' },
+		{ "force",	no_argument,	   0, FORCE_OPTION, },
 		{ "quiet",	no_argument,	   0, 'q' },
 		{ "timing",	optional_argument, 0, 't' },
 		{ "version",	no_argument,	   0, 'V' },
@@ -175,7 +179,7 @@ main(int argc, char **argv) {
 	textdomain(PACKAGE);
 
 	while ((ch = getopt_long(argc, argv, "ac:efqt::Vh", longopts, NULL)) != -1)
-		switch((char)ch) {
+		switch(ch) {
 		case 'a':
 			aflg++;
 			break;
@@ -188,6 +192,9 @@ main(int argc, char **argv) {
 		case 'f':
 			fflg++;
 			break;
+		case FORCE_OPTION:
+			forceflg = 1;
+			break;
 		case 'q':
 			qflg++;
 			break;
-- 
1.7.5.2


^ permalink raw reply related

* Re: [BUG] umount does not work for disconected nfs mounts
From: Konstantin Khlebnikov @ 2011-06-28  9:14 UTC (permalink / raw)
  To: util-linux, khlebnikov
In-Reply-To: <20110628085724.GE22770@foxbat.suse.cz>

Petr Uzel wrote:
> On Tue, Jun 28, 2011 at 12:18:03PM +0400, Konstantin Khlebnikov wrote:
>> commit 33cee6675edecbd27c0628f8b7c74c7d88fc02b2
>> http://git.kernel.org/?p=utils/util-linux/util-linux-ng.git;a=commitdiff;h=33cee6675edecbd27c0628f8b7c74c7d88fc02b2;hp=fde25e6be6e00a0998eb58b4b9d0d0b9ad65dbfd
>> "umount: allow unmounting loopdev specified by associated file"
>> broke umounting (by mountpoint) for broken nfs mounts,
>> because now umount always call stat() for target argument and umount hang inside nfs-rpc:
>>
>> [<ffffffff8163df3f>] rpc_wait_bit_killable+0x1f/0x40
>> [<ffffffff8163eb85>] __rpc_execute+0xe5/0x2f0
>> [<ffffffff8163eebe>] rpc_execute+0x3e/0x50
>> [<ffffffff816372f0>] rpc_run_task+0x70/0x90
>> [<ffffffff816373fe>] rpc_call_sync+0x3e/0x70
>> [<ffffffff812228f3>] nfs3_rpc_wrapper.constprop.11+0x43/0x70
>> [<ffffffff81223bd2>] nfs3_proc_getattr+0x42/0x80
>> [<ffffffff81212955>] __nfs_revalidate_inode+0x95/0x1f0
>> [<ffffffff81212bf1>] nfs_revalidate_inode+0x31/0x60
>> [<ffffffff81212cca>] nfs_getattr+0x5a/0x110
>> [<ffffffff8112caea>] vfs_getattr+0x1a/0x30
>> [<ffffffff8112cce3>] vfs_fstatat+0x53/0x70
>> [<ffffffff8112cd36>] vfs_stat+0x16/0x20
>> [<ffffffff8112d0c5>] sys_newstat+0x15/0x30
>> [<ffffffff816c45bb>] tracesys+0xd9/0xde
>> [<ffffffffffffffff>] 0xffffffffffffffff
>
> Shouldn't this be handled in the kernel? Or is stat() really
> supposed to fail in such way with broken nfs?

It depends on used mount options, IIRR in "soft" mode it by default fail with EIO after 3-6 minutes timeout,
in "hard" mode syscalls never returns EIO.

BTW linux support bindmounting for individual files,
so argument can refer to regular file not only for loop device image.

>
>>
>> so mount /mnt/nfs get stuck, umounting by device is still possible.
>
> We might first scan through mtab to check if umount arg is known
> mountpoint and only if we fail, we would look for associated loopfile.

Yes, it seems is the best solution

>
> Karel?
>
>
> Petr
>
> --
> Petr Uzel
> IRC: ptr_uzl @ freenode


^ permalink raw reply

* Re: [BUG] umount does not work for disconected nfs mounts
From: Petr Uzel @ 2011-06-28  8:57 UTC (permalink / raw)
  To: util-linux; +Cc: khlebnikov
In-Reply-To: <4E098E3B.5060707@openvz.org>

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

On Tue, Jun 28, 2011 at 12:18:03PM +0400, Konstantin Khlebnikov wrote:
> commit 33cee6675edecbd27c0628f8b7c74c7d88fc02b2
> http://git.kernel.org/?p=utils/util-linux/util-linux-ng.git;a=commitdiff;h=33cee6675edecbd27c0628f8b7c74c7d88fc02b2;hp=fde25e6be6e00a0998eb58b4b9d0d0b9ad65dbfd
> "umount: allow unmounting loopdev specified by associated file"
> broke umounting (by mountpoint) for broken nfs mounts,
> because now umount always call stat() for target argument and umount hang inside nfs-rpc:
> 
> [<ffffffff8163df3f>] rpc_wait_bit_killable+0x1f/0x40
> [<ffffffff8163eb85>] __rpc_execute+0xe5/0x2f0
> [<ffffffff8163eebe>] rpc_execute+0x3e/0x50
> [<ffffffff816372f0>] rpc_run_task+0x70/0x90
> [<ffffffff816373fe>] rpc_call_sync+0x3e/0x70
> [<ffffffff812228f3>] nfs3_rpc_wrapper.constprop.11+0x43/0x70
> [<ffffffff81223bd2>] nfs3_proc_getattr+0x42/0x80
> [<ffffffff81212955>] __nfs_revalidate_inode+0x95/0x1f0
> [<ffffffff81212bf1>] nfs_revalidate_inode+0x31/0x60
> [<ffffffff81212cca>] nfs_getattr+0x5a/0x110
> [<ffffffff8112caea>] vfs_getattr+0x1a/0x30
> [<ffffffff8112cce3>] vfs_fstatat+0x53/0x70
> [<ffffffff8112cd36>] vfs_stat+0x16/0x20
> [<ffffffff8112d0c5>] sys_newstat+0x15/0x30
> [<ffffffff816c45bb>] tracesys+0xd9/0xde
> [<ffffffffffffffff>] 0xffffffffffffffff

Shouldn't this be handled in the kernel? Or is stat() really
supposed to fail in such way with broken nfs?

> 
> so mount /mnt/nfs get stuck, umounting by device is still possible.

We might first scan through mtab to check if umount arg is known
mountpoint and only if we fail, we would look for associated loopfile.

Karel?


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode

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

^ permalink raw reply

* [BUG] umount does not work for disconected nfs mounts
From: Konstantin Khlebnikov @ 2011-06-28  8:18 UTC (permalink / raw)
  To: util-linux, Petr Uzel, Karel Zak

commit 33cee6675edecbd27c0628f8b7c74c7d88fc02b2
http://git.kernel.org/?p=utils/util-linux/util-linux-ng.git;a=commitdiff;h=33cee6675edecbd27c0628f8b7c74c7d88fc02b2;hp=fde25e6be6e00a0998eb58b4b9d0d0b9ad65dbfd
"umount: allow unmounting loopdev specified by associated file"
broke umounting (by mountpoint) for broken nfs mounts,
because now umount always call stat() for target argument and umount hang inside nfs-rpc:

[<ffffffff8163df3f>] rpc_wait_bit_killable+0x1f/0x40
[<ffffffff8163eb85>] __rpc_execute+0xe5/0x2f0
[<ffffffff8163eebe>] rpc_execute+0x3e/0x50
[<ffffffff816372f0>] rpc_run_task+0x70/0x90
[<ffffffff816373fe>] rpc_call_sync+0x3e/0x70
[<ffffffff812228f3>] nfs3_rpc_wrapper.constprop.11+0x43/0x70
[<ffffffff81223bd2>] nfs3_proc_getattr+0x42/0x80
[<ffffffff81212955>] __nfs_revalidate_inode+0x95/0x1f0
[<ffffffff81212bf1>] nfs_revalidate_inode+0x31/0x60
[<ffffffff81212cca>] nfs_getattr+0x5a/0x110
[<ffffffff8112caea>] vfs_getattr+0x1a/0x30
[<ffffffff8112cce3>] vfs_fstatat+0x53/0x70
[<ffffffff8112cd36>] vfs_stat+0x16/0x20
[<ffffffff8112d0c5>] sys_newstat+0x15/0x30
[<ffffffff816c45bb>] tracesys+0xd9/0xde
[<ffffffffffffffff>] 0xffffffffffffffff

so mount /mnt/nfs get stuck, umounting by device is still possible.

^ permalink raw reply

* Re: fdisk
From: Mike Frysinger @ 2011-06-27 19:27 UTC (permalink / raw)
  To: Karel Zak; +Cc: Bruce Dubbs, util-linux
In-Reply-To: <20110627142119.GB6418@nb.net.home>

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

On Monday, June 27, 2011 10:21:19 Karel Zak wrote:
> On Fri, Jun 24, 2011 at 01:25:39PM -0500, Bruce Dubbs wrote:
> > On my system, a block appears to be 2-512 byte sectors, but is it
> > always so?
> 
>  Yes. It's stupid legacy (the same thing you can found in
>  /proc/partitions).
> 
>  I hope that one day we will have better and nicer fdisk with
>  human readable sizes ;-)

and merge duplicated code with cfdisk ;)
-mike

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

^ permalink raw reply

* Re: mount: if mount -a crashes on one partition, remaining should be probed
From: Karel Zak @ 2011-06-27 15:59 UTC (permalink / raw)
  To: Marek Otahal; +Cc: util-linux
In-Reply-To: <201106071151.18570.markotahal@gmail.com>

On Tue, Jun 07, 2011 at 11:51:17AM +0200, Marek Otahal wrote:
> with 2.6.39 kernel I can get in conditions when mounting a btrfs
> partition segfaults (I already reported upstream -
> http://article.gmane.org/gmane.comp.file-systems.btrfs/11135 ).

 If the oops occur in any process (except init) then the process is
 usually killed by kernel... so it really does not seem like mount(8)
 bug.

    Karel

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

^ permalink raw reply

* Re: Pentecost weekend pull request
From: Karel Zak @ 2011-06-27 15:29 UTC (permalink / raw)
  To: kerolasa; +Cc: util-linux
In-Reply-To: <BANLkTimNPg6VVNS+MQ-9cMgs_ppCQYVE=A@mail.gmail.com>

On Sat, Jun 25, 2011 at 05:26:35PM +0200, Sami Kerola wrote:
> All the patches are available in the git repository at:
>  git://github.com/kerolasa/lelux-utiliteetit.git wknd23

 Applied, thanks!

    Karel

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

^ permalink raw reply

* Re: [PATCH] lscpu: fix bogomips detection for s390
From: Karel Zak @ 2011-06-27 14:24 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: util-linux
In-Reply-To: <20110621112433.GA4198@osiris.boeblingen.de.ibm.com>

On Tue, Jun 21, 2011 at 01:24:33PM +0200, Heiko Carstens wrote:
>  sys-utils/lscpu.c |    2 ++
>  1 file changed, 2 insertions(+)

 Applied, thanks.

    Karel

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

^ permalink raw reply

* Re: [PATCH] mkfs.minix: check for misalignment
From: Karel Zak @ 2011-06-27 14:23 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux
In-Reply-To: <1308625906.3690.2.camel@offworld>

On Mon, Jun 20, 2011 at 11:11:46PM -0400, Davidlohr Bueso wrote:
>  disk-utils/mkfs.minix.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)

 Applied with a small change, thanks.

> @@ -653,6 +653,11 @@ int main(int argc, char ** argv) {
>  		DEV = open(device_name,O_RDWR | O_EXCL);
>  	else
>  		DEV = open(device_name,O_RDWR);
> +
> +	if (blkdev_is_misaligned(DEV))
> +		warnx(_("warning: %s is misaligned"), device_name);

 It makes sense for block devices only.

    Karel

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

^ permalink raw reply

* Re: [PATCH] blkdev: add blkdev_get_physector_size()
From: Karel Zak @ 2011-06-27 14:22 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: util-linux
In-Reply-To: <1308625104.3690.1.camel@offworld>

On Mon, Jun 20, 2011 at 10:58:24PM -0400, Davidlohr Bueso wrote:
>  include/blkdev.h |    3 +++
>  lib/blkdev.c     |   14 ++++++++++++++
>  2 files changed, 17 insertions(+), 0 deletions(-)

 Applied with minor changes, thanks.

    Karel

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

^ permalink raw reply

* Re: fdisk
From: Karel Zak @ 2011-06-27 14:21 UTC (permalink / raw)
  To: Bruce Dubbs; +Cc: util-linux
In-Reply-To: <4E04D6A3.4060105@gmail.com>

On Fri, Jun 24, 2011 at 01:25:39PM -0500, Bruce Dubbs wrote:
> On my system, a block appears to be 2-512 byte sectors, but is it
> always so?

 Yes. It's stupid legacy (the same thing you can found in
 /proc/partitions).

 I hope that one day we will have better and nicer fdisk with 
 human readable sizes ;-)

    Karel

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

^ permalink raw reply

* Re: Pentecost weekend pull request
From: Sami Kerola @ 2011-06-25 15:26 UTC (permalink / raw)
  To: Karel Zak; +Cc: util-linux
In-Reply-To: <20110620101947.GA17967@nb.net.home>

On Mon, Jun 20, 2011 at 12:19, Karel Zak <kzak@redhat.com> wrote:
> On Mon, Jun 13, 2011 at 05:13:50PM +0200, Sami Kerola wrote:
>
>> [01/33] mount: take xalloc.h in use
>
>  It would be better to keep my_free() in mount/ sources only. I don't
>  think that we will use this crap outside the mount code.
>
>  Note that the final solution will be libmount/mount.c as the mount(8)
>  command implementation. So, let's keep the current mount/* code in
>  maintenance mode and don't try to rewrite it :-)

The original patch is replaced with a above note added to README.

>> [02/33] checktty: NGROUP -> sysconf
>>         This patch was sent earlier, see details bellow.
>>
>>         date    Thu, Jun 9, 2011 at 21:31
>>         subject Re: [PATCH 3/6] checktty: Use NGROUPS_MAX instead of NGROUPS
>
>  You cannot use xalloc() (and friends) in login(1). The login has to
>  call pam_end and report to syslog before exit.
>
>  I'd like to clean up login(1), it means:
>
>    - code refactoring
>    - support PAM or /etc/{passwd,shadow} *only*
>       - remove checktty support
>       - remove cryptocard support
>       - remove kerberos support

This patch is gone. IMHO the above should be in TODO file.

>> [04/33] login-utils: include fix
>>         Inspired what P?draig Brady did with coreutils I thought
>>         to give a shot to include-what-you-use as well.
>>         http://lists.gnu.org/archive/html/coreutils/2011-06/msg00004.html
>>
>>         The utility clearly works. So it is a good time to think
>>         if checking headers in all files should be TODO item?
>
>  Nice!
>
>  What about to add any wrapper to the tools/ directory and call it
>  from our top-level Makefile?
>
>  We already have some stuff there, and I use it before release.

Funny enough in the coreutils list same question was asked pretty
much immediately. I agree it would be awesome to get automatic
header checking, but for now that is not easy to achieve.

The utility relies on llvm source tree, and it gives lots of
false positive indications. For instance iwyu proposes nls.h
should be removed and replaced with libintl.h. Same happens with
c.h and err.h.

For now I recommend to use this utility when one is working with
some particular file. Something like `if you are going to touch
the file check the headers as well'.

>> [10/33] mcookie: change coding style
>>         The mcookie patches are trivial, with exception of docs
>>         change. Updating manual pages with help2man seems to be
>>         quite good idea. Using the output as is is pretty brain
>>         dead idea, but copy pasting bits of syntax etc seems to
>>         work great. Is this an approach you would like to see in
>>         future?
>
>  It depends, the --help output is usually very brief and space-saving.
>
>  Don't forget that GNU guys hate man pages and all their documentation
>  is in the horrible info files, so help2man makes sense for them ;-)
>  We don't have info files, but we have real man pages.

I did not mean help2man output should be used as is. Taking for
instance .TH line or option \fB\-h\fR, \fB\-\-help\fR lines
sounds reasonable for me. I let the patch be what it was.

>> [11/33] whereis: maintenance fixes
>
>  I can imagine more than one patch for these changes.

Split to 4 patches.

>> [12/33] cal: maintenance fixes
>
>  I'll use this patch, but next time don't mix any real changes in the
>  code with indentation changes. Please!

Sorry. Split to 3 patches.

>> [15/33] docs: rename.1 verbose, long options and warning
>>         Looking the code this utility seems to be in wrong
>>         package. Rewriting the command to rely heavily on gnulib
>>         copy.h and backupfile.h would make this to be good
>>         addition to coreutils, assuming they accept the command.
>
>  Yep, go ahead and ask at coreutils mailing list.

Eventually yes.

>>         Or it could time to deprecate the whole command, and
>>         recommend users to multimove by using scripts.
>
>  The command is used by many users. I don't think that deprecation is
>  a good idea. And I also don't think that change the default behavior
>  is a good idea. Maybe we can add --dry-run.

This is exactly why merging to coreutils might work. Providing
the same switches as there is for mv or cp is fairly easy with
gnulib. IMHO the tool is a little too unixy in doing exactly what
user asks how ever stupid it might be. Having --backup,
--interactive and --no-globber just sound right to me.

I am not sure is --dry-run in this case good idea. There's no
guarantees contents on file system have not changed in between
dry and next run. For example the command is not reentant safe.
User might simply get over confident the dry run did not report
anything and end up loosing data.

>> [18/33] write: maintenance fixes
>
>  Don't use
>
>    return (1);
>
>  use
>    return 1;
>
>  The "return" is not a function.

Fixed.

>> [23/33] uuidd: maintenance fixes
>
>    - remove die() -- use err()
>    - remove printf() + exit() -- use err[x]()
>    - print all error messages (!= debug) to stderr

Done and split to multiple patches.

>> [32/33] getopt: inform where to send bug reports
>>         I wonder should the config.h PACKAGE_BUGREPORT be
>>         util-linux mail list...
>
>  Probably ;-)
>
>  We shouldn't use PACKAGE_BUGREPORT in man pages or --help output. I
>  don't think that upstream is the right place for end-users and their
>  bug reports.
>
>  The ideal solution is downstream --patch--> upstream ;-)

This patch is gone.


All the patches are available in the git repository at:
 git://github.com/kerolasa/lelux-utiliteetit.git wknd23

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

^ permalink raw reply

* fdisk
From: Bruce Dubbs @ 2011-06-24 18:25 UTC (permalink / raw)
  To: util-linux

In fdisk, printing a partition table gives the headers:

Device Boot      Start         End      Blocks   Id  System

What's a block?  It does not seem to be defined anywhere.  Perhaps an 
update to the man page would be appropriate.  A line in the explanation 
above the partition listing would be even better.

On my system, a block appears to be 2-512 byte sectors, but is it always so?

   -- Bruce

^ 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