include: clean up _PATH_DEV_* macros

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2009-06-30 01:13:42 +02:00
parent 26d5130869
commit c74c0dafff
7 changed files with 23 additions and 15 deletions

View File

@ -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"

View File

@ -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;
}

View File

@ -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);

View File

@ -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++) {

View File

@ -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"
@ -445,7 +446,8 @@ is_valid_loop(struct mntentchn *mc, struct mntentchn *fs)
char *p;
/* check if it begins with /dev/loop */
if (strncmp(mc->m.mnt_fsname, "/dev/loop", 9))
if (strncmp(mc->m.mnt_fsname, _PATH_DEV_LOOP,
sizeof(_PATH_DEV_LOOP) - 1))
return 0;
/* check for loop option in fstab */

View File

@ -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

View File

@ -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),