1
0
forked from pool/util-linux
OBS User unknown 2009-07-17 13:52:45 +00:00 committed by Git OBS Bridge
parent 41f19d1446
commit a4e7d68c8f
8 changed files with 43 additions and 488 deletions

View File

@ -1,471 +0,0 @@
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),

9
baselibs.conf Normal file
View File

@ -0,0 +1,9 @@
libuuid1
libuuid-devel
requires -libblkid-<targettype>
requires "libblkid1-<targettype> = <version>"
libblkid1
obsoletes "e2fsprogs-<targettype> <= <version>"
libblkid-devel
requires -libuuid-<targettype>
requires "libuuid1-<targettype> = <version>"

5
blkid.conf Normal file
View File

@ -0,0 +1,5 @@
# do not keep cache file across reboots
CACHE_FILE=/dev/.blkid.tab
# never try to sequentially scan all devices in /dev
EVALUATE=udev

View File

@ -128,8 +128,8 @@ Index: util-linux-ng-2.14/misc-utils/Makefile.am
bin_PROGRAMS =
-usrbinexec_PROGRAMS = cal ddate logger look mcookie \
+usrbinexec_PROGRAMS = cal ddate hostid logger look mcookie \
-usrbin_exec_PROGRAMS = cal ddate logger look mcookie \
+usrbin_exec_PROGRAMS = cal ddate hostid logger look mcookie \
namei script whereis scriptreplay
EXTRA_DIST += README.cal README.ddate README.namei README.namei2

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7fd2c539888aeab25c22e99d784e9d537ba35fd3087c926efc40af4047dc418d
size 3455981

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a6365fcb2b34439faa52164e1a018086c2b6818f8a189c487c79e09dc3c62722
size 3470040

View File

@ -1,3 +1,19 @@
Mon Jul 13 14:21:07 CEST 2009 - kay.sievers@novell.com
- update to final 2.16 release
- fix libdir issues in pkgconfig files
- fix location of uuidd run directory
- improve libuuid handling if uuidd is installed but not setuid
- add blkid.conf file to:
- disable the sequential /dev scanner
- move cache to /dev/.blkid.tab to get file out of /etc
and prevent the cache file to survive a reboot
-------------------------------------------------------------------
Wed Jul 8 13:14:42 CEST 2009 - meissner@novell.com
- added baselibs.conf for libblkid* and libuuid*
-------------------------------------------------------------------
Sun Jun 28 21:36:57 CEST 2009 - kay.sievers@novell.com

View File

@ -29,10 +29,10 @@ License: BSD 3-clause (or similar) ; GPL v2 or later
Group: System/Base
AutoReqProv: on
Version: 2.16
Release: 1
Release: 2
Requires: %name-lang = %{version}
Summary: A collection of basic system utilities
Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-ng-%version-rc1.tar.bz2
Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-ng-%version.tar.bz2
Source1: util-linux-rpmlintrc
Source2: nologin.c
Source3: nologin.8
@ -56,10 +56,10 @@ Source29: mkzimage_cmdline.c
Source30: README.largedisk
Source31: addnote.c
Source50: uuidd.rc
Source51: blkid.conf
##
## util-linux patches
##
Patch1: HEAD.patch
# add hostid
Patch2: util-linux-2.12-misc_utils_hostid.patch
# 241372 - remove legacy warnings from fdisk
@ -149,8 +149,7 @@ unique IDs (UUIDs).
%lang_package
%prep
%setup -q -a 9 -b 10 -b 11 -b 12 -b 13 -n %name-ng-%version-rc1
%patch1 -p1
%setup -q -a 9 -b 10 -b 11 -b 12 -b 13 -n %name-ng-%version
%patch2 -p1
%patch3 -p1
%patch17 -p1
@ -257,6 +256,7 @@ mkdir -p "$RPM_BUILD_ROOT"{/etc/init.d,%{_mandir}/man{1,8},/bin,/sbin,/usr/bin,/
mkdir -p $RPM_BUILD_ROOT/var/lib/libuuid/
mkdir -p $RPM_BUILD_ROOT/var/run/uuidd/
install -m 744 %{SOURCE50} $RPM_BUILD_ROOT/etc/init.d/uuidd
install -m 644 %{SOURCE51} $RPM_BUILD_ROOT/etc/blkid.conf
mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
cp adjtimex-*/adjtimex %{buildroot}/sbin/
cp adjtimex-*/adjtimex.8 %{buildroot}%{_mandir}/man8/
@ -297,12 +297,8 @@ make DESTDIR=$RPM_BUILD_ROOT install
mv $RPM_BUILD_ROOT/usr/bin/logger $RPM_BUILD_ROOT/bin/logger
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/etc/filesystems
install -m 755 nologin $RPM_BUILD_ROOT/sbin
rm -f $RPM_BUILD_ROOT/%{_lib}/libblkid.la
rm -f $RPM_BUILD_ROOT/%{_lib}/libblkid.so
ln -sf /%{_lib}/libblkid.so.1 $RPM_BUILD_ROOT%{_libdir}/libblkid.so
rm -f $RPM_BUILD_ROOT/%{_lib}/libuuid.la
rm -f $RPM_BUILD_ROOT/%{_lib}/libuuid.so
ln -sf /%{_lib}/libuuid.so.1 $RPM_BUILD_ROOT%{_libdir}/libuuid.so
rm -f $RPM_BUILD_ROOT/%{_libdir}/libblkid.la
rm -f $RPM_BUILD_ROOT/%{_libdir}/libuuid.la
%ifnarch ppc ppc64
install -m 755 mkzimage_cmdline $RPM_BUILD_ROOT/usr/bin
install -m 644 %{S:28} $RPM_BUILD_ROOT%{_mandir}/man8
@ -432,6 +428,7 @@ fi
%config %attr(744,root,root) /etc/init.d/raw
%config(noreplace) %attr(644,root,root) /etc/raw
%config(noreplace) /etc/filesystems
%config(noreplace) /etc/blkid.conf
/bin/dmesg
/bin/more
/bin/mount
@ -595,7 +592,6 @@ fi
%{_mandir}/man8/swapon.8.gz
%{_mandir}/man8/umount.8.gz
%{_mandir}/man8/setctsid.8.gz
%{_mandir}/man8/setarch.8.gz
/usr/sbin/flushb
/usr/sbin/readprofile
%dir /usr/share/getopt