Browse Source

knf; otto ok

OPENBSD_3_6
deraadt 20 years ago
parent
commit
2462bc4b83
14 changed files with 77 additions and 117 deletions
  1. +4
    -3
      src/lib/libutil/fmt_scaled.c
  2. +10
    -22
      src/lib/libutil/fparseln.c
  3. +2
    -2
      src/lib/libutil/getmaxpartitions.c
  4. +2
    -2
      src/lib/libutil/getrawpartition.c
  5. +3
    -4
      src/lib/libutil/login.c
  6. +3
    -4
      src/lib/libutil/login_tty.c
  7. +3
    -4
      src/lib/libutil/logout.c
  8. +4
    -5
      src/lib/libutil/logwtmp.c
  9. +4
    -8
      src/lib/libutil/opendev.c
  10. +2
    -7
      src/lib/libutil/opendisk.c
  11. +3
    -3
      src/lib/libutil/pidfile.c
  12. +11
    -13
      src/lib/libutil/pty.c
  13. +14
    -17
      src/lib/libutil/readlabel.c
  14. +12
    -23
      src/lib/libutil/uucplock.c

+ 4
- 3
src/lib/libutil/fmt_scaled.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: fmt_scaled.c,v 1.2 2003/12/27 19:49:51 otto Exp $ */
/* $OpenBSD: fmt_scaled.c,v 1.3 2004/05/28 07:03:47 deraadt Exp $ */
/* /*
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved. * Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@ -37,7 +37,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static const char ident[] = "$OpenBSD: fmt_scaled.c,v 1.2 2003/12/27 19:49:51 otto Exp $";
static const char ident[] = "$OpenBSD: fmt_scaled.c,v 1.3 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <stdio.h> #include <stdio.h>
@ -126,7 +126,8 @@ scan_scaled(char *scaled, long long *result)
i = (*p) - '0'; /* whew! finally a digit we can use */ i = (*p) - '0'; /* whew! finally a digit we can use */
if (fract_digits > 0) { if (fract_digits > 0) {
if (fract_digits >= MAX_DIGITS-1) if (fract_digits >= MAX_DIGITS-1)
continue; /* ignore extra fractional digits */
/* ignore extra fractional digits */
continue;
fract_digits++; /* for later scaling */ fract_digits++; /* for later scaling */
fpart *= 10; fpart *= 10;
fpart += i; fpart += i;


+ 10
- 22
src/lib/libutil/fparseln.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: fparseln.c,v 1.4 2002/06/09 22:18:43 fgsch Exp $ */
/* $OpenBSD: fparseln.c,v 1.5 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: fparseln.c,v 1.7 1999/07/02 15:49:12 simonb Exp $ */ /* $NetBSD: fparseln.c,v 1.7 1999/07/02 15:49:12 simonb Exp $ */
/* /*
@ -31,7 +31,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$OpenBSD: fparseln.c,v 1.4 2002/06/09 22:18:43 fgsch Exp $";
static const char rcsid[] = "$OpenBSD: fparseln.c,v 1.5 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -49,9 +49,7 @@ static int isescaped(const char *, const char *, int);
* that starts in *sp, is escaped by the escape character esc. * that starts in *sp, is escaped by the escape character esc.
*/ */
static int static int
isescaped(sp, p, esc)
const char *sp, *p;
int esc;
isescaped(const char *sp, const char *p, int esc)
{ {
const char *cp; const char *cp;
size_t ne; size_t ne;
@ -75,24 +73,13 @@ isescaped(sp, p, esc)
* the comment char. * the comment char.
*/ */
char * char *
fparseln(fp, size, lineno, str, flags)
FILE *fp;
size_t *size;
size_t *lineno;
const char str[3];
int flags;
fparseln(FILE *fp, size_t *size, size_t *lineno, const char str[3],
int flags)
{ {
static const char dstr[3] = { '\\', '\\', '#' }; static const char dstr[3] = { '\\', '\\', '#' };
size_t s, len;
char *buf;
char *ptr, *cp;
int cnt;
char esc, con, nl, com;
len = 0;
buf = NULL;
cnt = 1;
char *buf = NULL, *ptr, *cp, esc, con, nl, com;
size_t s, len = 0;
int cnt = 1;
if (str == NULL) if (str == NULL)
str = dstr; str = dstr;
@ -100,6 +87,7 @@ fparseln(fp, size, lineno, str, flags)
esc = str[0]; esc = str[0];
con = str[1]; con = str[1];
com = str[2]; com = str[2];
/* /*
* XXX: it would be cool to be able to specify the newline character, * XXX: it would be cool to be able to specify the newline character,
* but unfortunately, fgetln does not let us * but unfortunately, fgetln does not let us
@ -124,7 +112,7 @@ fparseln(fp, size, lineno, str, flags)
} }
} }
if (s && nl) { /* Check and eliminate newlines */
if (s && nl) { /* Check and eliminate newlines */
cp = &ptr[s - 1]; cp = &ptr[s - 1];
if (*cp == nl) if (*cp == nl)


+ 2
- 2
src/lib/libutil/getmaxpartitions.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: getmaxpartitions.c,v 1.3 2002/06/09 22:18:43 fgsch Exp $ */
/* $OpenBSD: getmaxpartitions.c,v 1.4 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:31 thorpej Exp $ */ /* $NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:31 thorpej Exp $ */
/*- /*-
@ -47,7 +47,7 @@ static const char rcsid[] = "$NetBSD: getmaxpartitions.c,v 1.1 1996/05/16 07:03:
#include "util.h" #include "util.h"
int int
getmaxpartitions()
getmaxpartitions(void)
{ {
int maxpart, mib[2]; int maxpart, mib[2];
size_t varlen; size_t varlen;


+ 2
- 2
src/lib/libutil/getrawpartition.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: getrawpartition.c,v 1.3 2002/06/09 22:18:43 fgsch Exp $ */
/* $OpenBSD: getrawpartition.c,v 1.4 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:33 thorpej Exp $ */ /* $NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:33 thorpej Exp $ */
/*- /*-
@ -47,7 +47,7 @@ static const char rcsid[] = "$NetBSD: getrawpartition.c,v 1.1 1996/05/16 07:03:3
#include "util.h" #include "util.h"
int int
getrawpartition()
getrawpartition(void)
{ {
int rawpart, mib[2]; int rawpart, mib[2];
size_t varlen; size_t varlen;


+ 3
- 4
src/lib/libutil/login.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: login.c,v 1.8 2003/06/02 20:18:42 millert Exp $ */
/* $OpenBSD: login.c,v 1.9 2004/05/28 07:03:47 deraadt Exp $ */
/* /*
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93"; */ /* from: static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93"; */
static const char rcsid[] = "$Id: login.c,v 1.8 2003/06/02 20:18:42 millert Exp $";
static const char rcsid[] = "$Id: login.c,v 1.9 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/types.h> #include <sys/types.h>
@ -45,8 +45,7 @@ static const char rcsid[] = "$Id: login.c,v 1.8 2003/06/02 20:18:42 millert Exp
#include "util.h" #include "util.h"
void void
login(utp)
struct utmp *utp;
login(struct utmp *utp)
{ {
struct utmp old_ut; struct utmp old_ut;
register int fd; register int fd;


+ 3
- 4
src/lib/libutil/login_tty.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: login_tty.c,v 1.5 2003/06/02 20:18:42 millert Exp $ */
/* $OpenBSD: login_tty.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $ */
/*- /*-
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; */ /* from: static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; */
static const char rcsid[] = "$Id: login_tty.c,v 1.5 2003/06/02 20:18:42 millert Exp $";
static const char rcsid[] = "$Id: login_tty.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/param.h> #include <sys/param.h>
@ -40,8 +40,7 @@ static const char rcsid[] = "$Id: login_tty.c,v 1.5 2003/06/02 20:18:42 millert
#include "util.h" #include "util.h"
int int
login_tty(fd)
int fd;
login_tty(int fd)
{ {
(void) setsid(); (void) setsid();
if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1)


+ 3
- 4
src/lib/libutil/logout.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: logout.c,v 1.6 2003/06/02 20:18:42 millert Exp $ */
/* $OpenBSD: logout.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $ */
/* /*
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93"; */ /* from: static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93"; */
static const char rcsid[] = "$Id: logout.c,v 1.6 2003/06/02 20:18:42 millert Exp $";
static const char rcsid[] = "$Id: logout.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/types.h> #include <sys/types.h>
@ -47,8 +47,7 @@ static const char rcsid[] = "$Id: logout.c,v 1.6 2003/06/02 20:18:42 millert Exp
typedef struct utmp UTMP; typedef struct utmp UTMP;
int int
logout(line)
const char *line;
logout(const char *line)
{ {
int fd, rval; int fd, rval;
UTMP ut; UTMP ut;


+ 4
- 5
src/lib/libutil/logwtmp.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: logwtmp.c,v 1.6 2003/06/02 20:18:42 millert Exp $ */
/* $OpenBSD: logwtmp.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $ */
/* /*
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -30,7 +30,7 @@
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; */ /* from: static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; */
static const char rcsid[] = "$Id: logwtmp.c,v 1.6 2003/06/02 20:18:42 millert Exp $";
static const char rcsid[] = "$Id: logwtmp.c,v 1.7 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/types.h> #include <sys/types.h>
@ -45,11 +45,10 @@ static const char rcsid[] = "$Id: logwtmp.c,v 1.6 2003/06/02 20:18:42 millert Ex
#include "util.h" #include "util.h"
void void
logwtmp(line, name, host)
const char *line, *name, *host;
logwtmp(const char *line, const char *name, const char *host)
{ {
struct utmp ut;
struct stat buf; struct stat buf;
struct utmp ut;
int fd; int fd;
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)


+ 4
- 8
src/lib/libutil/opendev.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: opendev.c,v 1.7 2002/06/09 22:18:43 fgsch Exp $ */
/* $OpenBSD: opendev.c,v 1.8 2004/05/28 07:03:47 deraadt Exp $ */
/* /*
* Copyright (c) 2000, Todd C. Miller. All rights reserved. * Copyright (c) 2000, Todd C. Miller. All rights reserved.
@ -41,15 +41,11 @@
*/ */
int int
opendev(path, oflags, dflags, realpath)
char *path;
int oflags;
int dflags;
char **realpath;
opendev(char *path, int oflags, int dflags, char **realpath)
{ {
int fd;
char *slash, *prefix;
static char namebuf[PATH_MAX]; static char namebuf[PATH_MAX];
char *slash, *prefix;
int fd;
/* Initial state */ /* Initial state */
if (realpath) if (realpath)


+ 2
- 7
src/lib/libutil/opendisk.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: opendisk.c,v 1.2 2001/08/16 18:34:40 millert Exp $ */
/* $OpenBSD: opendisk.c,v 1.3 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: opendisk.c,v 1.4 1997/09/30 17:13:50 phil Exp $ */ /* $NetBSD: opendisk.c,v 1.4 1997/09/30 17:13:50 phil Exp $ */
/*- /*-
@ -49,12 +49,7 @@
#include "util.h" #include "util.h"
int int
opendisk(path, flags, buf, buflen, iscooked)
const char *path;
int flags;
char *buf;
size_t buflen;
int iscooked;
opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked)
{ {
int f, rawpart; int f, rawpart;


+ 3
- 3
src/lib/libutil/pidfile.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraadt Exp $ */
/* $OpenBSD: pidfile.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $ */
/* $NetBSD: pidfile.c,v 1.4 2001/02/19 22:43:42 cgd Exp $ */ /* $NetBSD: pidfile.c,v 1.4 2001/02/19 22:43:42 cgd Exp $ */
/*- /*-
@ -38,7 +38,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$OpenBSD: pidfile.c,v 1.5 2002/05/26 09:29:02 deraadt Exp $";
static const char rcsid[] = "$OpenBSD: pidfile.c,v 1.6 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/param.h> #include <sys/param.h>
@ -59,9 +59,9 @@ extern char *__progname;
int int
pidfile(const char *basename) pidfile(const char *basename)
{ {
FILE *f;
int save_errno; int save_errno;
pid_t pid; pid_t pid;
FILE *f;
if (basename == NULL) if (basename == NULL)
basename = __progname; basename = __progname;


+ 11
- 13
src/lib/libutil/pty.c View File

@ -1,4 +1,5 @@
/* $OpenBSD: pty.c,v 1.12 2004/04/11 18:04:36 millert Exp $ */
/* $OpenBSD: pty.c,v 1.13 2004/05/28 07:03:47 deraadt Exp $ */
/*- /*-
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -30,7 +31,7 @@
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
/* from: static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93"; */ /* from: static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93"; */
static const char rcsid[] = "$Id: pty.c,v 1.12 2004/04/11 18:04:36 millert Exp $";
static const char rcsid[] = "$Id: pty.c,v 1.13 2004/05/28 07:03:47 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h> #include <sys/cdefs.h>
@ -52,32 +53,29 @@ static const char rcsid[] = "$Id: pty.c,v 1.12 2004/04/11 18:04:36 millert Exp $
#define TTY_SUFFIX "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" #define TTY_SUFFIX "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
int int
openpty(amaster, aslave, name, termp, winp)
int *amaster, *aslave;
char *name;
struct termios *termp;
struct winsize *winp;
openpty(int *amaster, int *aslave, char *name, struct termios *termp,
struct winsize *winp)
{ {
char line[] = "/dev/ptyXX"; char line[] = "/dev/ptyXX";
const char *cp1, *cp2; const char *cp1, *cp2;
int master, slave, ttygid;
struct group *gr;
int master, slave, fd;
struct ptmget ptm; struct ptmget ptm;
int fd;
struct group *gr;
gid_t ttygid;
/* Try to use /dev/ptm and the PTMGET ioctl to get a properly set up
/*
* Try to use /dev/ptm and the PTMGET ioctl to get a properly set up
* and owned pty/tty pair. If this fails, (because we might not have * and owned pty/tty pair. If this fails, (because we might not have
* the ptm device, etc.) fall back to using the traditional method * the ptm device, etc.) fall back to using the traditional method
* of walking through the pty entries in /dev for the moment, until * of walking through the pty entries in /dev for the moment, until
* there is less chance of people being seriously boned by running * there is less chance of people being seriously boned by running
* kernels without /dev/ptm in them. * kernels without /dev/ptm in them.
*/ */
fd = open(PATH_PTMDEV, O_RDWR, 0); fd = open(PATH_PTMDEV, O_RDWR, 0);
if (fd == -1) if (fd == -1)
goto walkit; goto walkit;
if ((ioctl(fd, PTMGET, &ptm) == -1)) { if ((ioctl(fd, PTMGET, &ptm) == -1)) {
close(fd);
close(fd);
goto walkit; goto walkit;
} }
close(fd); close(fd);


+ 14
- 17
src/lib/libutil/readlabel.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: readlabel.c,v 1.7 2002/02/21 16:22:23 deraadt Exp $ */
/* $OpenBSD: readlabel.c,v 1.8 2004/05/28 07:03:47 deraadt Exp $ */
/* /*
* Copyright (c) 1996, Jason Downs. All rights reserved. * Copyright (c) 1996, Jason Downs. All rights reserved.
@ -46,24 +46,22 @@
* Try to get a disklabel for the specified device, and return mount_xxx * Try to get a disklabel for the specified device, and return mount_xxx
* style filesystem type name for the specified partition. * style filesystem type name for the specified partition.
*/ */
char *readlabelfs(device, verbose)
char *device;
int verbose;
char *
readlabelfs(char *device, int verbose)
{ {
char rpath[MAXPATHLEN]; char rpath[MAXPATHLEN];
struct disklabel dk;
char part, *type; char part, *type;
struct stat sbuf; struct stat sbuf;
struct disklabel dk;
int fd; int fd;
/* Assuming device is of the form /dev/??p, build a raw partition. */ /* Assuming device is of the form /dev/??p, build a raw partition. */
if (stat(device, &sbuf) < 0) { if (stat(device, &sbuf) < 0) {
if (verbose) if (verbose)
warn("%s", device); warn("%s", device);
return(NULL);
return (NULL);
} }
switch(sbuf.st_mode & S_IFMT) {
switch (sbuf.st_mode & S_IFMT) {
case S_IFCHR: case S_IFCHR:
/* Ok... already a raw device. Hmm. */ /* Ok... already a raw device. Hmm. */
strncpy(rpath, device, sizeof(rpath)); strncpy(rpath, device, sizeof(rpath));
@ -77,7 +75,6 @@ char *readlabelfs(device, verbose)
if (strlen(device) > sizeof(_PATH_DEV) - 1) { if (strlen(device) > sizeof(_PATH_DEV) - 1) {
snprintf(rpath, sizeof(rpath), "%sr%s", _PATH_DEV, snprintf(rpath, sizeof(rpath), "%sr%s", _PATH_DEV,
&device[sizeof(_PATH_DEV) - 1]); &device[sizeof(_PATH_DEV) - 1]);
/* Change partition name. */ /* Change partition name. */
part = rpath[strlen(rpath) - 1]; part = rpath[strlen(rpath) - 1];
rpath[strlen(rpath) - 1] = 'a' + getrawpartition(); rpath[strlen(rpath) - 1] = 'a' + getrawpartition();
@ -86,7 +83,7 @@ char *readlabelfs(device, verbose)
default: default:
if (verbose) if (verbose)
warnx("%s: not a device node", device); warnx("%s: not a device node", device);
return(NULL);
return (NULL);
} }
/* If rpath doesn't exist, change that partition back. */ /* If rpath doesn't exist, change that partition back. */
@ -99,28 +96,28 @@ char *readlabelfs(device, verbose)
if (fd < 0) { if (fd < 0) {
if (verbose) if (verbose)
warn("%s", rpath); warn("%s", rpath);
return(NULL);
return (NULL);
} }
} else { } else {
if (verbose)
warn("%s", rpath);
return(NULL);
if (verbose)
warn("%s", rpath);
return (NULL);
} }
} }
if (ioctl(fd, DIOCGDINFO, &dk) < 0) { if (ioctl(fd, DIOCGDINFO, &dk) < 0) {
if (verbose) if (verbose)
warn("%s: couldn't read disklabel", rpath); warn("%s: couldn't read disklabel", rpath);
close(fd); close(fd);
return(NULL);
return (NULL);
} }
close(fd); close(fd);
if (dk.d_partitions[part - 'a'].p_fstype > FSMAXTYPES) { if (dk.d_partitions[part - 'a'].p_fstype > FSMAXTYPES) {
if (verbose) if (verbose)
warnx("%s: bad filesystem type in label", rpath); warnx("%s: bad filesystem type in label", rpath);
return(NULL);
return (NULL);
} }
type = fstypesnames[dk.d_partitions[part - 'a'].p_fstype]; type = fstypesnames[dk.d_partitions[part - 'a'].p_fstype];
return((type[0] == '\0') ? NULL : type);
return ((type[0] == '\0') ? NULL : type);
} }

+ 12
- 23
src/lib/libutil/uucplock.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: uucplock.c,v 1.11 2003/06/02 20:18:42 millert Exp $ */
/* $OpenBSD: uucplock.c,v 1.12 2004/05/28 07:03:48 deraadt Exp $ */
/* /*
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -61,22 +61,19 @@ static pid_t get_pid(int fd,int *err);
/* /*
* uucp style locking routines * uucp style locking routines
*/ */
int int
uu_lock(ttyname)
const char *ttyname;
uu_lock(const char *ttyname)
{ {
int fd, tmpfd, i;
pid_t pid, pid_old;
char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN], char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN],
lcktmpname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN]; lcktmpname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
int err, uuerr;
int fd, tmpfd, i, err, uuerr;
pid_t pid, pid_old;
pid = getpid(); pid = getpid();
(void)snprintf(lcktmpname, sizeof(lcktmpname), _PATH_UUCPLOCK LOCKTMP, (void)snprintf(lcktmpname, sizeof(lcktmpname), _PATH_UUCPLOCK LOCKTMP,
(long)pid);
(long)pid);
(void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, (void)snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT,
ttyname);
ttyname);
if ((tmpfd = creat(lcktmpname, 0664)) < 0) if ((tmpfd = creat(lcktmpname, 0664)) < 0)
GORET(0, UU_LOCK_CREAT_ERR); GORET(0, UU_LOCK_CREAT_ERR);
@ -126,12 +123,10 @@ ret0:
} }
int int
uu_lock_txfr(ttyname, pid)
const char *ttyname;
pid_t pid;
uu_lock_txfr(const char *ttyname, pid_t pid)
{ {
int fd, err;
char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN]; char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
int fd, err;
snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname); snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, ttyname);
@ -148,8 +143,7 @@ uu_lock_txfr(ttyname, pid)
} }
int int
uu_unlock(ttyname)
const char *ttyname;
uu_unlock(const char *ttyname)
{ {
char tbuf[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN]; char tbuf[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
@ -158,8 +152,7 @@ uu_unlock(ttyname)
} }
const char * const char *
uu_lockerr(uu_lockresult)
int uu_lockresult;
uu_lockerr(int uu_lockresult)
{ {
static char errbuf[128]; static char errbuf[128];
char *fmt; char *fmt;
@ -200,9 +193,7 @@ uu_lockerr(uu_lockresult)
} }
static int static int
put_pid(fd, pid)
int fd;
pid_t pid;
put_pid(int fd, pid_t pid)
{ {
char buf[32]; char buf[32];
int len; int len;
@ -218,9 +209,7 @@ put_pid(fd, pid)
} }
static pid_t static pid_t
get_pid(fd, err)
int fd;
int *err;
get_pid(int fd, int *err)
{ {
int bytes_read; int bytes_read;
char buf[32]; char buf[32];


Loading…
Cancel
Save