summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaMont Jones <lamont@debian.org>2008-04-15 22:59:28 -0600
committerLaMont Jones <lamont@debian.org>2008-04-15 22:59:28 -0600
commit769434fc28227d4f83ca6da9d7271b734811fd1c (patch)
tree0eaf54de54c4368cb8ba7747ffcb1874bf34b81c
parent086916a81fb67e2e2a371ec4605b766188adddb0 (diff)
parent42bcaa2ca12865ec09244a66314dafcf05024e4e (diff)
downloadutil-linux-old-769434fc28227d4f83ca6da9d7271b734811fd1c.tar.gz
Merge commit 'origin/master'
Conflicts: mount/lomount.c mount/lomount.h mount/mount.c
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS1
-rw-r--r--DEPRECATED6
-rw-r--r--README.devel58
-rw-r--r--configure.ac1
-rw-r--r--disk-utils/.gitignore12
-rw-r--r--docs/v2.14-ReleaseNotes15
-rw-r--r--fdisk/.gitignore3
-rw-r--r--fdisk/fdisk.c4
-rw-r--r--getopt/.gitignore1
-rw-r--r--hwclock/.gitignore1
-rw-r--r--lib/.gitignore1
-rw-r--r--login-utils/.gitignore9
-rw-r--r--login-utils/Makefile.am7
-rw-r--r--login-utils/chfn.c4
-rw-r--r--login-utils/chsh.c4
-rw-r--r--login-utils/islocal.c105
-rw-r--r--login-utils/islocal.h2
-rw-r--r--login-utils/login.c4
-rw-r--r--misc-utils/.gitignore12
-rw-r--r--misc-utils/Makefile.am6
-rw-r--r--misc-utils/scriptreplay.140
-rw-r--r--misc-utils/scriptreplay.c179
-rwxr-xr-xmisc-utils/scriptreplay.pl83
-rw-r--r--mount/.gitignore6
-rw-r--r--mount/lomount.c44
-rw-r--r--mount/lomount.h2
-rw-r--r--mount/losetup.814
-rw-r--r--mount/mount.84
-rw-r--r--mount/mount.c12
-rw-r--r--mount/swapon.c11
-rw-r--r--partx/.gitignore3
-rw-r--r--schedutils/.gitignore3
-rw-r--r--sys-utils/.gitignore38
-rw-r--r--tests/.gitignore2
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/commands.sh.in1
-rw-r--r--tests/expected/ts-login-islocal13
-rw-r--r--tests/helpers/.gitignore2
-rw-r--r--tests/input/ts-login-islocal10
-rwxr-xr-xtests/ts-login-islocal28
-rw-r--r--text-utils/.gitignore11
42 files changed, 603 insertions, 161 deletions
diff --git a/.gitignore b/.gitignore
index 729240c0..5b76af18 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
*~
*.[ao]
+*.static
Makefile
aclocal.m4
autom4te.cache
diff --git a/AUTHORS b/AUTHORS
index 2c25a0ec..334a5e49 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -102,6 +102,7 @@ CONTRIBUTORS:
Samuel Thibault <samuel.thibault@ens-lyon.org>
Santiago Vila Doncel <sanvila@unex.es>
Sascha Sommer <ssommer@suse.de>
+ Shachar Shemesh <shachar@lingnu.com>
Simon Mihevc <simonmihevc@email.si>
Stefan Krah <stefan@bytereef.org>
Stepan Kasal <skasal@redhat.com>
diff --git a/DEPRECATED b/DEPRECATED
index 6c209b87..4bc79fed 100644
--- a/DEPRECATED
+++ b/DEPRECATED
@@ -2,6 +2,12 @@ The following is a list of commands or features that are deprecated. All
deprecated utils are in maintenace mode and we keep them in source tree for
backward compatibilty only.
+What: losetup -s
+When: 2.15
+Why: the option -s is in collision with the Loop-AES losetup dialect that is used
+ in some distributions. Use the long version (--show) only.
+
+--------------------------
What: raw(8) command
When: undefined yet; depends on kernel upstream
diff --git a/README.devel b/README.devel
index 52cfc8f2..415bd330 100644
--- a/README.devel
+++ b/README.devel
@@ -7,7 +7,7 @@ AUTOTOOLS:
* "./autogen.sh" generates all necessary files (run it after checkout from
git)
- * "make distclean" removes all unnecessary files, but code is still possible
+ * "make distclean" removes all unnecessary files, but code is still possible
recompile by "./configure; make"
* "make dist-gzip" (or -bzip2) creates tarball which is possible use without
@@ -21,7 +21,8 @@ PATCHES:
* diff -u
- * don't include generated (autotools) stuff to your patches (use git-clean [-X])
+ * don't include generated (autotools) stuff to your patches
+ (hint: use git-clean [-X])
* patches are delivered via email only. Downloading them from internet
servers is a pain.
@@ -30,20 +31,59 @@ PATCHES:
* Subject: [PATCH] subsystem: description
- * if someone else wrote the patch, they should be credited (and blamed) for it.
- To communicate this, add a line:
+ * if someone else wrote the patch, they should be credited (and blamed)
+ for it. To communicate this, add a line:
From: John Doe <jdoe@wherever.com>
- * add a Signed-off-by line:
+ * add a Signed-off-by line (hint: use "git commit -s")
- Signed-off-by: Foo Bar <fb@wherever.com>
+ The sign-off is a simple line at the end of the explanation for the
+ patch, which certifies that you wrote it or otherwise have the right to
+ pass it on as a open-source patch. The rules are pretty simple: if you
+ can certify the below:
- * there is a lot of really useful rules. Please, read:
+ By making a contribution to this project, I certify that:
+
+ (a) The contribution was created in whole or in part by me and I
+ have the right to submit it under the open source license
+ indicated in the file; or
+
+ (b) The contribution is based upon previous work that, to the best
+ of my knowledge, is covered under an appropriate open source
+ license and I have the right under that license to submit that
+ work with modifications, whether created in whole or in part
+ by me, under the same open source license (unless I am
+ permitted to submit under a different license), as indicated
+ in the file; or
+
+ (c) The contribution was provided directly to me by some other
+ person who certified (a), (b) or (c) and I have not modified it.
+
+ (d) I understand and agree that this project and the contribution
+ are public and that a record of the contribution (including all
+ personal information I submit with it, including my sign-off) is
+ maintained indefinitely and may be redistributed consistent with
+ this project or the open source license(s) involved.
+
+ then you just add a line saying
+
+ Signed-off-by: Random J Developer <random@developer.example.org>
+
+ using your real name (sorry, no pseudonyms or anonymous contributions.)
+
+
+ * for more details see:
The perfect patch
http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
+CODING STYLE:
+
+ * the preferred coding style is based on the linux kernel Documentation/CodingStyle.
+ For more details see:
+
+ http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/CodingStyle
SCM (source code management):
@@ -72,6 +112,6 @@ SCM (source code management):
- every release, tag name: v<version>
- KNOWN BUGS:
- - tag v2.13.1 is typo. Please, ignore this tag.
+ * KNOWN BUGS:
+ - tag v2.13.1 is typo. Please, ignore this tag.
diff --git a/configure.ac b/configure.ac
index 435f7683..75a112cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -693,7 +693,6 @@ tests/Makefile
tests/helpers/Makefile
tests/commands.sh
misc-utils/chkdupexe:misc-utils/chkdupexe.pl
-misc-utils/scriptreplay:misc-utils/scriptreplay.pl
])
AC_OUTPUT
diff --git a/disk-utils/.gitignore b/disk-utils/.gitignore
new file mode 100644
index 00000000..726008f6
--- /dev/null
+++ b/disk-utils/.gitignore
@@ -0,0 +1,12 @@
+blockdev
+fdformat
+fsck.cramfs
+fsck.minix
+isosize
+mkfs
+mkfs.bfs
+mkfs.minix
+mkswap
+mkfs.cramfs
+elvtune
+raw
diff --git a/docs/v2.14-ReleaseNotes b/docs/v2.14-ReleaseNotes
index c8ca19de..c3aa24c3 100644
--- a/docs/v2.14-ReleaseNotes
+++ b/docs/v2.14-ReleaseNotes
@@ -14,6 +14,8 @@ Release highlights:
losetup(8) supports unlimited number of loop devices.
+ losetup(8) supports new command line option "--sizelimit" to set data end.
+
ldattach(8) command has been added to util-linux-ng. The ldattach
daemon opens the specified device file and attaches the line discipline
to it for processing of the sent and/or received data.
@@ -38,6 +40,19 @@ Release highlights:
losetup(8), mount(8), umount(8), fdisk(8) and sfdisk(8) support static
linking when compiled with --enable-static-programs.
+ hwclock(8) supports new command line option "adjfile" to override
+ the default /etc/adjtime.
+
+ scriptreplay(1) command has been re-written from Perl to C.
+
+
+Deprecated
+----------
+
+ The losetup(8) '-s' option (introduced by util-linux-ng-2.13) is deprecated.
+ This short form of the option '--show' could be in collision with Loop-AES
+ losetup implementation where the same option is used for the loop sizelimit.
+
ChangeLog between v2.13 and v2.14
---------------------------------
diff --git a/fdisk/.gitignore b/fdisk/.gitignore
new file mode 100644
index 00000000..c20d140e
--- /dev/null
+++ b/fdisk/.gitignore
@@ -0,0 +1,3 @@
+cfdisk
+fdisk
+sfdisk
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index ede41b3e..58b8bbde 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1519,8 +1519,8 @@ change_sysid(void) {
printf (_("Changed system type of partition %d "
"to %x (%s)\n"), i + 1, sys, temp);
else
- printf (_("System type of partition %d is unchanged "
- "to %x (%s)\n"), i + 1, sys, temp);
+ printf (_("System type of partition %d is unchanged: "
+ "%x (%s)\n"), i + 1, sys, temp);
if (is_dos_partition(origsys) ||
is_dos_partition(sys))
dos_changed = 1;
diff --git a/getopt/.gitignore b/getopt/.gitignore
new file mode 100644
index 00000000..d3e0b2dd
--- /dev/null
+++ b/getopt/.gitignore
@@ -0,0 +1 @@
+getopt
diff --git a/hwclock/.gitignore b/hwclock/.gitignore
new file mode 100644
index 00000000..97f59f33
--- /dev/null
+++ b/hwclock/.gitignore
@@ -0,0 +1 @@
+hwclock
diff --git a/lib/.gitignore b/lib/.gitignore
new file mode 100644
index 00000000..b3968c73
--- /dev/null
+++ b/lib/.gitignore
@@ -0,0 +1 @@
+test_blkdev
diff --git a/login-utils/.gitignore b/login-utils/.gitignore
new file mode 100644
index 00000000..584a0d00
--- /dev/null
+++ b/login-utils/.gitignore
@@ -0,0 +1,9 @@
+checktty_test
+islocal_test
+agetty
+wall
+chfn
+chsh
+login
+newgrp
+vipw
diff --git a/login-utils/Makefile.am b/login-utils/Makefile.am
index 8f5dc894..a660dacb 100644
--- a/login-utils/Makefile.am
+++ b/login-utils/Makefile.am
@@ -130,7 +130,12 @@ install-exec-hook::
endif
-noinst_PROGRAMS = checktty_test
+noinst_PROGRAMS = checktty_test islocal_test
checktty_test_SOURCES = checktty.c login.h
checktty_test_CPPFLAGS = -DMAIN_TEST_CHECKTTY $(AM_CPPFLAGS)
+islocal_test_SOURCES = islocal.c
+islocal_test_CPPFLAGS = -DMAIN_TEST_ISLOCAL $(AM_CPPFLAGS)
+check-local: islocal_test$(EXEEXT) checktty_test$(EXEEXT)
+ ./islocal_test$(EXEEXT)
+ ./checktty_test$(EXEEXT)
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
index a08713b2..ee0dc312 100644
--- a/login-utils/chfn.c
+++ b/login-utils/chfn.c
@@ -186,8 +186,8 @@ int main (int argc, char **argv) {
retcode = pam_start("chfn", oldf.username, &conv, &pamh);
if(retcode != PAM_SUCCESS) {
- fprintf(stderr, _("chfn: PAM Failure, aborting: %s\n"),
- pam_strerror(pamh, retcode));
+ fprintf(stderr, _("%s: PAM failure, aborting: %s\n"),
+ whoami, pam_strerror(pamh, retcode));
exit(1);
}
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index 58cbbb06..d4cc5267 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -185,8 +185,8 @@ main (int argc, char *argv[]) {
retcode = pam_start("chsh", pw->pw_name, &conv, &pamh);
if(retcode != PAM_SUCCESS) {
- fprintf(stderr, _("chsh: PAM Failure, aborting: %s\n"),
- pam_strerror(pamh, retcode));
+ fprintf(stderr, _("%s: PAM failure, aborting: %s\n"),
+ whoami, pam_strerror(pamh, retcode));
exit(1);
}
diff --git a/login-utils/islocal.c b/login-utils/islocal.c
index 29769804..762a4e99 100644
--- a/login-utils/islocal.c
+++ b/login-utils/islocal.c
@@ -12,7 +12,10 @@
1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
- added Native Language Support
-
+
+ 2008-04-06 James Youngman, jay@gnu.org
+ - Completely rewritten to remove assumption that /etc/passwd
+ lines are < 1024 characters long. Also added unit tests.
*/
@@ -24,29 +27,89 @@
#include "pathnames.h"
#include "islocal.h"
-#define MAX_LENGTH 1024
-
-int
-is_local(char *user)
+static int
+is_local_in_file(const char *user, const char *filename)
{
- FILE *fd;
- char line[MAX_LENGTH];
int local = 0;
- size_t len;
-
- if(!(fd = fopen(_PATH_PASSWD, "r"))) {
- fprintf(stderr,_("Can't read %s, exiting."),_PATH_PASSWD);
- exit(1);
- }
-
- len = strlen(user);
- while(fgets(line, MAX_LENGTH, fd)) {
- if(!strncmp(line, user, len) && line[len] == ':') {
- local = 1;
- break;
- }
+ size_t match;
+ int chin, skip;
+ FILE *f;
+
+ if (NULL == (f=fopen(filename, "r")))
+ return -1;
+
+ match = 0u;
+ skip = 0;
+ while ((chin = getc(f)) != EOF) {
+ if (skip) {
+ /* Looking for the start of the next line. */
+ if ('\n' == chin) {
+ /* Start matching username at the next char. */
+ skip = 0;
+ match = 0u;
+ }
+ } else {
+ if (':' == chin) {
+ if (0 == user[match]) {
+ local = 1; /* Success. */
+ /* next line has no test coverage, but it is
+ * just an optimisation anyway. */
+ break;
+ } else {
+ /* we read a whole username, but it is
+ * the wrong user. Skip to the next
+ * line. */
+ skip = 1;
+ }
+ } else if ('\n' == chin) {
+ /* This line contains no colon; it's malformed.
+ * No skip since we are already at the start of
+ * the next line. */
+ match = 0u;
+ } else if (chin != user[match]) {
+ /* username does not match. */
+ skip = 1;
+ } else {
+ ++match;
+ }
+ }
}
- fclose(fd);
+ fclose(f);
return local;
}
+int
+is_local(const char *user)
+{
+ int rv;
+ if ((rv = is_local_in_file(user, _PATH_PASSWD)) < 0) {
+ perror(_PATH_PASSWD);
+ fprintf(stderr, _("Failed to open %s for reading, exiting."),
+ _PATH_PASSWD);
+ exit(1);
+ } else {
+ return rv;
+ }
+}
+
+#if MAIN_TEST_ISLOCAL
+int
+main (int argc, char *argv[])
+{
+ if (argc < 2) {
+ fprintf(stderr, "No test passwd file was specified.\n");
+ return 1;
+ } else {
+ int i;
+ for (i = 2; i < argc; i++) {
+ const int rv = is_local_in_file(argv[i], argv[1]);
+ if (rv < 0) {
+ perror(argv[1]);
+ return 2;
+ }
+ printf("%d:%s\n", rv, argv[i]);
+ }
+ return 0;
+ }
+}
+#endif
diff --git a/login-utils/islocal.h b/login-utils/islocal.h
index 305bc57c..2c587990 100644
--- a/login-utils/islocal.h
+++ b/login-utils/islocal.h
@@ -1 +1 @@
-extern int is_local(char *user);
+extern int is_local(const char *user);
diff --git a/login-utils/login.c b/login-utils/login.c
index 0e6db2b5..aad27794 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -548,8 +548,8 @@ main(int argc, char **argv)
retcode = pam_start("login",username, &conv, &pamh);
if(retcode != PAM_SUCCESS) {
- fprintf(stderr, _("login: PAM Failure, aborting: %s\n"),
- pam_strerror(pamh, retcode));
+ fprintf(stderr, _("%s: PAM failure, aborting: %s\n"),
+ "login", pam_strerror(pamh, retcode));
syslog(LOG_ERR, _("Couldn't initialize PAM: %s"),
pam_strerror(pamh, retcode));
exit(99);
diff --git a/misc-utils/.gitignore b/misc-utils/.gitignore
index ac89c1fa..122b1920 100644
--- a/misc-utils/.gitignore
+++ b/misc-utils/.gitignore
@@ -1,2 +1,14 @@
chkdupexe
scriptreplay
+cal
+ddate
+logger
+look
+mcookie
+namei
+rename
+script
+setterm
+whereis
+kill
+write
diff --git a/misc-utils/Makefile.am b/misc-utils/Makefile.am
index 5441b015..40610c14 100644
--- a/misc-utils/Makefile.am
+++ b/misc-utils/Makefile.am
@@ -5,14 +5,14 @@ EXTRA_DIST = README.flushb
bin_PROGRAMS =
usrbinexec_PROGRAMS = cal ddate logger look mcookie \
- namei script whereis
+ namei script whereis scriptreplay
EXTRA_DIST += README.cal README.ddate README.namei README.namei2
mcookie_SOURCES = mcookie.c ../lib/md5.c
-usrbinexec_SCRIPTS = chkdupexe scriptreplay
+usrbinexec_SCRIPTS = chkdupexe
-CLEANFILES = chkdupexe scriptreplay
+CLEANFILES = chkdupexe
dist_man_MANS = cal.1 chkdupexe.1 ddate.1 logger.1 look.1 mcookie.1 \
namei.1 script.1 whereis.1 scriptreplay.1
diff --git a/misc-utils/scriptreplay.1 b/misc-utils/scriptreplay.1
index 98129fb4..b2a03a24 100644
--- a/misc-utils/scriptreplay.1
+++ b/misc-utils/scriptreplay.1
@@ -149,8 +149,18 @@ scriptreplay timingfile [typescript [divisor]]
.IX Header "DESCRIPTION"
This program replays a typescript, using timing information to ensure that
output happens at the same speed as it originally appeared when the script
-was recorded. It is only guaranteed to work properly if run on the same
-terminal the script was recorded on.
+was recorded.
+.PP
+The replay simply displays the information again; the programs
+that were run when the typescript was being recorded are not run again.
+Since the same information is simply being displayed,
+.B scriptreplay
+is only guaranteed to work properly if run on the same type of
+terminal the typescript was recorded on. Otherwise, any escape characters
+in the typescript may be interpreted differently by the terminal to
+which
+.B scriptreplay
+is sending its output.
.PP
The timings information is what script outputs to standard error if it is
run with the \-t parameter.
@@ -158,8 +168,11 @@ run with the \-t parameter.
By default, the typescript to display is assumed to be named \*(L"typescript\*(R",
but other filenames may be specified, as the second parameter.
.PP
-If the third parameter exits, it is used as a time divisor. For example,
-specifying a divisor of 2 makes the script be replayed twice as fast.
+If the third parameter is specified, it is used as a speed-up multiplier. For
+example, a speed-up of 2 makes
+.B scriptreplay
+go twice as fast and a speed-up of 0.1 makes it go ten times slower
+than the original session.
.SH "EXAMPLE"
.IX Header "EXAMPLE"
.Vb 7
@@ -176,10 +189,23 @@ specifying a divisor of 2 makes the script be replayed twice as fast.
.BR script (1)
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
-This program is in the public domain.
+Copyright \(co 2008 James Youngman
+.PP
+Copyright \(co 2008 Karel Zak
+.PP
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.
+.PP
+Released under the GNU General Public License version 2 or later.
.SH "AUTHOR"
.IX Header "AUTHOR"
-Joey Hess <joey@kitenet.net>
+The original
+.B scriptreplay
+program was written by Joey Hess <joey@kitenet.net>.
+The program was re-written in C by James Youngman <jay@gnu.org> and Karel Zak <kzak@redhat.com>.
.SH AVAILABILITY
-The scriptreplay command is part of the util-linux-ng package and is available from
+The
+.B scriptreplay
+command is part of the util-linux-ng package and is available from
ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
diff --git a/misc-utils/scriptreplay.c b/misc-utils/scriptreplay.c
new file mode 100644
index 00000000..2ae31a2a
--- /dev/null
+++ b/misc-utils/scriptreplay.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2008, Karel Zak <kzak@redhat.com>
+ * Copyright (C) 2008, James Youngman <jay@gnu.org>
+ *
+ * This file 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 file is distributed in the hope that it will 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.
+ *
+ *
+ * Based on scriptreplay.pl by Joey Hess <joey@kitenet.net>
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <limits.h>
+#include <math.h>
+#include <sys/select.h>
+#include <unistd.h>
+#include <err.h>
+
+#include "nls.h"
+
+#define SCRIPT_MIN_DELAY 0.0001 /* from original sripreplay.pl */
+
+void __attribute__((__noreturn__))
+usage(int rc)
+{
+ printf("%s <timingfile> [<typescript> [<divisor>]]\n",
+ program_invocation_short_name);
+ exit(rc);
+}
+
+static double
+getnum(const char *s)
+{
+ double d;
+ char *end;
+
+ errno = 0;
+ d = strtod(s, &end);
+
+ if (end && *end != '\0')
+ errx(EXIT_FAILURE, _("expected a number, but got '%s'"), s);
+
+ if ((d == HUGE_VAL || d == -HUGE_VAL) && ERANGE == errno)
+ err(EXIT_FAILURE, _("divisor '%s'"), s);
+
+ if (!(d==d)) { /* did they specify "nan"? */
+ errno = EINVAL;
+ err(EXIT_FAILURE, _("divisor '%s'"), s);
+ }
+ return d;
+}
+
+static void
+delay_for(double delay)
+{
+#ifdef HAVE_NANOSLEEP
+ struct timespec ts, remainder;
+ ts.tv_sec = (time_t) delay;
+ ts.tv_nsec = (delay - ts.tv_sec) * 1.0e9;
+
+ while (-1 == nanosleep(&ts, &remainder)) {
+ if (EINTR == errno)
+ ts = remainder;
+ else
+ break;
+ }
+#else
+ struct timeval tv;
+ tv.tv_sec = (long) delay;
+ tv.tv_usec = (delay - tv.tv_sec) * 1.0e6;
+ select(0, NULL, NULL, NULL, &tv);
+#endif
+}
+
+static void
+emit(FILE *fd, const char *filename, size_t ct)
+{
+ char buf[BUFSIZ];
+
+ while(ct) {
+ size_t len, cc;
+
+ cc = ct > sizeof(buf) ? sizeof(buf) : ct;
+ len = fread(buf, 1, cc, fd);
+
+ if (!len)
+ break;
+
+ ct -= len;
+ cc = write(STDOUT_FILENO, buf, len);
+ if (cc != len)
+ err(EXIT_FAILURE, "write to stdout failed");
+ }
+
+ if (!ct)
+ return;
+ if (feof(fd))
+ errx(EXIT_FAILURE, _("unexpected end of file on %s"), filename);
+
+ err(EXIT_FAILURE, _("failed to read typescript file %s"), filename);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ FILE *tfile, *sfile;
+ const char *sname, *tname;
+ double divi;
+ int c;
+ unsigned long line;
+
+ /* Because we use space as a separator, we can't afford to use any
+ * locale which tolerates a space in a number. In any case, script.c
+ * sets the LC_NUMERIC locale to C, anyway.
+ */
+ setlocale(LC_ALL, "");
+ setlocale(LC_NUMERIC, "C");
+
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ if (argc < 2 && argc > 4)
+ usage(EXIT_FAILURE);
+
+ tname = argv[1];
+ sname = argc > 2 ? argv[2] : "typescript";
+ divi = argc == 4 ? getnum(argv[3]) : 1;
+
+ tfile = fopen(tname, "r");
+ if (!tfile)
+ err(EXIT_FAILURE, _("cannot open timing file %s"), tname);
+ sfile = fopen(sname, "r");
+ if (!sfile)
+ err(EXIT_FAILURE, _("cannot open typescript file %s"), sname);
+
+ /* ignore the first typescript line */
+ while((c = fgetc(sfile)) != EOF && c != '\n');
+
+ for(line = 0; ; line++) {
+ double delay;
+ size_t blk;
+ char nl;
+
+ if ((fscanf(tfile, "%lf %zd%[\n]\n", &delay, &blk, &nl) != 3) ||
+ (nl != '\n')) {
+ if (feof(tfile))
+ break;
+ if (ferror(tfile))
+ err(EXIT_FAILURE,
+ "failed to read timing file %s", tname);
+ errx(EXIT_FAILURE,
+ _("timings file %s: %lu: expected format"),
+ tname, line);
+ }
+ delay /= divi;
+
+ if (delay > SCRIPT_MIN_DELAY)
+ delay_for(delay);
+
+ emit(sfile, sname, blk);
+ }
+
+ fclose(sfile);
+ fclose(tfile);
+ exit(EXIT_SUCCESS);
+}
diff --git a/misc-utils/scriptreplay.pl b/misc-utils/scriptreplay.pl
deleted file mode 100755
index b445f6d6..00000000
--- a/misc-utils/scriptreplay.pl
+++ /dev/null
@@ -1,83 +0,0 @@
-#!@PERL@ -w
-
-# "script -t" will output a typescript with timings
-# this script "scriptreplay" replays it
-# run pod2man on it to get a man page
-
-=head1 NAME
-
-scriptreplay - play back typescripts, using timing information
-
-=head1 SYNOPSIS
-
-scriptreplay timingfile [typescript [divisor]]
-
-=head1 DESCRIPTION
-
-This program replays a typescript, using timing information to ensure that
-output happens at the same speed as it originally appeared when the script
-was recorded. It is only guaranteed to work properly if run on the same
-terminal the script was recorded on.
-
-The timings information is what script outputs to standard error if it is
-run with the -t parameter.
-
-By default, the typescript to display is assumed to be named "typescript",
-but other filenames may be specified, as the second parameter.
-
-If the third parameter exits, it is used as a time divisor. For example,
-specifying a divisor of 2 makes the script be replayed twice as fast.
-
-=head1 EXAMPLE
-
- % script -t 2> timingfile
- Script started, file is typescript
- % ls
- <etc, etc>
- % exit
- Script done, file is typescript
- % scriptreplay timingfile
-
-=cut
-
-use strict;
-$|=1;
-open (TIMING, shift)
- or die "cannot read timing info: $!";
-open (TYPESCRIPT, shift || 'typescript')
- or die "cannot read typescript: $!";
-my $divisor=shift || 1;
-
-# Read starting timestamp line and ignore.
-<TYPESCRIPT>;
-
-my $block;
-my $oldblock='';
-while (<TIMING>) {
- my ($delay, $blocksize)=split ' ', $_, 2;
- # Sleep, unless the delay is really tiny. Really tiny delays cannot
- # be accurately done, because the system calls in this loop will
- # have more overhead. The 0.0001 is arbitrary, but works fairly well.
- if ($delay / $divisor > 0.0001) {
- select(undef, undef, undef, $delay / $divisor - 0.0001);
- }
-
- read(TYPESCRIPT, $block, $blocksize)
- or die "read failure on typescript: $!";
- print $oldblock;
- $oldblock=$block;
-}
-print $oldblock;
-
-=head1 SEE ALSO
-
-script(1)
-
-=head1 COPYRIGHT
-
-This program is in the public domain.
-
-=head1 AUTHOR
-
-Joey Hess <joey@kitenet.net>
-
diff --git a/mount/.gitignore b/mount/.gitignore
new file mode 100644
index 00000000..6de7afca
--- /dev/null
+++ b/mount/.gitignore
@@ -0,0 +1,6 @@
+losetup
+mount
+mtab_lock_test
+pivot_root
+swapon
+umount
diff --git a/mount/lomount.c b/mount/lomount.c
index 04b0f279..e6b7f247 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -610,7 +610,8 @@ digits_only(const char *s) {
int
set_loop(const char *device, const char *file, unsigned long long offset,
- const char *encryption, int pfd, int *options, int keysz, int hash_pass) {
+ unsigned long long sizelimit, const char *encryption, int pfd, int *options,
+ int keysz, int hash_pass) {
struct loop_info64 loopinfo64;
int fd, ffd, mode, i;
char *pass;
@@ -658,6 +659,7 @@ set_loop(const char *device, const char *file, unsigned long long offset,
}
loopinfo64.lo_offset = offset;
+ loopinfo64.lo_sizelimit = sizelimit;
#ifdef MCL_FUTURE
/*
@@ -826,8 +828,8 @@ set_loop(const char *device, const char *file, unsigned long long offset,
close (fd);
if (verbose > 1)
- printf(_("set_loop(%s,%s,%llu): success\n"),
- device, filename, offset);
+ printf(_("set_loop(%s,%s,%llu,%llu): success\n"),
+ device, filename, offset, sizelimit);
if (file != filename)
free(filename);
return 0;
@@ -863,8 +865,9 @@ mutter(void) {
}
int
-set_loop (const char *device, const char *file, unsigned long long offset,
- const char *encryption, int pfd, int *options, int keysz, int hash_pass) {
+set_loop(const char *device, const char *file, unsigned long long offset,
+ unsigned long long sizelimit, const char *encryption, int pfd, int *options,
+ int keysz, int hash_pass) {
mutter();
return 1;
}
@@ -898,28 +901,30 @@ usage(void) {
" %1$s -d | --detach <loopdev> delete\n"
" %1$s -f | --find find unused\n"
" %1$s -j | --associated <file> [-o <num>] list all associated with <file>\n"
- " %1$s [ options ] {-f|--find|loopdev} <file> setup\n"
- "\nOptions:\n"
+ " %1$s [ options ] {-f|--find|loopdev} <file> setup\n"),
+ progname);
+
+ fprintf(stderr, _("\nOptions:\n"
" -e | --encryption <type> enable data encryption with specified <name/num>\n"
" -h | --help this help\n"
" -o | --offset <num> start at offset <num> into file\n"
+ " --sizelimit <num> loop limited to only <num> bytes of the file\n"
" -p | --pass-fd <num> read passphrase from file descriptor <num>\n"
" -r | --read-only setup read-only loop device\n"
- " -s | --show print device name (with -f <file>)\n"
+ " --show print device name (with -f <file>)\n"
" -N | --nohashpass Do not hash the given password (Debian hashes)\n"
" -k | --keybits <num> specify number of bits in the hashed key given\n"
" to the cipher. Some ciphers support several key\n"
" sizes and might be more efficient with a smaller\n"
" key size. Key sizes < 128 are generally not\n"
" recommended\n"
- " -v | --verbose verbose mode\n\n"),
- progname);
+ " -v | --verbose verbose mode\n\n"));
exit(1);
}
int
main(int argc, char **argv) {
- char *p, *offset, *encryption, *passfd, *device, *file, *assoc;
+ char *p, *offset, *sizelimit, *encryption, *passfd, *device, *file, *assoc;
char *keysize;
int delete, find, c, all;
int res = 0;
@@ -928,7 +933,7 @@ main(int argc, char **argv) {
int pfd = -1;
int keysz = 0;
int hash_pass = 1;
- unsigned long long off;
+ unsigned long long off, slimit;
struct option longopts[] = {
{ "all", 0, 0, 'a' },
{ "detach", 0, 0, 'd' },
@@ -940,6 +945,7 @@ main(int argc, char **argv) {
{ "nohashpass", 0, 0, 'N' },
{ "associated", 1, 0, 'j' },
{ "offset", 1, 0, 'o' },
+ { "sizelimit", 1, 0, 128 },
{ "pass-fd", 1, 0, 'p' },
{ "read-only", 0, 0, 'r' },
{ "show", 0, 0, 's' },
@@ -953,7 +959,7 @@ main(int argc, char **argv) {
delete = find = all = 0;
off = 0;
- offset = encryption = passfd = NULL;
+ slimit = 0;
assoc = offset = encryption = passfd = NULL;
keysize = NULL;
@@ -1000,6 +1006,11 @@ main(int argc, char **argv) {
case 'v':
verbose = 1;
break;
+
+ case 128: /* --sizelimit */
+ sizelimit = optarg;
+ break;
+
default:
usage();
}
@@ -1008,7 +1019,7 @@ main(int argc, char **argv) {
if (argc == 1) {
usage();
} else if (delete) {
- if (argc != optind+1 || encryption || offset ||
+ if (argc != optind+1 || encryption || offset || sizelimit ||
find || all || showdev || assoc || ro)
usage();
} else if (find) {
@@ -1028,6 +1039,9 @@ main(int argc, char **argv) {
if (offset && sscanf(offset, "%llu", &off) != 1)
usage();
+ if (sizelimit && sscanf(sizelimit, "%llu", &slimit) != 1)
+ usage();
+
if (all)
return show_used_loop_devices();
else if (assoc)
@@ -1061,7 +1075,7 @@ main(int argc, char **argv) {
if (keysize && sscanf(keysize,"%d",&keysz) != 1)
usage();
do {
- res = set_loop(device, file, off, encryption, pfd, &ro, keysz, hash_pass);
+ res = set_loop(device, file, off, slimit, encryption, pfd, &ro, keysz, hash_pass);
if (res == 2 && find) {
if (verbose)
printf("stolen loop=%s...trying again\n",
diff --git a/mount/lomount.h b/mount/lomount.h
index 95f13988..7d548b5a 100644
--- a/mount/lomount.h
+++ b/mount/lomount.h
@@ -1,4 +1,4 @@
-extern int set_loop(const char *, const char *, unsigned long long,
+extern int set_loop(const char *, const char *, unsigned long long, unsigned long long,
const char *, int, int *, int, int);
extern int del_loop(const char *);
extern int is_loop_device(const char *);
diff --git a/mount/losetup.8 b/mount/losetup.8
index c90360c2..07b3a519 100644
--- a/mount/losetup.8
+++ b/mount/losetup.8
@@ -35,11 +35,13 @@ Setup loop device:
.IR encryption ]
.RB [ \-o
.IR offset ]
+.RB [ \-\-sizelimit
+.IR limit ]
.RB [ \-p
.IR pfd ]
.RB [ \-r ]
.in +8
-.RB { \-f [ \-s ] | \fIloop_device\fP }
+.RB { \-f [ \-\-show ] | \fIloop_device\fP }
.I file
.in -13
.ad b
@@ -89,18 +91,24 @@ hash function, non-Debian systems tend not to.
.IP "\fB\-o, \-\-offset \fIoffset\fP"
the data start is moved \fIoffset\fP bytes into the specified file or
device
+.IP "\fB\-\-sizelimit \fIlimit\fP"
+the data end is set to no more than \fIsizelimit\fP bytes after the data start
.IP "\fB\-p, \-\-pass-fd \fInum\fP"
read the passphrase from file descriptor with number
.I num
instead of from the terminal
.IP "\fB\-r, \-\-read-only\fP"
setup read-only loop device
-.IP "\fB\-s, \-\-show\fP"
+.IP "\fB\-\-show\fP"
print device name if the
.I -f
option and a
.I file
-argument are present
+argument are present.
+
+The short form of this option (\fB\-s\fP) is deprecated. This short form could
+be in collision with Loop-AES implementation where the same option is used for
+\fB\-\-sizelimit\fP.
.IP "\fB\-v, \-\-verbose\fP"
verbose mode
diff --git a/mount/mount.8 b/mount/mount.8
index ac0eeef7..10a39dfd 100644
--- a/mount/mount.8
+++ b/mount/mount.8
@@ -2015,8 +2015,8 @@ to correspond to the file
and then mount this device on
.IR /mnt .
-This type of mount knows about three options, namely
-.BR loop ", " offset " and " encryption ,
+This type of mount knows about four options, namely
+.BR loop ", " offset ", " sizelimit " and " encryption ,
that are really options to
.BR \%losetup (8).
If the mount requires a passphrase, you will be prompted for one unless
diff --git a/mount/mount.c b/mount/mount.c
index 182f36b6..62b89068 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -191,8 +191,8 @@ static const struct opt_map opt_map[] = {
static int opt_nofail = 0;
-static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption,
- *opt_speed, *opt_comment, *opt_uhelper;
+static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_sizelimit,
+ *opt_encryption, *opt_speed, *opt_comment, *opt_uhelper;
static const char *opt_keybits, *opt_nohashpass;
static int mounted (const char *spec0, const char *node0);
@@ -207,6 +207,7 @@ static struct string_opt_map {
{ "loop=", 0, &opt_loopdev },
{ "vfs=", 1, &opt_vfstype },
{ "offset=", 0, &opt_offset },
+ { "sizelimit=", 0, &opt_sizelimit },
{ "encryption=", 0, &opt_encryption },
{ "keybits=", 0, &opt_keybits },
{ "nohashpass", 0, &opt_nohashpass },
@@ -884,7 +885,7 @@ loop_check(const char **spec, const char **type, int *flags,
int *loop, const char **loopdev, const char **loopfile,
const char *node) {
int looptype;
- unsigned long long offset;
+ unsigned long long offset, sizelimit;
/*
* In the case of a loop mount, either type is of the form lo@/dev/loop5
@@ -909,7 +910,7 @@ loop_check(const char **spec, const char **type, int *flags,
*type = opt_vfstype;
}
- *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_encryption || opt_keybits);
+ *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_sizelimit || opt_encryption || opt_keybits);
*loopfile = *spec;
if (*loop) {
@@ -925,6 +926,7 @@ loop_check(const char **spec, const char **type, int *flags,
loop_opts |= SETLOOP_RDONLY;
offset = opt_offset ? strtoull(opt_offset, NULL, 0) : 0;
+ sizelimit = opt_sizelimit ? strtoull(opt_sizelimit, NULL, 0) : 0;
if (is_mounted_same_loopfile(node, *loopfile, offset)) {
error(_("mount: according to mtab %s is already mounted on %s as loop"), *loopfile, node);
@@ -942,7 +944,7 @@ loop_check(const char **spec, const char **type, int *flags,
keysz = strtoul(opt_keybits, NULL, 0);
if (opt_nohashpass)
hash_pass=0;
- if ((res = set_loop(*loopdev, *loopfile, offset,
+ if ((res = set_loop(*loopdev, *loopfile, offset, sizelimit,
opt_encryption, pfd, &loop_opts, keysz, hash_pass))) {
if (res == 2) {
/* loop dev has been grabbed by some other process,
diff --git a/mount/swapon.c b/mount/swapon.c
index 23c92e44..fff48e6f 100644
--- a/mount/swapon.c
+++ b/mount/swapon.c
@@ -177,7 +177,16 @@ static int
swap_is_suspend(const char *device) {
const char *type = fsprobe_get_fstype_by_devname(device);
- return (type && strcmp(type, "suspend") == 0) ? 1 : 0;
+ /* S1SUSPEND/S2SUSPEND =
+ *
+ * "swsuspend" in libblkid
+ * "suspend" in libvolume_id
+ */
+ if (type && (strcmp(type, "suspend") == 0 ||
+ strcmp(type, "swsuspend") == 0))
+ return 1;
+
+ return 0;
}
/* calls mkswap */
diff --git a/partx/.gitignore b/partx/.gitignore
new file mode 100644
index 00000000..9767d23d
--- /dev/null
+++ b/partx/.gitignore
@@ -0,0 +1,3 @@
+addpart
+delpart
+partx
diff --git a/schedutils/.gitignore b/schedutils/.gitignore
new file mode 100644
index 00000000..9c325874
--- /dev/null
+++ b/schedutils/.gitignore
@@ -0,0 +1,3 @@
+chrt
+ionice
+taskset
diff --git a/sys-utils/.gitignore b/sys-utils/.gitignore
new file mode 100644
index 00000000..32346b49
--- /dev/null
+++ b/sys-utils/.gitignore
@@ -0,0 +1,38 @@
+ctrlaltdel
+cytune
+dmesg
+flock
+ipcrm
+ipcs
+ldattach
+readprofile
+renice
+rtcwake
+setarch
+setsid
+tunelp
+arch
+vidmode.8
+ramsize.8
+rdev
+i386.8
+ia64.8
+linux32.8
+linux64.8
+mips32.8
+mips64.8
+mips.8
+parisc32.8
+parisc64.8
+parisc.8
+ppc32.8
+ppc64.8
+ppc.8
+rootflags.8
+s390.8
+s390x.8
+sparc32.8
+sparc32bash.8
+sparc64.8
+sparc.8
+x86_64.8
diff --git a/tests/.gitignore b/tests/.gitignore
index 4a7be8c8..c22f5081 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1 +1,3 @@
commands.sh
+diff
+output
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 67bd5685..827b8493 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,6 +28,7 @@ EXTRA_DIST = expected \
ts-ipcs-limits2 \
ts-ipcs.sh \
ts-login-checktty \
+ ts-login-islocal \
ts-look-separator \
ts-mount-noncanonical \
ts-mount-devname \
diff --git a/tests/commands.sh.in b/tests/commands.sh.in
index 6035547a..c363aac9 100644
--- a/tests/commands.sh.in
+++ b/tests/commands.sh.in
@@ -36,6 +36,7 @@ TS_CMD_CAL=${TS_CMD_CAL-"$TOPDIR/misc-utils/cal"}
TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"$TOPDIR/misc-utils/script"}
TS_CMD_CHECKTTY=${TS_CMD_CHECKTTY-"$TOPDIR/login-utils/checktty_test"}
+TS_CMD_ISLOCAL=${TS_CMD_ISLOCAL-"$TOPDIR/login-utils/islocal_test"}
TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"$TOPDIR/hwclock/hwclock"}
diff --git a/tests/expected/ts-login-islocal b/tests/expected/ts-login-islocal
new file mode 100644
index 00000000..c5d43ff5
--- /dev/null
+++ b/tests/expected/ts-login-islocal
@@ -0,0 +1,13 @@
+1:root
+1:nobody
+0:
+0:youngman
+0:youngman2
+0:abcdefghx
+0:nobo
+1:long
+0:rot
+1:al
+0:malformed
+1:nonl
+0:znobody
diff --git a/tests/helpers/.gitignore b/tests/helpers/.gitignore
new file mode 100644
index 00000000..de086d53
--- /dev/null
+++ b/tests/helpers/.gitignore
@@ -0,0 +1,2 @@
+test_pathnames
+test_sysinfo
diff --git a/tests/input/ts-login-islocal b/tests/input/ts-login-islocal
new file mode 100644
index 00000000..916a8a9b
--- /dev/null
+++ b/tests/input/ts-login-islocal
@@ -0,0 +1,10 @@
+root:x:0:0:root:/root:/bin/bash
+sys:x:3:3:sys:/dev:/bin/sh
+orac:x:33:33:sys:/dev:/bin/youngman
+long:x:4:4:foo:/home/loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooonnnggg:/bin/sh
+al:x:5:5:fnord:/dev:/bin/sh
+abcdefgh:x:6:3:fnord:/dev:/bin/sh
+malformed
+
+nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
+nonl:x:65532:65532:no newline:/:/bin/false
diff --git a/tests/ts-login-islocal b/tests/ts-login-islocal
new file mode 100755
index 00000000..0c8d7798
--- /dev/null
+++ b/tests/ts-login-islocal
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2008 James Youngman <jay@gnu.org>
+#
+# This file is part of util-linux-ng.
+#
+# This file 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 file is distributed in the hope that it will 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.
+#
+. ./commands.sh
+. ./functions.sh
+
+TS_COMPONENT="login"
+TS_DESC="islocal"
+
+ts_init "$*"
+$TS_CMD_ISLOCAL "$TS_INPUT" root nobody "" youngman youngman2 \
+ abcdefghx nobo long rot al malformed \
+ nonl znobody >> $TS_OUTPUT
+ts_finalize
diff --git a/text-utils/.gitignore b/text-utils/.gitignore
new file mode 100644
index 00000000..09096a69
--- /dev/null
+++ b/text-utils/.gitignore
@@ -0,0 +1,11 @@
+col
+colcrt
+column
+hexdump
+line
+more
+pg
+rev
+tailf
+ul
+colrm