+ RETURN (0);
+ RETURN (vn_lock(fp, uap->how));
+}
+
+/*
+ * File Descriptor pseudo-device driver (/dev/fd/).
+ *
+ * Fred Blonder - U of Maryland 11-Sep-1984
+ *
+ * Opening minor device N dup()s the file (if any) connected to file
+ * descriptor N belonging to the calling process. Note that this driver
+ * consists of only the ``open()'' routine, because all subsequent
+ * references to this file will be direct to the other driver.
+ */
+/* ARGSUSED */
+fdopen(dev, mode, type)
+ dev_t dev;
+ int mode, type;
+{
+ struct file *fp, *wfp;
+ int indx, dfd;
+
+ /*
+ * XXX
+ * Horrid kludge: u.u_r.r_val1 contains the value of the new file
+ * descriptor, which was set before the call to vn_open() by copen()
+ * in vfs_syscalls.c.
+ */
+ indx = u.u_r.r_val1;
+ fp = u.u_ofile[indx];
+
+ /*
+ * File system device minor number is the to-be-dup'd fd number.
+ * If it is greater than the allowed number of file descriptors,
+ * or the fd to be dup'd has already been closed, reject. Note,
+ * check for new == old is necessary as u_falloc could allocate
+ * an already closed to-be-dup'd descriptor as the new descriptor.
+ */
+ dfd = minor(dev);
+ if ((u_int)dfd >= NOFILE || (wfp = u.u_ofile[dfd]) == NULL ||
+ fp == wfp)
+ return (EBADF);
+
+ /*
+ * Check that the mode the file is being opened for is a subset
+ * of the mode of the existing descriptor.
+ */
+ if ((mode & (FREAD|FWRITE) | wfp->f_flag) != wfp->f_flag)
+ return (EACCES);
+ u.u_ofile[indx] = wfp;
+ u.u_pofile[indx] = u.u_pofile[dfd];
+ wfp->f_count++;
+ if (indx > u.u_lastfile)
+ u.u_lastfile = indx;
+
+ /*
+ * Delete references to this pseudo-device by returning a special
+ * error (EJUSTRETURN) that will cause all resources to be freed,
+ * then detected and cleared by copen().
+ */
+ return (EJUSTRETURN); /* XXX */