diff options
76 files changed, 255 insertions, 147 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index e437441..8ba307b 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -52,6 +52,7 @@ static const char rcsid[] = #include <sys/wait.h> #include <sys/time.h> #include <sys/resource.h> +#include <paths.h> #endif #include <sys/ioctl.h> @@ -635,9 +636,9 @@ forkshell(jp, n, mode) if ((jp == NULL || jp->nprocs == 0) && ! fd0_redirected_p ()) { close(0); - if (open("/dev/null", O_RDONLY) != 0) - error("Can't open /dev/null: %s", - strerror(errno)); + if (open(_PATH_DEVNULL, O_RDONLY) != 0) + error("Can't open %s: %s", + _PATH_DEVNULL, strerror(errno)); } } #else @@ -647,9 +648,9 @@ forkshell(jp, n, mode) if ((jp == NULL || jp->nprocs == 0) && ! fd0_redirected_p ()) { close(0); - if (open("/dev/null", O_RDONLY) != 0) - error("Can't open /dev/null: %s", - strerror(errno)); + if (open(_PATH_DEVNULL, O_RDONLY) != 0) + error("Can't open %s: %s", + _PATH_DEVNULL, strerror(errno)); } } #endif diff --git a/gnu/libexec/uucp/contrib/tstout.c b/gnu/libexec/uucp/contrib/tstout.c index dd82633..92eca75 100644 --- a/gnu/libexec/uucp/contrib/tstout.c +++ b/gnu/libexec/uucp/contrib/tstout.c @@ -15,6 +15,8 @@ This program must run suid to root. */ +/* $FreeBSD$ */ + #include <stdio.h> #include <string.h> @@ -36,7 +38,7 @@ main (argc, argv) char *z; if (argc != 2 - || strncmp (argv[1], "/dev/", sizeof "/dev/" - 1) != 0) + || strncmp (argv[1], _PATH_DEV, sizeof _PATH_DEV - 1) != 0) { fprintf (stderr, "Usage: tstout device\n"); exit (EXIT_FAILURE); diff --git a/gnu/libexec/uucp/libunix/cohtty.c b/gnu/libexec/uucp/libunix/cohtty.c index 5a52df9..9cbe220 100644 --- a/gnu/libexec/uucp/libunix/cohtty.c +++ b/gnu/libexec/uucp/libunix/cohtty.c @@ -2,6 +2,8 @@ Hemedinger <bob@dalek.mwc.com> of Mark Williams Corporation and lightly edited by Ian Lance Taylor. */ +/* $FreeBSD$ */ + /* The bottom part of this file is lock.c. * This is a hacked lock.c. A full lock.c can be found in the libmisc sources * under /usr/src/misc.tar.Z. @@ -29,6 +31,7 @@ #include <ctype.h> #include <access.h> +#include <paths.h> /* fscoherent_disable_tty() is a COHERENT specific function. It takes the name * of a serial device and then scans /etc/ttys for a match. If it finds one, @@ -139,9 +142,10 @@ char enable_device[16]; /* this will hold our device name x = ixswait ((unsigned long) ipid, (const char *) NULL); } - *pzenable = zbufalc (sizeof "/dev/" + *pzenable = zbufalc (sizeof _PATH_DEV + strlen (enable_device)); - sprintf(*pzenable,"/dev/%s", enable_device); + sprintf(*pzenable,"%s%s",_PATH_DEV, + enable_device); /* ulog(LOG_NORMAL,"Enable string is {%s}",*pzenable); */ return TRUE; }else{ @@ -246,7 +250,7 @@ const char *ttyn; char resource[LOKFLEN]; char filename[LOKFLEN]; - sprintf(filename, "/dev/%s", ttyn); + sprintf(filename, "%s%s", _PATH_DEV, ttyn); if (NULL == gen_res_name(filename, resource)){ return(0); /* Non-existent tty can not be locked :-) */ } diff --git a/gnu/libexec/uucp/libunix/cusub.c b/gnu/libexec/uucp/libunix/cusub.c index c92eeba..67cd363 100644 --- a/gnu/libexec/uucp/libunix/cusub.c +++ b/gnu/libexec/uucp/libunix/cusub.c @@ -63,6 +63,7 @@ const char cusub_rcsid[] = "$FreeBSD$"; #endif /* ! defined (O_NONBLOCK) */ #include <errno.h> +#include <paths.h> /* 4.2 systems don't define SIGUSR2. This should work for them. On systems which are missing SIGUSR1, or SIGURG, you must find two @@ -156,8 +157,8 @@ fsysdep_port_access (qport) zfree = NULL; if (*zline != '/') { - zfree = zbufalc (sizeof "/dev/" + strlen (zline)); - sprintf (zfree, "/dev/%s", zline); + zfree = zbufalc (sizeof _PATH_DEV + strlen (zline)); + sprintf (zfree, "%s%s", _PATH_DEV, zline); zline = zfree; } @@ -188,14 +189,14 @@ fsysdep_port_is_line (qport, zline) zfree2 = NULL; if (*zline != '/') { - zfree1 = zbufalc (sizeof "/dev/" + strlen (zline)); - sprintf (zfree1, "/dev/%s", zline); + zfree1 = zbufalc (sizeof _PATH_DEV + strlen (zline)); + sprintf (zfree1, "%s%s", _PATH_DEV, zline); zline = zfree1; } if (*zpline != '/') { - zfree2 = zbufalc (sizeof "/dev/" + strlen (zpline)); - sprintf (zfree2, "/dev/%s", zpline); + zfree2 = zbufalc (sizeof _PATH_DEV + strlen (zpline)); + sprintf (zfree2, "%s%s", _PATH_DEV, zpline); zpline = zfree2; } diff --git a/gnu/libexec/uucp/libunix/detach.c b/gnu/libexec/uucp/libunix/detach.c index 88becf1..ad753b4 100644 --- a/gnu/libexec/uucp/libunix/detach.c +++ b/gnu/libexec/uucp/libunix/detach.c @@ -23,6 +23,8 @@ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. */ +/* $FreeBSD$ */ + #include "uucp.h" #include "uudefs.h" @@ -30,6 +32,7 @@ #include "sysdep.h" #include <errno.h> +#include <paths.h> #if HAVE_SYS_IOCTL_H #include <sys/ioctl.h> @@ -123,7 +126,7 @@ usysdep_detach () { int o; - o = open ((char *) "/dev/tty", O_RDONLY); + o = open ((char *) _PATH_TTY, O_RDONLY); if (o >= 0) { (void) ioctl (o, TIOCNOTTY, (char *) NULL); @@ -137,10 +140,10 @@ usysdep_detach () (void) close (0); (void) close (1); (void) close (2); - if (open ((char *) "/dev/null", O_RDONLY) != 0 - || open ((char *) "/dev/null", O_WRONLY) != 1 - || open ((char *) "/dev/null", O_WRONLY) != 2) - ulog (LOG_FATAL, "open (/dev/null): %s", strerror (errno)); + if (open ((char *) _PATH_DEVNULL, O_RDONLY) != 0 + || open ((char *) _PATH_DEVNULL, O_WRONLY) != 1 + || open ((char *) _PATH_DEVNULL, O_WRONLY) != 2) + ulog (LOG_FATAL, "open (%s): %s", _PATH_DEVNULL, strerror (errno)); #if HAVE_SETSID diff --git a/gnu/libexec/uucp/libunix/init.c b/gnu/libexec/uucp/libunix/init.c index 8a3c416..fade17c 100644 --- a/gnu/libexec/uucp/libunix/init.c +++ b/gnu/libexec/uucp/libunix/init.c @@ -23,6 +23,8 @@ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. */ +/* $FreeBSD$ */ + #include "uucp.h" #include "uudefs.h" @@ -31,6 +33,7 @@ #include "sysdep.h" #include <errno.h> +#include <paths.h> #include <pwd.h> #if HAVE_FCNTL_H @@ -189,13 +192,13 @@ usysdep_initialize (puuconf,iflags) /* Make sure stdin, stdout and stderr are open. */ if (fcntl (0, F_GETFD, 0) < 0 - && open ((char *) "/dev/null", O_RDONLY, 0) != 0) + && open ((char *) _PATH_DEVNULL, O_RDONLY, 0) != 0) exit (EXIT_FAILURE); if (fcntl (1, F_GETFD, 0) < 0 - && open ((char *) "/dev/null", O_WRONLY, 0) != 1) + && open ((char *) _PATH_DEVNULL, O_WRONLY, 0) != 1) exit (EXIT_FAILURE); if (fcntl (2, F_GETFD, 0) < 0 - && open ((char *) "/dev/null", O_WRONLY, 0) != 2) + && open ((char *) _PATH_DEVNULL, O_WRONLY, 0) != 2) exit (EXIT_FAILURE); iuuconf = uuconf_spooldir (puuconf, &zSspooldir); diff --git a/gnu/libexec/uucp/libunix/portnm.c b/gnu/libexec/uucp/libunix/portnm.c index 9eda4ab..11f1247 100644 --- a/gnu/libexec/uucp/libunix/portnm.c +++ b/gnu/libexec/uucp/libunix/portnm.c @@ -1,6 +1,8 @@ /* portnm.c Get the port name of stdin. */ +/* $FreeBSD$ */ + #include "uucp.h" #include "sysdep.h" @@ -12,6 +14,7 @@ #endif #include <sys/socket.h> #endif +#include <paths.h> #ifndef ttyname extern char *ttyname (); @@ -44,8 +47,8 @@ zsysdep_port_name (ftcp_port) z = ttyname (0); if (z == NULL) return NULL; - if (strncmp (z, "/dev/", sizeof "/dev/" - 1) == 0) - return z + sizeof "/dev/" - 1; + if (strncmp (z, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) + return z + sizeof _PATH_DEV - 1; else return z; } diff --git a/gnu/libexec/uucp/libunix/serial.c b/gnu/libexec/uucp/libunix/serial.c index f5d8816..0c2a5b3 100644 --- a/gnu/libexec/uucp/libunix/serial.c +++ b/gnu/libexec/uucp/libunix/serial.c @@ -37,6 +37,7 @@ const char serial_rcsid[] = "$FreeBSD$"; #include <errno.h> #include <ctype.h> +#include <paths.h> #if HAVE_SYS_PARAM_H #include <sys/param.h> @@ -497,10 +498,10 @@ fsserial_init (qconn, qcmds, zdevice) size_t clen; clen = strlen (zdevice); - q->zdevice = zbufalc (sizeof "/dev/" + clen); - memcpy (q->zdevice, "/dev/", sizeof "/dev/" - 1); - memcpy (q->zdevice + sizeof "/dev/" - 1, zdevice, clen); - q->zdevice[sizeof "/dev/" + clen - 1] = '\0'; + q->zdevice = zbufalc (sizeof _PATH_DEV + clen); + memcpy (q->zdevice, _PATH_DEV, sizeof _PATH_DEV - 1); + memcpy (q->zdevice + sizeof _PATH_DEV - 1, zdevice, clen); + q->zdevice[sizeof _PATH_DEV + clen - 1] = '\0'; } q->o = -1; q->ord = -1; @@ -519,7 +520,7 @@ fsysdep_stdin_init (qconn) { /* chmod /dev/tty to prevent other users from writing messages to it. This is essentially `mesg n'. */ - (void) chmod ("/dev/tty", S_IRUSR | S_IWUSR); + (void) chmod (_PATH_TTY, S_IRUSR | S_IWUSR); return fsserial_init (qconn, &sstdincmds, (const char *) NULL); } @@ -959,8 +960,8 @@ fsserial_open (qconn, ibaud, fwait, tlocal) #else const char *z; - if (strncmp (q->zdevice, "/dev/", sizeof "/dev/" - 1) == 0) - z = q->zdevice + sizeof "/dev/" - 1; + if (strncmp (q->zdevice, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) + z = q->zdevice + sizeof _PATH_DEV - 1; else z = q->zdevice; ulog_device (z); @@ -1651,8 +1652,8 @@ fsysdep_modem_begin_dial (qconn, qdial) zfree = NULL; if (*z != '/') { - zfree = zbufalc (sizeof "/dev/" + strlen (z)); - sprintf (zfree, "/dev/%s", z); + zfree = zbufalc (sizeof _PATH_DEV + strlen (z)); + sprintf (zfree, "%s%s", _PATH_DEV, z); z = zfree; } diff --git a/gnu/libexec/uucp/libunix/spawn.c b/gnu/libexec/uucp/libunix/spawn.c index d39e2ba..6a413c4 100644 --- a/gnu/libexec/uucp/libunix/spawn.c +++ b/gnu/libexec/uucp/libunix/spawn.c @@ -23,12 +23,15 @@ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. */ +/* $FreeBSD$ */ + #include "uucp.h" #include "uudefs.h" #include "sysdep.h" #include <errno.h> +#include <paths.h> #if HAVE_FCNTL_H #include <fcntl.h> @@ -210,7 +213,7 @@ ixsspawn (pazargs, aidescs, fkeepuid, fkeepenv, zchdir, fnosigs, fshell, { if (onull < 0) { - onull = open ((char *) "/dev/null", O_RDWR); + onull = open ((char *) _PATH_DEVNULL, O_RDWR); if (onull < 0 || fcntl (onull, F_SETFD, fcntl (onull, F_GETFD, 0) | FD_CLOEXEC) < 0) diff --git a/gnu/libexec/uucp/libunix/tli.c b/gnu/libexec/uucp/libunix/tli.c index 714942e..0330646 100644 --- a/gnu/libexec/uucp/libunix/tli.c +++ b/gnu/libexec/uucp/libunix/tli.c @@ -38,6 +38,7 @@ const char tli_rcsid[] = "$FreeBSD$"; #include "system.h" #include <errno.h> +#include <paths.h> #if HAVE_SYS_IOCTL_H #include <sys/ioctl.h> @@ -267,8 +268,8 @@ ftli_open (qconn, ibaud, fwait) zfreedev = NULL; if (*zdevice != '/') { - zfreedev = zbufalc (sizeof "/dev/" + strlen (zdevice)); - sprintf (zfreedev, "/dev/%s", zdevice); + zfreedev = zbufalc (sizeof _PATH_DEV + strlen (zdevice)); + sprintf (zfreedev, "%s%s", _PATH_DEV, zdevice); zdevice = zfreedev; } diff --git a/gnu/usr.bin/binutils/gdb/alpha/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/alpha/kvm-fbsd.c index 5c28908..6da1a8e 100644 --- a/gnu/usr.bin/binutils/gdb/alpha/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/alpha/kvm-fbsd.c @@ -19,6 +19,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + /* * This works like "remote" but, you use it like this: * target kcore /dev/mem @@ -37,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <signal.h> #include <fcntl.h> #include <kvm.h> +#include <paths.h> #include "defs.h" #include "gdb_string.h" @@ -110,7 +113,7 @@ initial_pcb() return (0); /* If this is NOT /dev/mem try for dumppcb. */ - if (strncmp(core_file, "/dev/", 5)) { + if (strncmp(core_file, _PATH_DEV, sizeof _PATH_DEV - 1)) { sym = lookup_minimal_symbol("dumppcb", NULL, NULL); if (sym != NULL) { addr = SYMBOL_VALUE_ADDRESS(sym); diff --git a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c index 2608e3c..a08254d 100644 --- a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c @@ -17,11 +17,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "defs.h" #include <errno.h> #include <signal.h> #include <fcntl.h> +#include <paths.h> #include <sys/sysctl.h> #include <sys/param.h> #include <sys/time.h> @@ -540,7 +543,7 @@ kvm_open (efile, cfile, sfile, perm, errout) && stb.st_rdev == makedev (2, 0)) { devmem = 1; - kfd = open ("/dev/kmem", perm, 0); + kfd = open (_PATH_KMEM, perm, 0); } if (lookup_minimal_symbol("mp_ncpus", NULL, NULL)) { diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c index 2608e3c..a08254d 100644 --- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c @@ -17,11 +17,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "defs.h" #include <errno.h> #include <signal.h> #include <fcntl.h> +#include <paths.h> #include <sys/sysctl.h> #include <sys/param.h> #include <sys/time.h> @@ -540,7 +543,7 @@ kvm_open (efile, cfile, sfile, perm, errout) && stb.st_rdev == makedev (2, 0)) { devmem = 1; - kfd = open ("/dev/kmem", perm, 0); + kfd = open (_PATH_KMEM, perm, 0); } if (lookup_minimal_symbol("mp_ncpus", NULL, NULL)) { diff --git a/gnu/usr.bin/patch/util.c b/gnu/usr.bin/patch/util.c index 258490b..277440c 100644 --- a/gnu/usr.bin/patch/util.c +++ b/gnu/usr.bin/patch/util.c @@ -1,3 +1,7 @@ +/* $FreeBSD$ */ + +#include <paths.h> + #include "EXTERN.h" #include "common.h" #include "INTERN.h" @@ -247,7 +251,7 @@ long arg1,arg2,arg3; write(1, buf, strlen(buf)); r = read(1, buf, sizeof buf); } - else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) { + else if ((ttyfd = open(_PATH_TTY, 2)) >= 0 && isatty(ttyfd)) { /* might be deleted or unwriteable */ write(ttyfd, buf, strlen(buf)); r = read(ttyfd, buf, sizeof buf); @@ -382,7 +386,7 @@ int assume_exists; if (debug & 128) say4("fetchname %s %d %d\n",at,strip_leading,assume_exists); #endif - if (strnEQ(at, "/dev/null", 9)) /* so files can be created by diffing */ + if (strnEQ(at, _PATH_DEVNULL, sizeof _PATH_DEVNULL - 1)) /* so files can be created by diffing */ return Nullch; /* against /dev/null. */ name = fullname = t = savestr(at); diff --git a/include/paths.h b/include/paths.h index ea72120..0109ac6 100644 --- a/include/paths.h +++ b/include/paths.h @@ -31,6 +31,7 @@ * SUCH DAMAGE. * * @(#)paths.h 8.1 (Berkeley) 6/2/93 + * $FreeBSD$ */ #ifndef _PATHS_H_ @@ -50,6 +51,7 @@ #define _PATH_CSHELL "/bin/csh" #define _PATH_DEVDB "/var/run/dev.db" #define _PATH_DEVNULL "/dev/null" +#define _PATH_DEVZERO "/dev/zero" #define _PATH_DRUM "/dev/drum" #define _PATH_FTPUSERS "/etc/ftpusers" #define _PATH_KMEM "/dev/kmem" diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index bb6bb6f..91236df 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -72,7 +72,7 @@ static int fdzero; # define MMAP_FD fdzero # define INIT_MMAP() \ - { if ((fdzero = _open("/dev/zero", O_RDWR, 0000)) == -1) \ + { if ((fdzero = _open(_PATH_DEVZERO, O_RDWR, 0000)) == -1) \ wrterror("open of /dev/zero"); } # define MADV_FREE MADV_DONTNEED #endif /* __sparc__ */ @@ -91,6 +91,7 @@ #include <sys/mman.h> #include <errno.h> #include <fcntl.h> +#include <paths.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> diff --git a/lib/libio/bwx.c b/lib/libio/bwx.c index dede881..f923572 100644 --- a/lib/libio/bwx.c +++ b/lib/libio/bwx.c @@ -31,6 +31,7 @@ #include <sys/fcntl.h> #include <sys/sysctl.h> #include <err.h> +#include <paths.h> #include <machine/bwx.h> #include <machine/sysarch.h> #include <stdlib.h> @@ -52,9 +53,9 @@ bwx_init() size_t len = sizeof(u_int64_t); int error; - mem_fd = open("/dev/mem", O_RDWR); + mem_fd = open(_PATH_MEM, O_RDWR); if (mem_fd < 0) - err(1, "/dev/mem"); + err(1, _PATH_MEM); bwx_int1_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0); bwx_int2_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0); bwx_int4_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0); diff --git a/lib/libio/swiz.c b/lib/libio/swiz.c index bee9f6d..b30dfa3f 100644 --- a/lib/libio/swiz.c +++ b/lib/libio/swiz.c @@ -31,6 +31,7 @@ #include <sys/fcntl.h> #include <sys/sysctl.h> #include <err.h> +#include <paths.h> #include <machine/swiz.h> #include <machine/sysarch.h> #include <stdlib.h> @@ -54,9 +55,9 @@ swiz_init() size_t len = sizeof(u_int64_t); int error; - mem_fd = open("/dev/mem", O_RDWR); + mem_fd = open(_PATH_MEM, O_RDWR); if (mem_fd < 0) - err(1, "/dev/mem"); + err(1, _PATH_MEM); swiz_ports = mmap(0, 1L<<32, PROT_READ, MAP_ANON, -1, 0); if ((error = sysctlbyname("hw.chipset.ports", &swiz_io_base, &len, diff --git a/lib/libkvm/kvm_getswapinfo.c b/lib/libkvm/kvm_getswapinfo.c index 3a4ab77..fe742ad 100644 --- a/lib/libkvm/kvm_getswapinfo.c +++ b/lib/libkvm/kvm_getswapinfo.c @@ -27,6 +27,7 @@ static const char rcsid[] = #include <fcntl.h> #include <kvm.h> #include <nlist.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -187,7 +188,7 @@ kvm_getswapinfo( swap_ary[i].ksw_devname, sizeof(swap_ary[i].ksw_devname), "%s%s", - ((flags & SWIF_DEV_PREFIX) ? "/dev/" : ""), + ((flags & SWIF_DEV_PREFIX) ? _PATH_DEV : ""), devname(swinfo.sw_dev, S_IFCHR) ); } diff --git a/lib/libss/pager.c b/lib/libss/pager.c index 988f8d9..deea0ba 100644 --- a/lib/libss/pager.c +++ b/lib/libss/pager.c @@ -9,11 +9,14 @@ * For copyright information, see copyright.h. */ +/* $FreeBSD$ */ + #include "ss_internal.h" #include "copyright.h" #include <errno.h> #include <stdio.h> #include <sys/file.h> +#include <paths.h> #include <signal.h> #include <unistd.h> @@ -61,7 +64,7 @@ int ss_pager_create() int ss_pager_create() { int fd; - fd = open("/dev/tty", O_WRONLY, 0); + fd = open(_PATH_TTY, O_WRONLY, 0); return fd; } #endif diff --git a/libexec/bootpd/bootpd.c b/libexec/bootpd/bootpd.c index 216e08f..aac6263 100644 --- a/libexec/bootpd/bootpd.c +++ b/libexec/bootpd/bootpd.c @@ -65,6 +65,7 @@ SOFTWARE. #include <errno.h> #include <ctype.h> #include <netdb.h> +#include <paths.h> #include <syslog.h> #include <assert.h> @@ -395,7 +396,7 @@ main(argc, argv) #ifdef NO_SETSID setpgrp(0,0); #ifdef TIOCNOTTY - n = open("/dev/tty", O_RDWR); + n = open(_PATH_TTY, O_RDWR); if (n >= 0) { ioctl(n, TIOCNOTTY, (char *) 0); (void) close(n); diff --git a/libexec/bootpd/bootpgw/bootpgw.c b/libexec/bootpd/bootpgw/bootpgw.c index b552eb3..7271a7a 100644 --- a/libexec/bootpd/bootpgw/bootpgw.c +++ b/libexec/bootpd/bootpgw/bootpgw.c @@ -25,6 +25,8 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ************************************************************************/ +/* $FreeBSD$ */ + /* * BOOTPGW is typically used to forward BOOTP client requests from * one subnet to a BOOTP server on a different subnet. @@ -54,6 +56,7 @@ SOFTWARE. #include <errno.h> #include <ctype.h> #include <netdb.h> +#include <paths.h> #include <syslog.h> #include <assert.h> @@ -372,7 +375,7 @@ main(argc, argv) #ifdef NO_SETSID setpgrp(0,0); #ifdef TIOCNOTTY - n = open("/dev/tty", O_RDWR); + n = open(_PATH_TTY, O_RDWR); if (n >= 0) { ioctl(n, TIOCNOTTY, (char *) 0); (void) close(n); diff --git a/libexec/bootpd/getether.c b/libexec/bootpd/getether.c index 8f95a59..071b5fc 100644 --- a/libexec/bootpd/getether.c +++ b/libexec/bootpd/getether.c @@ -18,6 +18,7 @@ #endif #include <ctype.h> +#include <paths.h> #include <syslog.h> #include "getether.h" @@ -195,7 +196,7 @@ getether(ifname, eap) char *enaddr; int unit = -1; /* which unit to attach */ - snprintf(devname, sizeof(devname), "/dev/%s", ifname); + snprintf(devname, sizeof(devname), "%s%s", _PATH_DEV, ifname); fd = open(devname, 2); if (fd < 0) { /* Try without the trailing digit. */ diff --git a/libexec/rtld-aout/rtld.c b/libexec/rtld-aout/rtld.c index a55e9bc..3a66319 100644 --- a/libexec/rtld-aout/rtld.c +++ b/libexec/rtld-aout/rtld.c @@ -45,6 +45,7 @@ #include <err.h> #include <fcntl.h> #include <a.out.h> +#include <paths.h> #include <stab.h> #include <stdio.h> #include <stdlib.h> @@ -66,8 +67,8 @@ #ifndef MAP_ANON #define MAP_ANON 0 #define anon_open() do { \ - if ((anon_fd = open("/dev/zero", O_RDWR, 0)) == -1) \ - err("open: %s", "/dev/zero"); \ + if ((anon_fd = open(_PATH_DEVZERO, O_RDWR, 0)) == -1) \ + err("open: %s", _PATH_DEVZERO); \ } while (0) #define anon_close() do { \ (void)close(anon_fd); \ diff --git a/libexec/rtld-elf/malloc.c b/libexec/rtld-elf/malloc.c index 8aefa41..cb00a20 100644 --- a/libexec/rtld-elf/malloc.c +++ b/libexec/rtld-elf/malloc.c @@ -49,6 +49,7 @@ static char *rcsid = "$FreeBSD$"; #include <sys/types.h> #include <err.h> +#include <paths.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -456,9 +457,9 @@ int n; int offset; #ifdef NEED_DEV_ZERO - fd = open("/dev/zero", O_RDWR, 0); + fd = open(_PATH_DEVZERO, O_RDWR, 0); if (fd == -1) - perror("/dev/zero"); + perror(_PATH_DEVZERO); #endif if (pagepool_end - pagepool_start > pagesz) { diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c index 306449a..b1ca5c4 100644 --- a/libexec/telnetd/sys_term.c +++ b/libexec/telnetd/sys_term.c @@ -190,6 +190,7 @@ int ttyfd = -1; #include <sys/types.h> #include <libutil.h> +#include <paths.h> int cleanopen __P((char *)); void scrub_env __P((void)); @@ -512,7 +513,8 @@ int *ptynum; #endif #ifndef __hpux - (void) strcpy(line, "/dev/ptyXX"); + (void) strcpy(line, _PATH_DEV); + (void) strcat(line, "ptyXX"); p1 = &line[8]; p2 = &line[9]; #else @@ -563,7 +565,7 @@ int *ptynum; struct stat sb; for (*ptynum = lowpty; *ptynum <= highpty; (*ptynum)++) { - (void) sprintf(myline, "/dev/pty/%03d", *ptynum); + (void) sprintf(myline, "%spty/%03d", _PATH_DEV, *ptynum); p = open(myline, 2); if (p < 0) continue; @@ -1325,7 +1327,7 @@ login_tty(t) * the indirect /dev/tty interface. */ close(t); - if ((t = open("/dev/tty", O_RDWR)) < 0) + if ((t = open(_PATH_TTY, O_RDWR)) < 0) fatalperror(net, "open(/dev/tty)"); # endif # else @@ -1414,7 +1416,7 @@ startslave(host, autologin, autoname) wtmp.ut_pid = pid; SCPYN(wtmp.ut_user, "LOGIN"); SCPYN(wtmp.ut_host, host); - SCPYN(wtmp.ut_line, line + sizeof("/dev/") - 1); + SCPYN(wtmp.ut_line, line + sizeof(_PATH_DEV) - 1); #ifndef __hpux SCPYN(wtmp.ut_id, wtmp.ut_line+3); #else @@ -1546,7 +1548,7 @@ start_login(host, autologin, name) bzero(&utmpx, sizeof(utmpx)); SCPYN(utmpx.ut_user, ".telnet"); - SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1); + SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1); utmpx.ut_pid = pid; utmpx.ut_id[0] = 't'; utmpx.ut_id[1] = 'n'; @@ -1823,7 +1825,7 @@ cleanup(sig) # if (BSD > 43) || defined(convex) char *p; - p = line + sizeof("/dev/") - 1; + p = line + sizeof(_PATH_DEV) - 1; if (logout(p)) logwtmp(p, "", ""); (void)chmod(line, 0666); @@ -2102,7 +2104,7 @@ rmut() * This updates the utmpx and utmp entries and make a wtmp/x entry */ - SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1); + SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1); utxp = getutxline(&utmpx); if (utxp) { utxp->ut_type = DEAD_PROCESS; @@ -2163,7 +2165,7 @@ rmut() } (void) chmod(line, 0666); (void) chown(line, 0, 0); - line[strlen("/dev/")] = 'p'; + line[strlen(_PATH_DEV)] = 'p'; (void) chmod(line, 0666); (void) chown(line, 0, 0); } /* end of rmut */ diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c index ac0260e..5695f51 100644 --- a/libexec/telnetd/telnetd.c +++ b/libexec/telnetd/telnetd.c @@ -62,6 +62,7 @@ static const char rcsid[] = #include <sys/mman.h> #include <libutil.h> +#include <paths.h> #include <utmp.h> #if defined(_SC_CRAY_SECURE_SYS) @@ -824,10 +825,10 @@ doit(who) if (secflag) { char slave_dev[16]; - sprintf(tty_dev, "/dev/pty/%03d", ptynum); + sprintf(tty_dev, "%spty/%03d", _PATH_DEV, ptynum); if (setdevs(tty_dev, &dv) < 0) fatal(net, "cannot set pty security"); - sprintf(slave_dev, "/dev/ttyp%03d", ptynum); + sprintf(slave_dev, "%sp%03d", _PATH_TTY, ptynum); if (setdevs(slave_dev, &dv) < 0) fatal(net, "cannot set tty security"); } diff --git a/release/picobsd/tinyware/oinit/oinit.c b/release/picobsd/tinyware/oinit/oinit.c index c0555fa..66b5623 100644 --- a/release/picobsd/tinyware/oinit/oinit.c +++ b/release/picobsd/tinyware/oinit/oinit.c @@ -909,15 +909,15 @@ main(int argc, char **argv) } } if(devfs) - mount("devfs","/dev",MNT_NOEXEC|MNT_RDONLY,0); + mount("devfs",_PATH_DEV,MNT_NOEXEC|MNT_RDONLY,0); /* Fill in the sess structures. */ /* XXX Really, should be filled based upon config file. */ for(i=0;i<MAX_CONS;i++) { if(i==0) { - sprintf(ttys[i].tty,"/dev/console"); + sprintf(ttys[i].tty,_PATH_CONSOLE); } else { - sprintf(ttys[i].tty,"/dev/ttyv%c",vty[i]); + sprintf(ttys[i].tty,"%sv%c",_PATH_TTY,vty[i]); } ttys[i].pid=0; ttys[i].func=shell; diff --git a/sbin/atm/fore_dnld/fore_dnld.c b/sbin/atm/fore_dnld/fore_dnld.c index 1e5b27e..22ce59e 100644 --- a/sbin/atm/fore_dnld/fore_dnld.c +++ b/sbin/atm/fore_dnld/fore_dnld.c @@ -52,6 +52,7 @@ #include <ctype.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -73,7 +74,7 @@ extern int pca200e_microcode_size; #define DEV_NAME "/dev/sbus%d" #endif /* sun */ #if (defined(BSD) && (BSD >= 199103)) -#define DEV_NAME "/dev/kmem" +#define DEV_NAME _PATH_KMEM #endif /* BSD */ #define MAX_CHECK 60 @@ -1056,7 +1057,7 @@ char *argv[]; * If comm_mode, setup terminal for single char I/O */ if ( comm_mode ) { - tty = open ( "/dev/tty", O_RDWR ); + tty = open ( _PATH_TTY, O_RDWR ); ioctl ( tty, TCGETA, &sgtty ); sgtty.c_lflag &= ~( ICANON | ECHO ); vmin = sgtty.c_cc[VMIN]; diff --git a/sbin/ccdconfig/ccdconfig.c b/sbin/ccdconfig/ccdconfig.c index 9203dcc..aea08be 100644 --- a/sbin/ccdconfig/ccdconfig.c +++ b/sbin/ccdconfig/ccdconfig.c @@ -48,6 +48,7 @@ static const char rcsid[] = #include <fcntl.h> #include <kvm.h> #include <limits.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -444,9 +445,9 @@ resolve_ccdname(name) free(path); return (NULL); } - (void)sprintf(path, "/dev/%s%c", name, 'a' + rawpart); + (void)sprintf(path, "%s%s%c", _PATH_DEV, name, 'a' + rawpart); } else - (void)sprintf(path, "/dev/%s", name); + (void)sprintf(path, "%s%s", _PATH_DEV, name); return (path); } diff --git a/sbin/fdisk_pc98/fdisk.c b/sbin/fdisk_pc98/fdisk.c index 39faadd..9fe2773 100644 --- a/sbin/fdisk_pc98/fdisk.c +++ b/sbin/fdisk_pc98/fdisk.c @@ -35,6 +35,7 @@ static const char rcsid[] = #include <fcntl.h> #include <err.h> #include <errno.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -331,11 +332,11 @@ main(int argc, char *argv[]) { static char realname[12]; - if(strncmp(argv[0], "/dev", 4) == 0) + if(strncmp(argv[0], _PATH_DEV, sizeof _PATH_DEV - 2) == 0) disk = argv[0]; else { - snprintf(realname, 12, "/dev/%s", argv[0]); + snprintf(realname, 12, "%s%s", _PATH_DEV, argv[0]); disk = realname; } diff --git a/sbin/init/init.c b/sbin/init/init.c index 3bb51ae..7498608 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -59,6 +59,7 @@ static const char rcsid[] = #include <errno.h> #include <fcntl.h> #include <libutil.h> +#include <paths.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -283,7 +284,7 @@ invalid: warning("ignoring excess arguments"); if (devfs) { - mount("devfs", "/dev", 0, 0); + mount("devfs", _PATH_DEV, 0, 0); } /* diff --git a/sbin/pc98/fdisk/fdisk.c b/sbin/pc98/fdisk/fdisk.c index 39faadd..9fe2773 100644 --- a/sbin/pc98/fdisk/fdisk.c +++ b/sbin/pc98/fdisk/fdisk.c @@ -35,6 +35,7 @@ static const char rcsid[] = #include <fcntl.h> #include <err.h> #include <errno.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -331,11 +332,11 @@ main(int argc, char *argv[]) { static char realname[12]; - if(strncmp(argv[0], "/dev", 4) == 0) + if(strncmp(argv[0], _PATH_DEV, sizeof _PATH_DEV - 2) == 0) disk = argv[0]; else { - snprintf(realname, 12, "/dev/%s", argv[0]); + snprintf(realname, 12, "%s%s", _PATH_DEV, argv[0]); disk = realname; } diff --git a/sbin/route/route.c b/sbin/route/route.c index e6ee088..9c5b8d1 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -66,6 +66,7 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> #include <errno.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -178,7 +179,7 @@ main(argc, argv) pid = getpid(); uid = getuid(); if (tflag) - s = open("/dev/null", O_WRONLY, 0); + s = open(_PATH_DEVNULL, O_WRONLY, 0); else s = socket(PF_ROUTE, SOCK_RAW, 0); if (s < 0) diff --git a/share/examples/kld/cdev/test/testcdev.c b/share/examples/kld/cdev/test/testcdev.c index 8f2c0b3..d69c3f5 100644 --- a/share/examples/kld/cdev/test/testcdev.c +++ b/share/examples/kld/cdev/test/testcdev.c @@ -70,8 +70,10 @@ * * $FreeBSD$ */ + #include <stdio.h> #include <fcntl.h> +#include <paths.h> #include <string.h> #include <sys/ioccom.h> @@ -97,7 +99,7 @@ main(int argc, char *argv[]) if (ioctl(kernel_fd, CDEV_IOCTL1, &one) == -1) { perror("CDEV_IOCTL1"); } else { - printf( "Sent ioctl CDEV_IOCTL1 to device /dev/" CDEV_DEVICE "\n"); + printf( "Sent ioctl CDEV_IOCTL1 to device %s%s\n", _PATH_DEV, CDEV_DEVICE); } len = strlen(writestr) + 1; diff --git a/share/examples/scsi_target/scsi_target.c b/share/examples/scsi_target/scsi_target.c index c240686..6439d44 100644 --- a/share/examples/scsi_target/scsi_target.c +++ b/share/examples/scsi_target/scsi_target.c @@ -138,7 +138,7 @@ main(int argc, char *argv[]) exit(EX_SOFTWARE); } - snprintf(targdevname, sizeof(targdevname), "/dev/targ%d", + snprintf(targdevname, sizeof(targdevname), "%starg%d", _PATH_DEV, alloc_unit.unit); if ((targfd = open(targdevname, O_RDWR)) == -1) { diff --git a/share/examples/sunrpc/msg/msg_proc.c b/share/examples/sunrpc/msg/msg_proc.c index 96c1cb5..ed08883 100644 --- a/share/examples/sunrpc/msg/msg_proc.c +++ b/share/examples/sunrpc/msg/msg_proc.c @@ -1,7 +1,9 @@ /* @(#)msg_proc.c 2.1 88/08/11 4.0 RPCSRC */ +/* $FreeBSD$ */ /* * msg_proc.c: implementation of the remote procedure "printmessage" */ +#include <paths.h> #include <stdio.h> #include <rpc/rpc.h> /* always need this here */ #include "msg.h" /* need this too: msg.h will be generated by rpcgen */ @@ -16,7 +18,7 @@ printmessage_1(msg) static int result; /* must be static! */ FILE *f; - f = fopen("/dev/console", "w"); + f = fopen(_PATH_CONSOLE, "w"); if (f == NULL) { result = 0; return (&result); diff --git a/share/examples/sunrpc/msg/printmsg.c b/share/examples/sunrpc/msg/printmsg.c index f2d5285..681007c 100644 --- a/share/examples/sunrpc/msg/printmsg.c +++ b/share/examples/sunrpc/msg/printmsg.c @@ -1,7 +1,9 @@ /* @(#)printmsg.c 2.1 88/08/11 4.0 RPCSRC */ +/* $FreeBSD$ */ /* * printmsg.c: print a message on the console */ +#include <paths.h> #include <stdio.h> main(argc, argv) @@ -33,7 +35,7 @@ printmessage(msg) { FILE *f; - f = fopen("/dev/console", "w"); + f = fopen(_PATH_CONSOLE, "w"); if (f == NULL) { return (0); } diff --git a/sys/kern/vfs_conf.c b/sys/kern/vfs_conf.c index 2c1b7a3..2ca46185 100644 --- a/sys/kern/vfs_conf.c +++ b/sys/kern/vfs_conf.c @@ -55,6 +55,7 @@ #include <sys/disklabel.h> #include <sys/conf.h> #include <sys/cons.h> +#include <paths.h> #include "opt_ddb.h" #ifdef DDB @@ -253,7 +254,7 @@ vfs_mountroot_ask(void) for(;;) { printf("\nManual root filesystem specification:\n"); printf(" <fstype>:<device> Mount <device> using filesystem <fstype>\n"); - printf(" eg. ufs:/dev/da0s1a\n"); + printf(" eg. ufs:%sda0s1a\n", _PATH_DEV); printf(" ? List valid disk boot devices\n"); printf(" <empty line> Abort manual input\n"); printf("\nmountroot> "); diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 2c1b7a3..2ca46185 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -55,6 +55,7 @@ #include <sys/disklabel.h> #include <sys/conf.h> #include <sys/cons.h> +#include <paths.h> #include "opt_ddb.h" #ifdef DDB @@ -253,7 +254,7 @@ vfs_mountroot_ask(void) for(;;) { printf("\nManual root filesystem specification:\n"); printf(" <fstype>:<device> Mount <device> using filesystem <fstype>\n"); - printf(" eg. ufs:/dev/da0s1a\n"); + printf(" eg. ufs:%sda0s1a\n", _PATH_DEV); printf(" ? List valid disk boot devices\n"); printf(" <empty line> Abort manual input\n"); printf("\nmountroot> "); diff --git a/usr.bin/doscmd/dos.c b/usr.bin/doscmd/dos.c index 0a896b1..67b43687 100644 --- a/usr.bin/doscmd/dos.c +++ b/usr.bin/doscmd/dos.c @@ -44,6 +44,7 @@ #include <glob.h> #include <errno.h> #include <ctype.h> +#include <paths.h> #include <stddef.h> #include "dispatch.h" @@ -273,7 +274,7 @@ translate_filename(u_char *dname, u_char *uname, int *drivep) if (!strcasecmp(dname, "con")) { *drivep = -1; - strcpy(uname, "/dev/tty"); + strcpy(uname, _PATH_TTY); return (0); } @@ -281,7 +282,7 @@ translate_filename(u_char *dname, u_char *uname, int *drivep) /* Really need a better way to handle devices */ if (!strcasecmp(dname, "emmxxxx0")) { *drivep = -1; - strcpy(uname, "/dev/null"); + strcpy(uname, _PATH_DEVNULL); return (0); } diff --git a/usr.bin/doscmd/doscmd.c b/usr.bin/doscmd/doscmd.c index 8b6727b..7463af6 100644 --- a/usr.bin/doscmd/doscmd.c +++ b/usr.bin/doscmd/doscmd.c @@ -39,6 +39,7 @@ #include <errno.h> #include <limits.h> +#include <paths.h> #include <pwd.h> #include <signal.h> #include <unistd.h> @@ -116,7 +117,7 @@ main(int argc, char **argv) /* XXX should only be for tty mode */ - fd = open ("/dev/null", O_RDWR); + fd = open (_PATH_DEVNULL, O_RDWR); if (fd != 3) dup2 (fd, 3); /* stdaux */ if (fd != 4) diff --git a/usr.bin/doscmd/int17.c b/usr.bin/doscmd/int17.c index d62d6da..0cb162b 100644 --- a/usr.bin/doscmd/int17.c +++ b/usr.bin/doscmd/int17.c @@ -33,6 +33,7 @@ */ #include "doscmd.h" +#include <paths.h> #include <signal.h> static int lpt_fd[4] = { -1, -1, -1, -1, }; @@ -138,7 +139,7 @@ open_printer(int printer) return; } } else { - sprintf(printer_name, "/dev/lpt%d", printer); + sprintf(printer_name, "%slpt%d", _PATH_DEV, printer); debug(D_PRINTER, "Opening device %s\n", printer_name); if ((fd = open(printer_name, O_WRONLY)) < 0) { perror(printer_name); diff --git a/usr.bin/doscmd/tty.c b/usr.bin/doscmd/tty.c index 389695c..a078812 100644 --- a/usr.bin/doscmd/tty.c +++ b/usr.bin/doscmd/tty.c @@ -44,6 +44,7 @@ #include <unistd.h> #include <sys/ioctl.h> #include <fcntl.h> +#include <paths.h> #include <signal.h> #include <sys/time.h> #ifdef __FreeBSD__ @@ -306,8 +307,8 @@ console_init() } #endif - if ((fd = open("/dev/console", 2)) < 0) { - perror("/dev/console"); + if ((fd = open(_PATH_CONSOLE, 2)) < 0) { + perror(_PATH_CONSOLE); quit(1); } @@ -2036,7 +2037,7 @@ video_init() i = 0; if (fds) for (i = 0; i < nfds && (i == 0 || fds[i-1] < 63); ++i) - if ((fds[i] = open("/dev/null", 0)) < 0) + if ((fds[i] = open(_PATH_DEVNULL, 0)) < 0) break; /* * Leave 3 fds behind for X to play with diff --git a/usr.bin/ee/ee.c b/usr.bin/ee/ee.c index 88a89e1..7284f07 100644 --- a/usr.bin/ee/ee.c +++ b/usr.bin/ee/ee.c @@ -80,6 +80,7 @@ char *version = "@(#) ee, version 1.3"; #include <err.h> #include <errno.h> #include <fcntl.h> +#include <paths.h> #include <pwd.h> #include <signal.h> #include <sys/types.h> @@ -577,7 +578,7 @@ char *argv[]; scr_pos =0; scr_vert = 0; scr_horz = 0; - bit_bucket = fopen("/dev/null", "w"); + bit_bucket = fopen(_PATH_DEVNULL, "w"); edit = TRUE; gold = case_sen = FALSE; shell_fork = TRUE; diff --git a/usr.bin/login/login_fbtab.c b/usr.bin/login/login_fbtab.c index 846033c..e0b99e3 100644 --- a/usr.bin/login/login_fbtab.c +++ b/usr.bin/login/login_fbtab.c @@ -66,6 +66,7 @@ #include <string.h> #include <errno.h> #include <dirent.h> +#include <paths.h> #include <unistd.h> #include "pathnames.h" @@ -98,7 +99,7 @@ gid_t gid; *cp = 0; /* strip comment */ if ((cp = devname = strtok(buf, WSPACE)) == 0) continue; /* empty or comment */ - if (strncmp(devname, "/dev/", 5) != 0 + if (strncmp(devname, _PATH_DEV, sizeof _PATH_DEV - 1) != 0 || (cp = strtok((char *) 0, WSPACE)) == 0 || *cp != '0' || sscanf(cp, "%o", &prot) == 0 diff --git a/usr.sbin/atm/atmarpd/atmarpd.c b/usr.sbin/atm/atmarpd/atmarpd.c index 063a304..d221a59 100644 --- a/usr.sbin/atm/atmarpd/atmarpd.c +++ b/usr.sbin/atm/atmarpd/atmarpd.c @@ -52,6 +52,7 @@ #include <errno.h> #include <fcntl.h> #include <libatm.h> +#include <paths.h> #include <stdio.h> #include <string.h> #include <syslog.h> @@ -247,7 +248,7 @@ start_daemon() atmarp_log(LOG_ERR, "can't change process group"); exit(1); } - fd = open("/dev/tty", O_RDWR); + fd = open(_PATH_TTY, O_RDWR); if (fd >= 0) { ioctl(fd, TIOCNOTTY, (char *)0); close(fd); diff --git a/usr.sbin/atm/scspd/scspd.c b/usr.sbin/atm/scspd/scspd.c index a8a6d89..a6f03f3 100644 --- a/usr.sbin/atm/scspd/scspd.c +++ b/usr.sbin/atm/scspd/scspd.c @@ -53,6 +53,7 @@ #include <errno.h> #include <fcntl.h> #include <libatm.h> +#include <paths.h> #include <stdio.h> #include <string.h> #include <syslog.h> @@ -284,7 +285,7 @@ start_daemon() scsp_log(LOG_ERR, "can't change process group"); exit(1); } - fd = open("/dev/tty", O_RDWR); + fd = open(_PATH_TTY, O_RDWR); if (fd >= 0) { ioctl(fd, TIOCNOTTY, (char *)0); close(fd); diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index d5a754e..0161bdd 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -26,6 +26,7 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> #include <errno.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -1141,7 +1142,7 @@ int open_cd () if (*cdname == '/') { snprintf (devbuf, MAXPATHLEN, "%s", cdname); } else { - snprintf (devbuf, MAXPATHLEN, "/dev/%s", cdname); + snprintf (devbuf, MAXPATHLEN, "%s%s", _PATH_DEV, cdname); } fd = open (devbuf, O_RDONLY); diff --git a/usr.sbin/cron/cron/popen.c b/usr.sbin/cron/cron/popen.c index 1ac775d..f22f421 100644 --- a/usr.sbin/cron/cron/popen.c +++ b/usr.sbin/cron/cron/popen.c @@ -34,6 +34,7 @@ static const char rcsid[] = #include "cron.h" #include <sys/signal.h> #include <fcntl.h> +#include <paths.h> #if defined(SYSLOG) # include <syslog.h> #endif @@ -130,7 +131,7 @@ cron_popen(program, type, e) if (*type == 'r') { /* Do not share our parent's stdin */ (void)close(0); - (void)open("/dev/null", O_RDWR); + (void)open(_PATH_DEVNULL, O_RDWR); if (pdes[1] != 1) { dup2(pdes[1], 1); dup2(pdes[1], 2); /* stderr, too! */ @@ -144,9 +145,9 @@ cron_popen(program, type, e) } /* Hack: stdout gets revoked */ (void)close(1); - (void)open("/dev/null", O_RDWR); + (void)open(_PATH_DEVNULL, O_RDWR); (void)close(2); - (void)open("/dev/null", O_RDWR); + (void)open(_PATH_DEVNULL, O_RDWR); (void)close(pdes[1]); } # if defined(LOGIN_CAP) diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c index 0071f6a..8ee2ccb 100644 --- a/usr.sbin/cron/crontab/crontab.c +++ b/usr.sbin/cron/crontab/crontab.c @@ -31,6 +31,7 @@ static const char rcsid[] = #include "cron.h" #include <errno.h> #include <fcntl.h> +#include <paths.h> #include <sys/file.h> #include <sys/stat.h> #ifdef USE_UTIMES @@ -297,8 +298,8 @@ edit_cmd() { if (errno != ENOENT) err(ERROR_EXIT, "%s", n); warnx("no crontab for %s - using an empty one", User); - if (!(f = fopen("/dev/null", "r"))) - err(ERROR_EXIT, "/dev/null"); + if (!(f = fopen(_PATH_DEVNULL, "r"))) + err(ERROR_EXIT, _PATH_DEVNULL); } um = umask(077); diff --git a/usr.sbin/cron/lib/compat.c b/usr.sbin/cron/lib/compat.c index 6057b86..9686012 100644 --- a/usr.sbin/cron/lib/compat.c +++ b/usr.sbin/cron/lib/compat.c @@ -32,6 +32,7 @@ static char rcsid[] = "$FreeBSD$"; # include <sys/ioctl.h> #endif #include <errno.h> +#include <paths.h> /* the code does not depend on any of vfork's @@ -109,7 +110,7 @@ setsid() # else newpgrp = setpgrp(0, getpid()); # endif - if ((fd = open("/dev/tty", 2)) >= 0) + if ((fd = open(_PATH_TTY, 2)) >= 0) { (void) ioctl(fd, TIOCNOTTY, (char*)0); (void) close(fd); @@ -117,9 +118,9 @@ setsid() # else /*BSD*/ newpgrp = setpgrp(); - (void) close(STDIN); (void) open("/dev/null", 0); - (void) close(STDOUT); (void) open("/dev/null", 1); - (void) close(STDERR); (void) open("/dev/null", 2); + (void) close(STDIN); (void) open(_PATH_DEVNULL, 0); + (void) close(STDOUT); (void) open(_PATH_DEVNULL, 1); + (void) close(STDERR); (void) open(_PATH_DEVNULL, 2); # endif /*BSD*/ return newpgrp; } diff --git a/usr.sbin/ctm/mkCTM/mkctm.c b/usr.sbin/ctm/mkCTM/mkctm.c index 55e2361..336e824 100644 --- a/usr.sbin/ctm/mkCTM/mkctm.c +++ b/usr.sbin/ctm/mkCTM/mkctm.c @@ -1,3 +1,5 @@ +/* $FreeBSD$ */ + /* Still missing: * * mkctm @@ -27,6 +29,7 @@ #include <unistd.h> #include <md5.h> #include <err.h> +#include <paths.h> #include <signal.h> #define DEFAULT_IGNORE "/CVS$|/\\.#|00_TRANS\\.TBL$" @@ -560,7 +563,7 @@ main(int argc, char **argv) argv += optind; if (!logf) - logf = fopen("/dev/null", "w"); + logf = fopen(_PATH_DEVNULL, "w"); setbuf(stdout, 0); diff --git a/usr.sbin/fdformat/fdformat.c b/usr.sbin/fdformat/fdformat.c index 53db668..3d6b998 100644 --- a/usr.sbin/fdformat/fdformat.c +++ b/usr.sbin/fdformat/fdformat.c @@ -43,6 +43,7 @@ #include <ctype.h> #include <err.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <strings.h> @@ -130,7 +131,7 @@ makename(const char *arg, const char *suffix) return arg; if(*arg == '/') /* do not convert absolute pathnames */ return arg; - strcpy(namebuff, "/dev/"); + strcpy(namebuff, _PATH_DEV); strncat(namebuff, arg, 3); strcat(namebuff, suffix); return namebuff; diff --git a/usr.sbin/fdwrite/fdwrite.c b/usr.sbin/fdwrite/fdwrite.c index 4ab858e..00279c5 100644 --- a/usr.sbin/fdwrite/fdwrite.c +++ b/usr.sbin/fdwrite/fdwrite.c @@ -13,6 +13,7 @@ #include <ctype.h> #include <err.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <strings.h> @@ -106,9 +107,9 @@ main(int argc, char **argv) if(optind < argc) usage(); - tty = fopen("/dev/tty","r+"); + tty = fopen(_PATH_TTY,"r+"); if(!tty) - err(1, "/dev/tty"); + err(1, _PATH_TTY); setbuf(tty,0); for(j=1;j > 0;) { diff --git a/usr.sbin/i4b/isdnd/exec.c b/usr.sbin/i4b/isdnd/exec.c index db08e77..180b97ab 100644 --- a/usr.sbin/i4b/isdnd/exec.c +++ b/usr.sbin/i4b/isdnd/exec.c @@ -42,6 +42,7 @@ #include <net/if.h> #include <netinet/in.h> #include <arpa/inet.h> +#include <paths.h> #define MAX_PIDS 32 @@ -214,7 +215,8 @@ exec_answer(cfg_entry_t *cep) device = bdrivername(cep->usrdevicename); - snprintf(devicename, sizeof(devicename), "/dev/i4b%s%d", device, cep->usrdeviceunit); + snprintf(devicename, sizeof(devicename), "%si4b%s%d", _PATH_DEV, device, + cep->usrdeviceunit); argv[0] = cep->answerprog; argv[1] = "-D"; diff --git a/usr.sbin/i4b/isdnd/main.c b/usr.sbin/i4b/isdnd/main.c index 9c172e0..292b9da 100644 --- a/usr.sbin/i4b/isdnd/main.c +++ b/usr.sbin/i4b/isdnd/main.c @@ -36,6 +36,7 @@ *---------------------------------------------------------------------------*/ #include <locale.h> +#include <paths.h> #ifdef I4B_EXTERNAL_MONITOR #include "monitor.h" @@ -709,7 +710,7 @@ isdnrdhdl(void) break; default: - log(LL_WRN, "ERROR, unknown message received from /dev/isdn (0x%x)", msg_rd_buf[0]); + log(LL_WRN, "ERROR, unknown message received from %sisdn (0x%x)", _PATH_DEV, msg_rd_buf[0]); break; } } diff --git a/usr.sbin/i4b/isdntelctl/main.c b/usr.sbin/i4b/isdntelctl/main.c index 4820fbd..3d75663 100644 --- a/usr.sbin/i4b/isdntelctl/main.c +++ b/usr.sbin/i4b/isdntelctl/main.c @@ -38,6 +38,7 @@ #include <stdio.h> #include <signal.h> #include <errno.h> +#include <paths.h> #include <string.h> #include <stdlib.h> #include <unistd.h> @@ -212,7 +213,7 @@ static void usage(void) { fprintf(stderr, "\n"); - fprintf(stderr, "isdntelctl - /dev/i4btel control, version %d.%d.%d (%s %s)\n",VERSION, REL, STEP, __DATE__, __TIME__); + fprintf(stderr, "isdntelctl - %si4btel control, version %d.%d.%d (%s %s)\n", _PATH_DEV, VERSION, REL, STEP, __DATE__, __TIME__); fprintf(stderr, "usage: isdntelctl -c -g -u <unit> -A -N -U\n"); fprintf(stderr, " -c clear input queue\n"); fprintf(stderr, " -g get current settings\n"); diff --git a/usr.sbin/memcontrol/memcontrol.c b/usr.sbin/memcontrol/memcontrol.c index e66f2a4..456ac07 100644 --- a/usr.sbin/memcontrol/memcontrol.c +++ b/usr.sbin/memcontrol/memcontrol.c @@ -32,6 +32,7 @@ #include <err.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -107,8 +108,8 @@ main(int argc, char *argv[]) if (argc < 2) { help(NULL); } else { - if ((memfd = open("/dev/mem", O_RDONLY)) == -1) - err(1, "can't open /dev/mem"); + if ((memfd = open(_PATH_MEM, O_RDONLY)) == -1) + err(1, "can't open %s", _PATH_MEM); for (i = 0; functions[i].cmd != NULL; i++) if (!strcmp(argv[1], functions[i].cmd)) diff --git a/usr.sbin/mptable/mptable.c b/usr.sbin/mptable/mptable.c index ef780f0..784b415 100644 --- a/usr.sbin/mptable/mptable.c +++ b/usr.sbin/mptable/mptable.c @@ -49,6 +49,7 @@ static const char rcsid[] = #include <sys/types.h> #include <err.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -350,7 +351,7 @@ main( int argc, char *argv[] ) } /* open physical memory for access to MP structures */ - if ( (pfd = open( "/dev/mem", O_RDONLY )) < 0 ) + if ( (pfd = open( _PATH_MEM, O_RDONLY )) < 0 ) err( 1, "mem open" ); /* probe for MP structures */ @@ -866,7 +867,7 @@ static void seekEntry( vm_offset_t addr ) { if ( lseek( pfd, (off_t)addr, SEEK_SET ) < 0 ) - err( 1, "/dev/mem seek" ); + err( 1, "%s seek", _PATH_MEM ); } diff --git a/usr.sbin/mrouted/main.c b/usr.sbin/mrouted/main.c index f3fc676..87ab3ff 100644 --- a/usr.sbin/mrouted/main.c +++ b/usr.sbin/mrouted/main.c @@ -33,6 +33,7 @@ static const char rcsid[] = #include <varargs.h> #endif #include <fcntl.h> +#include <paths.h> #ifdef SNMP #include "snmp.h" @@ -384,7 +385,7 @@ main(argc, argv) (void)setpgrp(); #else #ifdef TIOCNOTTY - t = open("/dev/tty", 2); + t = open(_PATH_TTY, 2); if (t >= 0) { (void)ioctl(t, TIOCNOTTY, (char *)0); (void)close(t); diff --git a/usr.sbin/pcvt/cursor/cursor.c b/usr.sbin/pcvt/cursor/cursor.c index 1c7c140..e4da01a 100644 --- a/usr.sbin/pcvt/cursor/cursor.c +++ b/usr.sbin/pcvt/cursor/cursor.c @@ -34,7 +34,7 @@ */ static char *id = - "@(#)cursor.c, 3.20, Last Edit-Date: [Tue Apr 4 12:27:54 1995]"; + "@(#)cursor.c, 3.20, Last Edit-Date: [Tue Apr 4 12:27:54 1995]\n$FreeBSD$"; /*---------------------------------------------------------------------------* * @@ -48,6 +48,7 @@ static char *id = #include <fcntl.h> #include <sys/stat.h> #include <machine/pcvt_ioctl.h> +#include <paths.h> #define DEFAULTFD 0 @@ -148,7 +149,7 @@ usage() { fprintf(stderr,"\ncursor - set cursor shape for pcvt video driver\n"); fprintf(stderr,"usage: cursor -d [device] -n [no] -s [line] -e [line]\n"); - fprintf(stderr," -d <device> device to use (/dev/ttyvX), default current\n"); + fprintf(stderr," -d <device> device to use (%svX), default current\n", _PATH_TTY); fprintf(stderr," -n <no> screen no if specified, else current screen\n"); fprintf(stderr," -s <line> start scan line (topmost scan line)\n"); fprintf(stderr," -e <line> ending scan line (bottom scan line)\n\n"); diff --git a/usr.sbin/pcvt/vttest/main.c b/usr.sbin/pcvt/vttest/main.c index 02cbc62..341de73 100644 --- a/usr.sbin/pcvt/vttest/main.c +++ b/usr.sbin/pcvt/vttest/main.c @@ -15,6 +15,8 @@ choice to the address below. */ +/* $FreeBSD$ */ + #include "header.h" char inchar(), *instr(), *lookup(); @@ -1846,7 +1848,7 @@ initterminal(pn) int pn; { stty(0,&sgttyNew); #ifdef SIII close(2); - open("/dev/tty",O_RDWR|O_NDELAY); + open(_PATH_TTY,O_RDWR|O_NDELAY); #endif #endif #ifdef SARG10 diff --git a/usr.sbin/pim6dd/main.c b/usr.sbin/pim6dd/main.c index 2cf17f5..5e518b4 100644 --- a/usr.sbin/pim6dd/main.c +++ b/usr.sbin/pim6dd/main.c @@ -52,6 +52,7 @@ * $FreeBSD$ */ +#include <paths.h> #include "defs.h" #ifdef SNMP @@ -424,7 +425,7 @@ main(argc, argv) (void)setpgrp(); #else #ifdef TIOCNOTTY - t = open("/dev/tty", 2); + t = open(_PATH_TTY, 2); if (t >= 0) { (void)ioctl(t, TIOCNOTTY, (char *)0); (void)close(t); diff --git a/usr.sbin/pim6sd/main.c b/usr.sbin/pim6sd/main.c index 0024286..e4ae450 100644 --- a/usr.sbin/pim6sd/main.c +++ b/usr.sbin/pim6sd/main.c @@ -60,6 +60,7 @@ #include <sys/param.h> #include <sys/time.h> #include <errno.h> +#include <paths.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> @@ -466,7 +467,7 @@ usage: (void) setpgrp(); #else #ifdef TIOCNOTTY - t = open("/dev/tty", 2); + t = open(_PATH_TTY, 2); if (t >= 0) { (void) ioctl(t, TIOCNOTTY, (char *) 0); diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index a8bb500..9422c54 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -24,6 +24,7 @@ static const char rcsid[] = */ #include <err.h> +#include <paths.h> #include "lib.h" #include "add.h" @@ -363,9 +364,9 @@ pkg_do(char *pkg) printf("Running mtree for %s..\n", PkgName); p = find_plist(&Plist, PLIST_CWD); if (Verbose) - printf("mtree -U -f %s -d -e -p %s >/dev/null\n", MTREE_FNAME, p ? p->name : "/"); + printf("mtree -U -f %s -d -e -p %s >%s\n", MTREE_FNAME, p ? p->name : "/", _PATH_DEVNULL); if (!Fake) { - if (vsystem("/usr/sbin/mtree -U -f %s -d -e -p %s >/dev/null", MTREE_FNAME, p ? p->name : "/")) + if (vsystem("/usr/sbin/mtree -U -f %s -d -e -p %s >%s", MTREE_FNAME, p ? p->name : "/"), _PATH_DEVNULL) warnx("mtree returned a non-zero status - continuing"); } unlink(MTREE_FNAME); diff --git a/usr.sbin/pkg_install/lib/msg.c b/usr.sbin/pkg_install/lib/msg.c index 43dd7e6..068d305 100644 --- a/usr.sbin/pkg_install/lib/msg.c +++ b/usr.sbin/pkg_install/lib/msg.c @@ -25,6 +25,7 @@ static const char rcsid[] = */ #include <err.h> +#include <paths.h> #include "lib.h" /* Die a relatively simple death */ @@ -51,10 +52,10 @@ y_or_n(Boolean def, const char *msg, ...) * Need to open /dev/tty because file collection may have been * collected on stdin */ - tty = fopen("/dev/tty", "r"); + tty = fopen(_PATH_TTY, "r"); if (!tty) { cleanup(0); - errx(2, "can't open /dev/tty!"); + errx(2, "can't open %s!", _PATH_TTY); } while (ch != 'Y' && ch != 'N') { vfprintf(stderr, msg, args); diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c index 4cc40cb..2a580e9 100644 --- a/usr.sbin/pppd/auth.c +++ b/usr.sbin/pppd/auth.c @@ -41,6 +41,7 @@ static char rcsid[] = "$FreeBSD$"; #include <stdlib.h> #include <unistd.h> #include <syslog.h> +#include <paths.h> #include <pwd.h> #include <string.h> #include <sys/types.h> @@ -965,7 +966,7 @@ plogin(user, passwd, msg, msglen) /* Log in wtmp and utmp using login() */ tty = devnam; - if (strncmp(tty, "/dev/", 5) == 0) + if (strncmp(tty, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) tty += 5; if (logout(tty)) /* Already entered (by login?) */ @@ -1031,7 +1032,7 @@ plogout() char *tty; tty = devnam; - if (strncmp(tty, "/dev/", 5) == 0) + if (strncmp(tty, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) tty += 5; logwtmp(tty, "", ""); /* Wipe out wtmp logout entry */ logout(tty); /* Wipe out utmp */ diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c index f18131c..0676e3c 100644 --- a/usr.sbin/pppd/options.c +++ b/usr.sbin/pppd/options.c @@ -31,6 +31,7 @@ static char rcsid[] = "$FreeBSD$"; #include <syslog.h> #include <string.h> #include <netdb.h> +#include <paths.h> #include <pwd.h> #include <sys/types.h> #include <sys/stat.h> @@ -80,7 +81,7 @@ int dflag = 0; /* Tell libpcap we want debugging */ int debug = 0; /* Debug flag */ int kdebugflag = 0; /* Tell kernel to print debug messages */ int default_device = 1; /* Using /dev/tty or equivalent */ -char devnam[MAXPATHLEN] = "/dev/tty"; /* Device name */ +char devnam[MAXPATHLEN] = _PATH_TTY; /* Device name */ int crtscts = 0; /* Use hardware flow control */ int modem = 1; /* Use modem control lines */ int inspeed = 0; /* Input/Output speed requested */ @@ -694,7 +695,7 @@ options_for_tty() int ret; dev = devnam; - if (strncmp(dev, "/dev/", 5) == 0) + if (strncmp(dev, _PATH_DEV, sizeof _PATH_DEV - 1) == 0) dev += 5; if (strcmp(dev, "tty") == 0) return 1; /* don't look for /etc/ppp/options.tty */ @@ -1671,9 +1672,9 @@ setdevname(cp, quiet) if (*cp == 0) return 0; - if (strncmp("/dev/", cp, 5) != 0) { - strcpy(dev, "/dev/"); - strncat(dev, cp, MAXPATHLEN - 5); + if (strncmp(_PATH_DEV, cp, sizeof _PATH_DEV - 1) != 0) { + strcpy(dev, _PATH_DEV); + strncat(dev, cp, MAXPATHLEN - sizeof _PATH_DEV - 1); dev[MAXPATHLEN-1] = 0; cp = dev; } diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c index d854c92..ca3a10a 100644 --- a/usr.sbin/pw/pw.c +++ b/usr.sbin/pw/pw.c @@ -206,7 +206,7 @@ main(int argc, char *argv[]) * don't bother with extraneous errors */ if (getarg(&arglist, 'q') != NULL) - freopen("/dev/null", "w", stderr); + freopen(_PATH_DEVNULL, "w", stderr); /* * Set our base working path if not overridden diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index ceef657..01f822e 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -44,6 +44,7 @@ static const char rcsid[] = #include <err.h> #include <fcntl.h> #include <errno.h> +#include <paths.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> @@ -569,7 +570,7 @@ main(argc,argv) for (; --cnt >= 0; mp++) { if (!strncmp(mp->f_fstypename, "ufs", MFSNAMELEN)) { if ((nm = strrchr(mp->f_mntfromname,'/'))) { - sprintf(dev,"/dev/%s",nm + 1); + sprintf(dev,"%s%s",_PATH_DEV,nm + 1); nm = dev; } else nm = mp->f_mntfromname; diff --git a/usr.sbin/rpc.ypxfrd/ypxfrd_main.c b/usr.sbin/rpc.ypxfrd/ypxfrd_main.c index 50a5793..e83b997 100644 --- a/usr.sbin/rpc.ypxfrd/ypxfrd_main.c +++ b/usr.sbin/rpc.ypxfrd/ypxfrd_main.c @@ -38,6 +38,7 @@ static const char rcsid[] = #include "ypxfrd.h" #include <err.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> /* getenv, exit */ #include <unistd.h> @@ -240,10 +241,10 @@ main(argc, argv) size = getdtablesize(); for (i = 0; i < size; i++) (void) close(i); - i = open("/dev/console", 2); + i = open(_PATH_CONSOLE, 2); (void) dup2(i, 1); (void) dup2(i, 2); - i = open("/dev/tty", 2); + i = open(_PATH_TTY, 2); if (i >= 0) { (void) ioctl(i, TIOCNOTTY, (char *)NULL); (void) close(i); diff --git a/usr.sbin/sicontrol/sicontrol.c b/usr.sbin/sicontrol/sicontrol.c index 88e1770..eb6560f 100644 --- a/usr.sbin/sicontrol/sicontrol.c +++ b/usr.sbin/sicontrol/sicontrol.c @@ -39,6 +39,7 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> #include <fcntl.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -156,7 +157,7 @@ main(int argc, char **argv) if (strchr(Devname, '/') == NULL) { char *acp = malloc(6 + strlen(Devname)); - strcpy(acp, "/dev/"); + strcpy(acp, _PATH_DEV); strcat(acp, Devname); Devname = acp; } diff --git a/usr.sbin/sliplogin/sliplogin.c b/usr.sbin/sliplogin/sliplogin.c index e8c2f0c..5295682 100644 --- a/usr.sbin/sliplogin/sliplogin.c +++ b/usr.sbin/sliplogin/sliplogin.c @@ -39,6 +39,7 @@ static char copyright[] = #ifndef lint static char sccsid[] = "@(#)sliplogin.c 8.2 (Berkeley) 2/1/94"; +static char rscid[] = "@(#)$FreeBSD$"; #endif /* not lint */ /* @@ -82,6 +83,7 @@ static char sccsid[] = "@(#)sliplogin.c 8.2 (Berkeley) 2/1/94"; #include <stdio.h> #include <errno.h> #include <ctype.h> +#include <paths.h> #include <string.h> #include <unistd.h> #include <stdlib.h> @@ -375,7 +377,7 @@ main(argc, argv) FILE *iffile; /* interfaces file */ char *p; int n; - char devnam[MAXPATHLEN] = "/dev/tty"; /* Device name */ + char devnam[MAXPATHLEN] = _PATH_TTY; /* Device name */ if ((name = strrchr(argv[0], '/')) == NULL) name = argv[0]; @@ -510,7 +512,7 @@ main(argc, argv) (void) close(1); if ((fd = open(_PATH_DEVNULL, O_WRONLY)) != 1) { if (fd < 0) { - syslog(LOG_ERR, "open /dev/null: %m"); + syslog(LOG_ERR, "open %s: %m", _PATH_DEVNULL); exit(1); } (void) dup2(fd, 1); diff --git a/usr.sbin/vnconfig/vnconfig.c b/usr.sbin/vnconfig/vnconfig.c index c80d0db..11f9324 100644 --- a/usr.sbin/vnconfig/vnconfig.c +++ b/usr.sbin/vnconfig/vnconfig.c @@ -49,6 +49,7 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> #include <errno.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> @@ -263,7 +264,7 @@ config(vnp) * Operate on vnp->dev because it is used later. */ if (vnp->dev[0] != '/' && vnp->dev[0] != '.') - (void)asprintf(&vnp->dev, "/dev/%s", vnp->dev); + (void)asprintf(&vnp->dev, "%s%s", _PATH_DEV, vnp->dev); dev = vnp->dev; file = vnp->file; flags = vnp->flags; diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c index 817f7fc..da80260 100644 --- a/usr.sbin/watch/watch.c +++ b/usr.sbin/watch/watch.c @@ -26,6 +26,7 @@ static const char rcsid[] = #include <err.h> #include <locale.h> +#include <paths.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -139,7 +140,7 @@ fatal(err, buf) int open_snp() { - char snp[] = {"/dev/snpX"}; + char snp[] = {_PATH_DEV "snpX"}; char c; int f, mode; @@ -233,14 +234,14 @@ set_dev(name) char buf[DEV_NAME_LEN]; struct stat sb; - if (strlen(name) > 5 && !strncmp(name, "/dev/", 5)) { + if (strlen(name) > 5 && !strncmp(name, _PATH_DEV, sizeof _PATH_DEV - 1)) { snprintf(buf, sizeof buf, "%s", name); } else { if (strlen(name) == 2) - sprintf(buf, "/dev/tty%s", name); + sprintf(buf, "%s%s", _PATH_TTY, name); else - sprintf(buf, "/dev/%s", name); + sprintf(buf, "%s%s", _PATH_DEV, name); } if (*name == '\0' || stat(buf, &sb) < 0) |