POSIX 1003.1
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 26 May 1990 09:21:51 +0000 (01:21 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 26 May 1990 09:21:51 +0000 (01:21 -0800)
SCCS-vsn: sys/sys/fcntl.h 5.4
SCCS-vsn: sys/sys/file.h 7.5
SCCS-vsn: include/grp.h 5.1
SCCS-vsn: include/pwd.h 5.4

usr/src/include/grp.h
usr/src/include/pwd.h
usr/src/sys/sys/fcntl.h
usr/src/sys/sys/file.h

index 6fd0832..2c0d15d 100644 (file)
@@ -1,23 +1,15 @@
-/*
- * Copyright (c) 1988 The Regents of the University of California.
+/*-
+ * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)grp.h       4.5 (Berkeley) %G%
+ *     @(#)grp.h       5.1 (Berkeley) %G%
  */
 
  */
 
+#ifndef _POSIX_SOURCE
 #define        _PATH_GROUP             "/etc/group"
 #define        _PATH_GROUP             "/etc/group"
+#endif
 
 struct group {
        char    *gr_name;               /* group name */
 
 struct group {
        char    *gr_name;               /* group name */
@@ -27,19 +19,23 @@ struct group {
 };
 
 #ifdef __STDC__
 };
 
 #ifdef __STDC__
-extern struct group *getgrent(void);
 extern struct group *getgrgid(gid_t);
 extern struct group *getgrnam(const char *);
 extern struct group *getgrgid(gid_t);
 extern struct group *getgrnam(const char *);
+#ifndef _POSIX_SOURCE
+extern struct group *getgrent(void);
 extern int setgrent(void);
 extern void endgrent(void);
 extern void setgrfile(const char *);
 extern int setgroupent(int);
 extern int setgrent(void);
 extern void endgrent(void);
 extern void setgrfile(const char *);
 extern int setgroupent(int);
+#endif
 #else
 #else
-extern struct group *getgrent();
 extern struct group *getgrgid();
 extern struct group *getgrnam();
 extern struct group *getgrgid();
 extern struct group *getgrnam();
+#ifndef _POSIX_SOURCE
+extern struct group *getgrent();
 extern int setgrent();
 extern void endgrent();
 extern void setgrfile();
 extern int setgroupent();
 #endif
 extern int setgrent();
 extern void endgrent();
 extern void setgrfile();
 extern int setgroupent();
 #endif
+#endif
index 601dea0..5f0ab0d 100644 (file)
@@ -1,24 +1,15 @@
-/*
- * Copyright (c) 1988 The Regents of the University of California.
+/*-
+ * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)pwd.h       5.3 (Berkeley) %G%
+ *     @(#)pwd.h       5.4 (Berkeley) %G%
  */
 
 #include <sys/types.h>
 
  */
 
 #include <sys/types.h>
 
+#ifndef _POSIX_SOURCE
 #define        _PATH_PASSWD            "/etc/passwd"
 #define        _PATH_MASTERPASSWD      "/etc/master.passwd"
 #define        _PATH_MKPASSWD          "/usr/sbin/mkpasswd"
 #define        _PATH_PASSWD            "/etc/passwd"
 #define        _PATH_MASTERPASSWD      "/etc/master.passwd"
 #define        _PATH_MKPASSWD          "/usr/sbin/mkpasswd"
 #define        _PW_KEYBYUID            '1'
 
 #define        _PASSWORD_LEN           128
 #define        _PW_KEYBYUID            '1'
 
 #define        _PASSWORD_LEN           128
+#endif
 
 struct passwd {
 
 struct passwd {
-       char    *pw_name;                       /* user name */
-       char    *pw_passwd;                     /* encrypted password */
-       int     pw_uid;                         /* user uid */
-       int     pw_gid;                         /* user gid */
-       u_long  pw_change;                      /* password change time */
-       char    *pw_class;                      /* user access class */
-       char    *pw_gecos;                      /* Honeywell login info */
-       char    *pw_dir;                        /* home directory */
-       char    *pw_shell;                      /* default shell */
-       u_long  pw_expire;                      /* account expiration */
+       char    *pw_name;               /* user name */
+       char    *pw_passwd;             /* encrypted password */
+       int     pw_uid;                 /* user uid */
+       int     pw_gid;                 /* user gid */
+       time_t  pw_change;              /* password change time */
+       char    *pw_class;              /* user access class */
+       char    *pw_gecos;              /* Honeywell login info */
+       char    *pw_dir;                /* home directory */
+       char    *pw_shell;              /* default shell */
+       time_t  pw_expire;              /* account expiration */
 };
 
 #ifdef __STDC__
 };
 
 #ifdef __STDC__
-struct passwd *getpwent(void);
-struct passwd *getpwuid(int);
+struct passwd *getpwuid(uid_t);
 struct passwd *getpwnam(const char *);
 struct passwd *getpwnam(const char *);
+#ifndef _POSIX_SOURCE
+struct passwd *getpwent(void);
 int setpwent(void);
 void endpwent(void);
 void setpwfile(const char *);
 int setpassent(int);
 int setpwent(void);
 void endpwent(void);
 void setpwfile(const char *);
 int setpassent(int);
+#endif
 #else
 #else
-struct passwd *getpwent();
 struct passwd *getpwuid();
 struct passwd *getpwnam();
 struct passwd *getpwuid();
 struct passwd *getpwnam();
+#ifndef _POSIX_SOURCE
+struct passwd *getpwent();
 int setpwent();
 void endpwent();
 void setpwfile();
 int setpassent();
 #endif
 int setpwent();
 void endpwent();
 void setpwfile();
 int setpassent();
 #endif
+#endif
index 1f4582a..610ab6b 100644 (file)
@@ -1,46 +1,90 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1983, 1990 The Regents of the University of California.
+ * All rights reserved.
  *
  *
- *     @(#)fcntl.h     5.3 (Berkeley) %G%
+ * %sccs.include.redist.c%
+ *
+ *     @(#)fcntl.h     5.4 (Berkeley) %G%
  */
 
  */
 
-/*
- * Flag values accessible to open(2) and fcntl(2)-- copied from
- * <sys/file.h>.  (The first three can only be set by open.)
- */
-#define        O_RDONLY        000             /* open for reading */
-#define        O_WRONLY        001             /* open for writing */
-#define        O_RDWR          002             /* open for read & write */
-#define        O_NDELAY        FNDELAY         /* non-blocking open */
-                                       /* really non-blocking I/O for fcntl */
-#define        O_APPEND        FAPPEND         /* append on each write */
-#define        O_CREAT         FCREAT          /* open with file create */
-#define        O_TRUNC         FTRUNC          /* open with truncation */
-#define        O_EXCL          FEXCL           /* error on create if file exists */
-
-#ifndef        F_DUPFD
-/* fcntl(2) requests */
-#define        F_DUPFD 0       /* Duplicate fildes */
-#define        F_GETFD 1       /* Get fildes flags */
-#define        F_SETFD 2       /* Set fildes flags */
-#define        F_GETFL 3       /* Get file flags */
-#define        F_SETFL 4       /* Set file flags */
-#define        F_GETOWN 5      /* Get owner */
-#define F_SETOWN 6     /* Set owner */
-
-/* flags for F_GETFL, F_SETFL-- copied from <sys/file.h> */
-#define        FNDELAY         00004           /* non-blocking reads */
-#define        FAPPEND         00010           /* append on each write */
-#define        FASYNC          00100           /* signal pgrp when data ready */
-#define        FCREAT          01000           /* create if nonexistant */
-#define        FTRUNC          02000           /* truncate to zero length */
-#define        FEXCL           04000           /* error if already created */
+#ifndef F_DUPFD
+
+/* command values for fcntl(2) */
+#define        F_DUPFD         0               /* duplicate file descriptor */
+#define        F_GETFD         1               /* get file descriptor flags */
+#define        F_SETFD         2               /* set file descriptor flags */
+#define        F_GETFL         3               /* get file status flags */
+#define        F_SETFL         4               /* set file status flags */
+#ifndef _POSIX_SOURCE
+#define        F_GETOWN        5               /* get SIGIO/SIGURG proc/pgrp */
+#define F_SETOWN       6               /* set SIGIO/SIGURG proc/pgrp */
+#endif
+#define        F_GETLK         7               /* get record locking information */
+#define        F_SETLK         8               /* set record locking information */
+#define        F_SETLKW        9               /* F_SETLK; wait if blocked */
+
+/* file descriptor flags (F_GETFD, F_SETFD) */
+#define        FD_CLOEXEC      1               /* close-on-exec flag */
+
+/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
+#define        F_RDLCK         1               /* shared or read lock */
+#define        F_UNLCK         2               /* unlock */
+#define        F_WRLCK         3               /* exclusive or write lock */
+
+#ifndef _POSIX_SOURCE
+/* lock operations for flock(2) */
+#define        LOCK_SH         0x01            /* shared file lock */
+#define        LOCK_EX         0x02            /* exclusive file lock */
+#define        LOCK_NB         0x04            /* don't block when locking */
+#define        LOCK_UN         0x08            /* unlock file */
 #endif
 
 #endif
 
-#ifdef __STDC__
+/* file status flags */
+#define        O_RDONLY        00000           /* open for reading only */
+#define        O_WRONLY        00001           /* open for writing only */
+#define        O_RDWR          00002           /* open for reading and writing */
+#define        O_NONBLOCK      00004           /* no delay */
+#ifndef _POSIX_SOURCE
+#define        O_NDELAY        O_NONBLOCK
+#define        FNDELAY         O_NONBLOCK
+#endif
+/*                     00008           /* unused */
+#define        O_APPEND        00010           /* set append mode */
+#ifndef _POSIX_SOURCE
+#define        FAPPEND         O_APPEND
+#endif
+                                       /* kernel placeholders */
+#if !defined(_POSIX_SOURCE) && defined(KERNEL)
+#define        O_MARK          00020           /* mark during gc() */
+#define        O_DEFER         00040           /* defer for next gc pass */
+#endif
+/*                     00080           /* unused */
+#ifndef _POSIX_SOURCE
+#define        O_ASYNC         00100           /* signal pgrp when data ready */
+#define        FASYNC          O_ASYNC
+#define        O_SHLOCK        00200           /* shared file lock present */
+#define        O_EXLOCK        00400           /* exclusive file lock present */
+/*                     00800           /* unused */
+#endif
+#define        O_CREAT         01000           /* create if nonexistant */
+#define        O_TRUNC         02000           /* truncate to zero length */
+#define        O_EXCL          04000           /* error if already exists */
+/*                     08000           /* unused */
+
+/* defined by POSIX 1003.1; BSD default, so no bit required */
+#define        O_NOCTTY        0               /* don't assign controlling terminal */
+
+/* mask for file access modes */
+#define        O_ACCMODE       (O_RDONLY|O_WRONLY|O_RDWR)
+
+#if defined(__STDC__)
 extern int fcntl(int, int, int);
 extern int fcntl(int, int, int);
+extern int creat(const char *, mode_t);
+extern int open(const char *, int, ...);
 #else
 extern int fcntl();
 #else
 extern int fcntl();
+extern int creat();
+extern int open();
 #endif
 #endif
+
+#endif /* !F_DUPFD */
index e33b5b8..d25f601 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)file.h      7.4 (Berkeley) %G%
+ *     @(#)file.h      7.5 (Berkeley) %G%
  */
 
 #ifdef KERNEL
  */
 
 #ifdef KERNEL
+#include "fcntl.h"
+#include "unistd.h"
+
 /*
  * Descriptor table entry.
  * One for each kernel object.
  */
 /*
  * Descriptor table entry.
  * One for each kernel object.
  */
-struct file {
+struct file {
        int     f_flag;         /* see below */
        int     f_flag;         /* see below */
+#define        DTYPE_VNODE     1       /* file */
+#define        DTYPE_SOCKET    2       /* communications endpoint */
        short   f_type;         /* descriptor type */
        short   f_count;        /* reference count */
        short   f_msgcount;     /* references from message queue */
        short   f_type;         /* descriptor type */
        short   f_count;        /* reference count */
        short   f_msgcount;     /* references from message queue */
@@ -39,89 +44,36 @@ struct      file {
        off_t   f_offset;
 };
 
        off_t   f_offset;
 };
 
-struct file *file, *fileNFILE;
-int    nfile;
-#endif
+struct file *file, *fileNFILE;
+int nfile;
 
 
-/*
- * flags- also for fcntl call.
- */
+/* convert O_RDONLY/O_WRONLY/O_RDWR to FREAD/FWRITE */
 #define        FOPEN           (-1)
 #define        FOPEN           (-1)
-#define        FREAD           00001           /* descriptor read/receive'able */
-#define        FWRITE          00002           /* descriptor write/send'able */
-#ifndef        F_DUPFD
-#define        FNDELAY         00004           /* no delay */
-#define        FAPPEND         00010           /* append on each write */
-#endif
-#define        FMARK           00020           /* mark during gc() */
-#define        FDEFER          00040           /* defer for next gc pass */
-#ifndef        F_DUPFD
-#define        FASYNC          00100           /* signal pgrp when data ready */
-#endif
-#define        FSHLOCK         00200           /* shared lock present */
-#define        FEXLOCK         00400           /* exclusive lock present */
+#define        FREAD           1
+#define        FWRITE          2
 
 
-/* bits to save after open */
-#define        FMASK           (FASYNC|FAPPEND|FNDELAY|FWRITE|FREAD)
-#define        FCNTLCANT       (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK)
-
-/* open only modes */
-#define        FCREAT          01000           /* create if nonexistant */
-#define        FTRUNC          02000           /* truncate to zero length */
-#define        FEXCL           04000           /* error if already created */
-
-#ifndef        F_DUPFD
-/* fcntl(2) requests--from <fcntl.h> */
-#define        F_DUPFD 0       /* Duplicate fildes */
-#define        F_GETFD 1       /* Get fildes flags */
-#define        F_SETFD 2       /* Set fildes flags */
-#define        F_GETFL 3       /* Get file flags */
-#define        F_SETFL 4       /* Set file flags */
-#define        F_GETOWN 5      /* Get owner */
-#define F_SETOWN 6     /* Set owner */
-#endif
-
-/*
- * User definitions.
- */
+/* kernel only versions -- deprecated, should be removed */
+#define        FCREAT          O_CREAT
+#define        FDEFER          O_DEFER
+#define        FEXCL           O_EXCL
+#define        FEXLOCK         O_EXLOCK
+#define        FMARK           O_MARK
+#define        FSHLOCK         O_SHLOCK
+#define        FTRUNC          O_TRUNC
 
 
-/*
- * Open call.
- */
-#define        O_RDONLY        000             /* open for reading */
-#define        O_WRONLY        001             /* open for writing */
-#define        O_RDWR          002             /* open for read & write */
-#define        O_NDELAY        FNDELAY         /* non-blocking open on file */
-#define O_NONBLOCK     FNDELAY         /* ditto */
-#define        O_APPEND        FAPPEND         /* append on each write */
-#define        O_CREAT         FCREAT          /* open with file create */
-#define        O_TRUNC         FTRUNC          /* open with truncation */
-#define        O_EXCL          FEXCL           /* error on create if file exists */
-
-/*
- * Flock call.
- */
-#define        LOCK_SH         1       /* shared lock */
-#define        LOCK_EX         2       /* exclusive lock */
-#define        LOCK_NB         4       /* don't block when locking */
-#define        LOCK_UN         8       /* unlock */
+/* bits to save after open */
+#define        FMASK           (FREAD|FWRITE|O_APPEND|O_ASYNC|O_NONBLOCK)
+/* bits not settable by fcntl(F_SETFL, ...) */
+#define        FCNTLCANT       (FREAD|FWRITE|O_DEFER|O_EXLOCK|O_MARK|O_SHLOCK)
 
 
-/*
- * Access call.
- */
-#define        F_OK            0       /* does file exist */
-#define        X_OK            1       /* is it executable by caller */
-#define        W_OK            2       /* writable by caller */
-#define        R_OK            4       /* readable by caller */
+#else
 
 
-/*
- * Lseek call.
- */
-#define        L_SET           0       /* absolute offset */
-#define        L_INCR          1       /* relative to current offset */
-#define        L_XTND          2       /* relative to end of file */
+#include <sys/fcntl.h>
+#include <sys/unistd.h>
 
 
-#ifdef KERNEL
-#define        DTYPE_VNODE     1       /* file */
-#define        DTYPE_SOCKET    2       /* communications endpoint */
 #endif
 #endif
+
+/* operation for lseek(2); renamed by POSIX 1003.1 to unistd.h */
+#define        L_SET           0       /* set file offset to offset */
+#define        L_INCR          1       /* set file offset to current plus offset */
+#define        L_XTND          2       /* set file offset to EOF plus offset */