+flock()
+{
+ struct a {
+ int fd;
+ int how;
+ } *uap;
+ register struct file *fp;
+ register int cmd, flags;
+
+ uap = (struct a *)u.u_ap;
+ fp = getf(uap->fd);
+ if (fp == NULL)
+ return;
+ if (fp->f_type == DTYPE_SOCKET) { /* XXX */
+ u.u_error = EINVAL;
+ return;
+ }
+ cmd = uap->how;
+ flags = u.u_pofile[uap->fd] & (RDLOCK|WRLOCK);
+ if (cmd&FUNLOCK) {
+ if (flags == 0) {
+ u.u_error = EINVAL;
+ return;
+ }
+ funlocki(fp->f_inode, flags);
+ u.u_pofile[uap->fd] &= ~(RDLOCK|WRLOCK);
+ return;
+ }
+ /*
+ * No reason to write lock a file we've already
+ * write locked, similarly with a read lock.
+ */
+ if ((flags&WRLOCK) && (cmd&FWRLOCK) ||
+ (flags&RDLOCK) && (cmd&FRDLOCK))
+ return;
+ u.u_pofile[uap->fd] = flocki(fp->f_inode, u.u_pofile[uap->fd], cmd);
+}
+
+truncate()
+{
+ struct a {
+ char *fname;
+ int length;
+ } *uap;
+ struct inode *ip;
+
+ ip = namei(uchar, 0, 1);
+ if (ip == NULL)
+ return;
+ if (access(ip, IWRITE))
+ goto bad;
+ if ((ip->i_mode&IFMT) == IFDIR) {
+ u.u_error = EISDIR;
+ goto bad;
+ }
+ itrunc(ip, uap->length);
+ return;
+bad:
+ iput(ip);
+}
+
+ftruncate()
+{
+ struct a {
+ int fd;
+ int length;
+ } *uap;
+ struct inode *ip;
+ struct file *fp;
+
+ fp = getf(uap->fd);
+ if (fp == NULL)
+ return;
+ if (fp->f_type == DTYPE_SOCKET) {
+ u.u_error = EINVAL;
+ return;
+ }
+ if ((fp->f_flag&FWRITE) == 0) {
+ u.u_error = EINVAL;
+ return;
+ }
+ ip = fp->f_inode;
+ ilock(ip);
+ itrunc(ip, uap->length);
+}
+
+rename()
+{
+ struct a {
+ char *from;
+ char *to;
+ } *uap;
+
+}
+