]> err.no Git - util-linux/commitdiff
include: clean up _PATH_DEV_* macros
authorKarel Zak <kzak@redhat.com>
Mon, 29 Jun 2009 23:13:42 +0000 (01:13 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 29 Jun 2009 23:13:42 +0000 (01:13 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/pathnames.h
login-utils/login.c
misc-utils/script.c
mount/lomount.c
mount/umount.c
tests/expected/paths/built-in
tests/helpers/test_pathnames.c

index 0060a756f56c3d644575c6314f255737903424be..12170f9df15bb41f0509d7d43a567da8f15d1b55 100644 (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"
 
 #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"
index f3154259e2e5cc835d3ade336c2f35286d988010..7328edeb9d8ae23c003534cc5a3f50fba1c258ef 100644 (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;
     }
 
index 12ea43a82ba4cb885dacf27126fb9ed5396b5f9e..b877c31298a296759614e40c4039961e1283ced5 100644 (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);
index f0f81ed6df17fece705cdaabb8c6cb10c4965205..c6e0c929cc9ac0c4bf8340cb4ae6c14de2c4f396 100644 (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++) {
index 0e5934fd66f74ecdc59307ae0f22ca82cb319bd0..a695f0c698da210048f89e0217390d6d0822ddff 100644 (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 */
index 318f44e5a304a2a82699cc477ee31fa5fafe50e0..51372de3bab71f5960f791fd2746ebc55d5263c9 100644 (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
index 1accedecd89244a49f1182b045af8b8174a6b6c5..5cc6efd70055a2e99c5df4656da50d7fdaa17176 100644 (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),