add fpathconf
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 26 May 1993 08:16:12 +0000 (00:16 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 26 May 1993 08:16:12 +0000 (00:16 -0800)
SCCS-vsn: sys/kern/kern_descrip.c 7.42

usr/src/sys/kern/kern_descrip.c

index a3517d7..846bf60 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)kern_descrip.c      7.41 (Berkeley) %G%
+ *     @(#)kern_descrip.c      7.42 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -21,6 +21,7 @@
 #include <sys/fcntl.h>
 #include <sys/malloc.h>
 #include <sys/syslog.h>
 #include <sys/fcntl.h>
 #include <sys/malloc.h>
 #include <sys/syslog.h>
+#include <sys/unistd.h>
 #include <sys/resourcevar.h>
 
 /*
 #include <sys/resourcevar.h>
 
 /*
@@ -401,6 +402,44 @@ fstat(p, uap, retval)
        return (error);
 }
 
        return (error);
 }
 
+/*
+ * Return pathconf information about a file descriptor.
+ */
+struct fpathconf_args {
+       int     fd;
+       int     name;
+};
+/* ARGSUSED */
+fpathconf(p, uap, retval)
+       struct proc *p;
+       register struct fpathconf_args *uap;
+       int *retval;
+{
+       struct filedesc *fdp = p->p_fd;
+       struct file *fp;
+       struct vnode *vp;
+
+       if ((unsigned)uap->fd >= fdp->fd_nfiles ||
+           (fp = fdp->fd_ofiles[uap->fd]) == NULL)
+               return (EBADF);
+       switch (fp->f_type) {
+
+       case DTYPE_SOCKET:
+               if (uap->name != _PC_PIPE_BUF)
+                       return (EINVAL);
+               *retval = PIPE_BUF;
+               return (0);
+
+       case DTYPE_VNODE:
+               vp = (struct vnode *)fp->f_data;
+               return (VOP_PATHCONF(vp, uap->name, retval));
+
+       default:
+               panic("fpathconf");
+       }
+       /*NOTREACHED*/
+}
+
 /*
  * Allocate a file descriptor for the process.
  */
 /*
  * Allocate a file descriptor for the process.
  */