1
0
forked from pool/util-linux
util-linux/HEAD.patch

472 lines
13 KiB
Diff
Raw Normal View History

diff --git a/disk-utils/raw.c b/disk-utils/raw.c
index bc64b34..f634b60 100644
--- a/disk-utils/raw.c
+++ b/disk-utils/raw.c
@@ -40,11 +40,11 @@ int master_fd;
int raw_minor;
void open_raw_ctl(void);
-int query(int minor, int quiet);
+int query(int minor, const char *raw_name, int quiet);
int bind (int minor, int block_major, int block_minor);
-static void usage(int err)
+static void usage(int err)
{
fprintf(stderr,
_("Usage:\n"
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
if (optind < argc)
usage(1);
for (i = 1; i < RAW_NR_MINORS; i++)
- query(i, 1);
+ query(i, NULL, 1);
exit(0);
}
@@ -117,7 +117,10 @@ int main(int argc, char *argv[])
* causes udev to *remove* /dev/rawctl
*/
rc = sscanf(raw_name, RAWDEVDIR "raw%d", &raw_minor);
- if (rc == 1 && raw_minor == 0) {
+ if (rc != 1)
+ usage(1);
+
+ if (raw_minor == 0) {
fprintf (stderr,
_("Device '%s' is control raw dev "
"(use raw<N> where <N> is greater than zero)\n"),
@@ -125,28 +128,8 @@ int main(int argc, char *argv[])
exit(2);
}
- err = stat(raw_name, &statbuf);
- if (err) {
- fprintf (stderr, _("Cannot locate raw device '%s' (%s)\n"),
- raw_name, strerror(errno));
- exit(2);
- }
-
- if (!S_ISCHR(statbuf.st_mode)) {
- fprintf (stderr, _("Raw device '%s' is not a character dev\n"),
- raw_name);
- exit(2);
- }
- if (major(statbuf.st_rdev) != RAW_MAJOR) {
- fprintf (stderr, _("Device '%s' is not a raw dev\n"),
- raw_name);
- exit(2);
- }
-
- raw_minor = minor(statbuf.st_rdev);
-
if (do_query)
- return query(raw_minor, 0);
+ return query(raw_minor, raw_name, 0);
/*
* It's not a query, so we still have some parsing to do. Have
@@ -208,12 +191,35 @@ void open_raw_ctl(void)
}
}
-int query(int minor, int quiet)
+int query(int minor, const char *raw_name, int quiet)
{
struct raw_config_request rq;
static int has_worked = 0;
int err;
+ if (raw_name) {
+ struct stat statbuf;
+
+ err = stat(raw_name, &statbuf);
+ if (err) {
+ fprintf (stderr, _("Cannot locate raw device '%s' (%s)\n"),
+ raw_name, strerror(errno));
+ exit(2);
+ }
+
+ if (!S_ISCHR(statbuf.st_mode)) {
+ fprintf (stderr, _("Raw device '%s' is not a character dev\n"),
+ raw_name);
+ exit(2);
+ }
+ if (major(statbuf.st_rdev) != RAW_MAJOR) {
+ fprintf (stderr, _("Device '%s' is not a raw dev\n"),
+ raw_name);
+ exit(2);
+ }
+ minor = minor(statbuf.st_rdev);
+ }
+
rq.raw_minor = minor;
err = ioctl(master_fd, RAW_GETBIND, &rq);
if (err < 0) {
diff --git a/include/pathnames.h b/include/pathnames.h
index 0060a75..12170f9 100644
--- a/include/pathnames.h
+++ b/include/pathnames.h
@@ -19,7 +19,6 @@
#undef _PATH_DEFPATH_ROOT
#define _PATH_DEFPATH_ROOT "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
-#define _PATH_TTY "/dev/tty"
#define _PATH_SECURETTY "/etc/securetty"
#define _PATH_WTMPLOCK "/etc/wtmplock"
@@ -94,6 +93,13 @@
#define _PATH_MOUNTED_LOCK _PATH_MOUNTED "~"
#define _PATH_MOUNTED_TMP _PATH_MOUNTED ".tmp"
+#ifndef _PATH_DEV
+# define _PATH_DEV "/dev"
+#endif
+
+#define _PATH_DEV_LOOP "/dev/loop"
+#define _PATH_DEV_TTY "/dev/tty"
+
/* udev paths */
#define _PATH_DEV_BYLABEL "/dev/disk/by-label"
#define _PATH_DEV_BYUUID "/dev/disk/by-uuid"
diff --git a/login-utils/login.c b/login-utils/login.c
index f315425..7328ede 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -378,7 +378,7 @@ main(int argc, char **argv)
int ask, fflag, hflag, pflag, cnt, errsv;
int quietlog, passwd_req;
char *domain, *ttyn;
- char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
+ char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_DEV_TTY) + 10];
char *termenv;
char *childArgv[10];
char *buff;
@@ -499,7 +499,7 @@ main(int argc, char **argv)
if (ttyn == NULL || *ttyn == '\0') {
/* no snprintf required - see definition of tname */
- sprintf(tname, "%s??", _PATH_TTY);
+ snprintf(tname, sizeof(tname), "%s??", _PATH_DEV_TTY);
ttyn = tname;
}
diff --git a/misc-utils/script.c b/misc-utils/script.c
index 12ea43a..b877c31 100644
--- a/misc-utils/script.c
+++ b/misc-utils/script.c
@@ -371,7 +371,7 @@ doshell() {
#if 0
int t;
- t = open(_PATH_TTY, O_RDWR);
+ t = open(_PATH_DEV_TTY, O_RDWR);
if (t >= 0) {
(void) ioctl(t, TIOCNOTTY, (char *)0);
(void) close(t);
diff --git a/misc-utils/uuidd.8 b/misc-utils/uuidd.8
index ae033ea..67c6614 100644
--- a/misc-utils/uuidd.8
+++ b/misc-utils/uuidd.8
@@ -64,11 +64,11 @@ UUID's.
.TP
.BI \-p " pidfile"
Specify the pathname where the pid file should be written. By default,
-the pid file is written to /var/lib/libuuid/uuidd.pid.
+the pid file is written to /var/run/uuidd/uuidd.pid.
.TP
.BI \-s " socketpath"
Specify the pathname used for the unix-domain socket used by uuidd. By
-default, the pathname used is /var/lib/libuuid/request. This is primarily
+default, the pathname used is /var/run/uuidd/request. This is primarily
for debugging purposes, since the pathname is hard-coded in the libuuid
library.
.TP
diff --git a/mount/lomount.c b/mount/lomount.c
index 1b191ab..c6e0c92 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -60,8 +60,6 @@ loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info)
return 0;
}
-#define DEV_LOOP_PATH "/dev/loop"
-#define DEV_PATH "/dev"
#define LOOPMAJOR 7
#define NLOOPS_DEFAULT 8 /* /dev/loop[0-7] */
@@ -143,10 +141,10 @@ looplist_open(struct looplist *ll, int flag)
ll->flag = flag;
ll->ncur = -1;
- if (stat(DEV_PATH, &st) == -1 || (!S_ISDIR(st.st_mode)))
+ if (stat(_PATH_DEV, &st) == -1 || (!S_ISDIR(st.st_mode)))
return -1; /* /dev doesn't exist */
- if (stat(DEV_LOOP_PATH, &st) == 0 && S_ISDIR(st.st_mode))
+ if (stat(_PATH_DEV_LOOP, &st) == 0 && S_ISDIR(st.st_mode))
ll->flag |= LLFLG_SUBDIR; /* /dev/loop/ exists */
if ((ll->flag & LLFLG_USEDONLY) &&
@@ -179,8 +177,8 @@ looplist_open_dev(struct looplist *ll, int lnum)
/* create a full device path */
snprintf(ll->name, sizeof(ll->name),
ll->flag & LLFLG_SUBDIR ?
- DEV_LOOP_PATH "/%d" :
- DEV_PATH "/loop%d",
+ _PATH_DEV_LOOP "/%d" :
+ _PATH_DEV "/loop%d",
lnum);
fd = open(ll->name, O_RDONLY);
@@ -331,8 +329,8 @@ looplist_next(struct looplist *ll)
*/
if (!ll->minors) {
ll->nminors = (ll->flag & LLFLG_SUBDIR) ?
- loop_scandir(DEV_LOOP_PATH, &ll->minors, 0) :
- loop_scandir(DEV_PATH, &ll->minors, 1);
+ loop_scandir(_PATH_DEV_LOOP, &ll->minors, 0) :
+ loop_scandir(_PATH_DEV, &ll->minors, 1);
ll->ncur = -1;
}
for (++ll->ncur; ll->ncur < ll->nminors; ll->ncur++) {
@@ -500,8 +498,7 @@ show_associated_loop_devices(char *filename, unsigned long long offset, int isof
/* check if the loopfile is already associated with the same given
* parameters.
*
- * returns: -1 error
- * 0 unused
+ * returns: 0 unused / error
* 1 loop device already used
*/
static int
@@ -516,17 +513,15 @@ is_associated(int dev, struct stat *file, unsigned long long offset, int isoff)
file->st_ino == linfo64.lo_inode &&
(isoff == 0 || offset == linfo64.lo_offset))
ret = 1;
- return ret;
- }
- if (ioctl(dev, LOOP_GET_STATUS, &linfo) == 0) {
+
+ } else if (ioctl(dev, LOOP_GET_STATUS, &linfo) == 0) {
if (file->st_dev == linfo.lo_device &&
file->st_ino == linfo.lo_inode &&
(isoff == 0 || offset == linfo.lo_offset))
ret = 1;
- return ret;
}
- return errno == ENXIO ? 0 : -1;
+ return ret;
}
/* check if the loop file is already used with the same given
@@ -572,18 +567,14 @@ loopfile_used_with(char *devname, const char *filename, unsigned long long offse
if (!is_loop_device(devname))
return 0;
- if (stat(filename, &statbuf) == -1) {
- perror(filename);
- return -1;
- }
+ if (stat(filename, &statbuf) == -1)
+ return 0;
fd = open(devname, O_RDONLY);
- if (fd == -1) {
- perror(devname);
- return -1;
- }
- ret = is_associated(fd, &statbuf, offset, 1);
+ if (fd == -1)
+ return 0;
+ ret = is_associated(fd, &statbuf, offset, 1);
close(fd);
return ret;
}
diff --git a/mount/umount.c b/mount/umount.c
index 0468cb4..a695f0c 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -14,6 +14,7 @@
#include "mount_constants.h"
#include "sundries.h"
#include "getusername.h"
+#include "pathnames.h"
#include "lomount.h"
#include "loop.h"
#include "fstab.h"
@@ -406,7 +407,7 @@ static int
contains(const char *list, const char *s) {
int n = strlen(s);
- while (*list) {
+ while (list && *list) {
if (strncmp(list, s, n) == 0 &&
(list[n] == 0 || list[n] == ','))
return 1;
@@ -423,7 +424,7 @@ get_value(const char *list, const char *s) {
const char *t;
int n = strlen(s);
- while (*list) {
+ while (list && *list) {
if (strncmp(list, s, n) == 0) {
s = t = list+n;
while (*s && *s != ',')
@@ -432,6 +433,44 @@ get_value(const char *list, const char *s) {
}
while (*list && *list++ != ',') ;
}
+ return NULL;
+}
+
+/* check if @mc contains a loop device which is associated
+ * with the @file in fs
+ */
+static int
+is_valid_loop(struct mntentchn *mc, struct mntentchn *fs)
+{
+ unsigned long long offset = 0;
+ char *p;
+
+ /* check if it begins with /dev/loop */
+ if (strncmp(mc->m.mnt_fsname, _PATH_DEV_LOOP,
+ sizeof(_PATH_DEV_LOOP) - 1))
+ return 0;
+
+ /* check for loop option in fstab */
+ if (!contains(fs->m.mnt_opts, "loop"))
+ return 0;
+
+ /* check for offset option in fstab */
+ p = get_value(fs->m.mnt_opts, "offset=");
+ if (p)
+ offset = strtoull(p, NULL, 10);
+
+ /* check association */
+ if (loopfile_used_with((char *) mc->m.mnt_fsname,
+ fs->m.mnt_fsname, offset) == 1) {
+ if (verbose > 1)
+ printf(_("device %s is associated with %s\n"),
+ mc->m.mnt_fsname, fs->m.mnt_fsname);
+ return 1;
+ }
+
+ if (verbose > 1)
+ printf(_("device %s is not associated with %s\n"),
+ mc->m.mnt_fsname, fs->m.mnt_fsname);
return 0;
}
@@ -516,12 +555,15 @@ umount_file (char *arg) {
the pair (dev,file) in fstab. */
fs = getfs_by_devdir(mc->m.mnt_fsname, mc->m.mnt_dir);
if (!fs) {
- if (!getfs_by_spec (file) && !getfs_by_dir (file))
+ fs = getfs_by_dir(file);
+ if (!fs && !getfs_by_spec(file))
die (2,
_("umount: %s is not in the fstab "
"(and you are not root)"),
file);
- else
+
+ /* spec could be a file which is loop mounted */
+ if (fs && !is_valid_loop(mc, fs))
die (2, _("umount: %s mount disagrees with "
"the fstab"), file);
}
diff --git a/shlibs/uuid/src/uuidd.h b/shlibs/uuid/src/uuidd.h
index 528acdc..c807236 100644
--- a/shlibs/uuid/src/uuidd.h
+++ b/shlibs/uuid/src/uuidd.h
@@ -35,8 +35,8 @@
#ifndef _UUID_UUIDD_H
#define _UUID_UUIDD_H
-#define UUIDD_SOCKET_PATH "/var/lib/libuuid/request"
-#define UUIDD_PIDFILE_PATH "/var/lib/libuuid/uuidd.pid"
+#define UUIDD_SOCKET_PATH "/var/run/uuidd/request"
+#define UUIDD_PIDFILE_PATH "/var/run/uuidd/uuidd.pid"
#define UUIDD_PATH "/usr/sbin/uuidd"
#define UUIDD_OP_GETPID 0
diff --git a/sys-utils/ldattach.8 b/sys-utils/ldattach.8
index 4ee6229..7afe51d 100644
--- a/sys-utils/ldattach.8
+++ b/sys-utils/ldattach.8
@@ -35,7 +35,7 @@ With no arguments,
.B ldattach
prints usage information.
.SH LINE DISCIPLINES
-As of kernel release 2.6.21, the following line disciplines are supported:
+Depending on the kernel release, the following line disciplines are supported:
.TP
.BR TTY ( 0 )
The default line discipline,
@@ -80,6 +80,9 @@ Bluetooth HCI UART driver.
.TP
.BR GIGASET_M101 ( 16 )
Driver for Siemens Gigaset M101 serial DECT adapter.
+.TP
+.BR PPS ( 18 )
+Driver for serial line Pulse Per Second (PPS) source.
.SH OPTIONS
.TP
\fB-d\fP | \fB--debug\fP
diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c
index 801dd1c..19f70fe 100644
--- a/sys-utils/ldattach.c
+++ b/sys-utils/ldattach.c
@@ -34,6 +34,10 @@
# define N_GIGASET_M101 16
#endif
+#ifndef N_PPS
+# define N_PPS 18
+#endif
+
#ifndef ARRAY_SIZE
# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
@@ -65,7 +69,8 @@ ld_table[] = {
{ "HCI", N_HCI },
{ "GIGASET_M101", N_GIGASET_M101 },
{ "GIGASET", N_GIGASET_M101 },
- { "M101", N_GIGASET_M101 }
+ { "M101", N_GIGASET_M101 },
+ { "PPS", N_PPS },
};
/* look up line discipline code */
diff --git a/tests/expected/paths/built-in b/tests/expected/paths/built-in
index 318f44e..51372de 100644
--- a/tests/expected/paths/built-in
+++ b/tests/expected/paths/built-in
@@ -1,6 +1,7 @@
_PATH_DEFPATH /usr/local/bin:/bin:/usr/bin
_PATH_DEFPATH_ROOT /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
- _PATH_TTY /dev/tty
+ _PATH_DEV_TTY /dev/tty
+ _PATH_DEV_LOOP /dev/loop
_PATH_SECURETTY /etc/securetty
_PATH_WTMPLOCK /etc/wtmplock
_PATH_HUSHLOGIN .hushlogin
diff --git a/tests/helpers/test_pathnames.c b/tests/helpers/test_pathnames.c
index 1accede..5cc6efd 100644
--- a/tests/helpers/test_pathnames.c
+++ b/tests/helpers/test_pathnames.c
@@ -33,7 +33,8 @@ struct hlpPath paths[] =
{
DEF_HLPPATH(_PATH_DEFPATH),
DEF_HLPPATH(_PATH_DEFPATH_ROOT),
- DEF_HLPPATH(_PATH_TTY),
+ DEF_HLPPATH(_PATH_DEV_TTY),
+ DEF_HLPPATH(_PATH_DEV_LOOP),
DEF_HLPPATH(_PATH_SECURETTY),
DEF_HLPPATH(_PATH_WTMPLOCK),
DEF_HLPPATH(_PATH_HUSHLOGIN),