svn commit: r274476 - in head/sys: cddl/compat/opensolaris/sys compat/freebsd32 compat/linux compat/svr4 dev/streams i386/ibcs2 kern sys
Konstantin Belousov
kib at FreeBSD.org
Thu Nov 13 18:01:58 UTC 2014
Author: kib
Date: Thu Nov 13 18:01:51 2014
New Revision: 274476
URL: https://svnweb.freebsd.org/changeset/base/274476
Log:
Remove the no-at variants of the kern_xx() syscall helpers. E.g., we
have both kern_open() and kern_openat(); change the callers to use
kern_openat().
This removes one (sometimes two) levels of indirection and
consolidates arguments checks.
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Modified:
head/sys/cddl/compat/opensolaris/sys/vnode.h
head/sys/compat/freebsd32/freebsd32_misc.c
head/sys/compat/linux/linux_file.c
head/sys/compat/linux/linux_misc.c
head/sys/compat/linux/linux_socket.c
head/sys/compat/linux/linux_stats.c
head/sys/compat/linux/linux_uid16.c
head/sys/compat/svr4/svr4_fcntl.c
head/sys/compat/svr4/svr4_misc.c
head/sys/compat/svr4/svr4_stat.c
head/sys/compat/svr4/svr4_stream.c
head/sys/dev/streams/streams.c
head/sys/i386/ibcs2/ibcs2_fcntl.c
head/sys/i386/ibcs2/ibcs2_misc.c
head/sys/i386/ibcs2/ibcs2_other.c
head/sys/i386/ibcs2/ibcs2_stat.c
head/sys/i386/ibcs2/ibcs2_xenix.c
head/sys/kern/kern_descrip.c
head/sys/kern/uipc_syscalls.c
head/sys/kern/vfs_mountroot.c
head/sys/kern/vfs_syscalls.c
head/sys/sys/param.h
head/sys/sys/syscallsubr.h
Modified: head/sys/cddl/compat/opensolaris/sys/vnode.h
==============================================================================
--- head/sys/cddl/compat/opensolaris/sys/vnode.h Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/cddl/compat/opensolaris/sys/vnode.h Thu Nov 13 18:01:51 2014 (r274476)
@@ -282,7 +282,7 @@ vn_rename(char *from, char *to, enum uio
ASSERT(seg == UIO_SYSSPACE);
- return (kern_rename(curthread, from, to, seg));
+ return (kern_renameat(curthread, AT_FDCWD, from, AT_FDCWD, to, seg));
}
static __inline int
@@ -292,7 +292,7 @@ vn_remove(char *fnamep, enum uio_seg seg
ASSERT(seg == UIO_SYSSPACE);
ASSERT(dirflag == RMFILE);
- return (kern_unlink(curthread, fnamep, seg));
+ return (kern_unlinkat(curthread, AT_FDCWD, fnamep, seg, 0));
}
#endif /* _KERNEL */
Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/freebsd32/freebsd32_misc.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -1231,7 +1231,8 @@ freebsd32_utimes(struct thread *td, stru
sp = s;
} else
sp = NULL;
- return (kern_utimes(td, uap->path, UIO_USERSPACE, sp, UIO_SYSSPACE));
+ return (kern_utimesat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
+ sp, UIO_SYSSPACE));
}
int
@@ -1697,7 +1698,8 @@ freebsd32_stat(struct thread *td, struct
struct stat32 sb32;
int error;
- error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
+ error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
+ &sb, NULL);
if (error)
return (error);
copy_stat(&sb, &sb32);
@@ -1713,7 +1715,8 @@ ofreebsd32_stat(struct thread *td, struc
struct ostat32 sb32;
int error;
- error = kern_stat(td, uap->path, UIO_USERSPACE, &sb);
+ error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
+ &sb, NULL);
if (error)
return (error);
copy_ostat(&sb, &sb32);
@@ -1761,7 +1764,8 @@ freebsd32_fstatat(struct thread *td, str
struct stat32 ub32;
int error;
- error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE, &ub);
+ error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE,
+ &ub, NULL);
if (error)
return (error);
copy_stat(&ub, &ub32);
@@ -1776,7 +1780,8 @@ freebsd32_lstat(struct thread *td, struc
struct stat32 sb32;
int error;
- error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb);
+ error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
+ UIO_USERSPACE, &sb, NULL);
if (error)
return (error);
copy_stat(&sb, &sb32);
@@ -1792,7 +1797,8 @@ ofreebsd32_lstat(struct thread *td, stru
struct ostat32 sb32;
int error;
- error = kern_lstat(td, uap->path, UIO_USERSPACE, &sb);
+ error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
+ UIO_USERSPACE, &sb, NULL);
if (error)
return (error);
copy_ostat(&sb, &sb32);
Modified: head/sys/compat/linux/linux_file.c
==============================================================================
--- head/sys/compat/linux/linux_file.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/linux/linux_file.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -82,8 +82,8 @@ linux_creat(struct thread *td, struct li
if (ldebug(creat))
printf(ARGS(creat, "%s, %d"), path, args->mode);
#endif
- error = kern_open(td, path, UIO_SYSSPACE, O_WRONLY | O_CREAT | O_TRUNC,
- args->mode);
+ error = kern_openat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ O_WRONLY | O_CREAT | O_TRUNC, args->mode);
LFREEPATH(path);
return (error);
}
@@ -572,7 +572,8 @@ linux_access(struct thread *td, struct l
if (ldebug(access))
printf(ARGS(access, "%s, %d"), path, args->amode);
#endif
- error = kern_access(td, path, UIO_SYSSPACE, args->amode);
+ error = kern_accessat(td, AT_FDCWD, path, UIO_SYSSPACE, 0,
+ args->amode);
LFREEPATH(path);
return (error);
@@ -619,12 +620,15 @@ linux_unlink(struct thread *td, struct l
printf(ARGS(unlink, "%s"), path);
#endif
- error = kern_unlink(td, path, UIO_SYSSPACE);
- if (error == EPERM)
+ error = kern_unlinkat(td, AT_FDCWD, path, UIO_SYSSPACE, 0);
+ if (error == EPERM) {
/* Introduce POSIX noncompliant behaviour of Linux */
- if (kern_stat(td, path, UIO_SYSSPACE, &st) == 0)
+ if (kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &st,
+ NULL) == 0) {
if (S_ISDIR(st.st_mode))
error = EISDIR;
+ }
+ }
LFREEPATH(path);
return (error);
}
@@ -654,7 +658,7 @@ linux_unlinkat(struct thread *td, struct
if (error == EPERM && !(args->flag & LINUX_AT_REMOVEDIR)) {
/* Introduce POSIX noncompliant behaviour of Linux */
if (kern_statat(td, AT_SYMLINK_NOFOLLOW, dfd, path,
- UIO_SYSSPACE, &st) == 0 && S_ISDIR(st.st_mode))
+ UIO_SYSSPACE, &st, NULL) == 0 && S_ISDIR(st.st_mode))
error = EISDIR;
}
LFREEPATH(path);
@@ -689,7 +693,8 @@ linux_chmod(struct thread *td, struct li
if (ldebug(chmod))
printf(ARGS(chmod, "%s, %d"), path, args->mode);
#endif
- error = kern_chmod(td, path, UIO_SYSSPACE, args->mode);
+ error = kern_fchmodat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ args->mode, 0);
LFREEPATH(path);
return (error);
}
@@ -725,7 +730,7 @@ linux_mkdir(struct thread *td, struct li
if (ldebug(mkdir))
printf(ARGS(mkdir, "%s, %d"), path, args->mode);
#endif
- error = kern_mkdir(td, path, UIO_SYSSPACE, args->mode);
+ error = kern_mkdirat(td, AT_FDCWD, path, UIO_SYSSPACE, args->mode);
LFREEPATH(path);
return (error);
}
@@ -760,7 +765,7 @@ linux_rmdir(struct thread *td, struct li
if (ldebug(rmdir))
printf(ARGS(rmdir, "%s"), path);
#endif
- error = kern_rmdir(td, path, UIO_SYSSPACE);
+ error = kern_rmdirat(td, AT_FDCWD, path, UIO_SYSSPACE);
LFREEPATH(path);
return (error);
}
@@ -783,7 +788,7 @@ linux_rename(struct thread *td, struct l
if (ldebug(rename))
printf(ARGS(rename, "%s, %s"), from, to);
#endif
- error = kern_rename(td, from, to, UIO_SYSSPACE);
+ error = kern_renameat(td, AT_FDCWD, from, AT_FDCWD, to, UIO_SYSSPACE);
LFREEPATH(from);
LFREEPATH(to);
return (error);
@@ -833,7 +838,7 @@ linux_symlink(struct thread *td, struct
if (ldebug(symlink))
printf(ARGS(symlink, "%s, %s"), path, to);
#endif
- error = kern_symlink(td, path, to, UIO_SYSSPACE);
+ error = kern_symlinkat(td, path, AT_FDCWD, to, UIO_SYSSPACE);
LFREEPATH(path);
LFREEPATH(to);
return (error);
@@ -878,8 +883,8 @@ linux_readlink(struct thread *td, struct
printf(ARGS(readlink, "%s, %p, %d"), name, (void *)args->buf,
args->count);
#endif
- error = kern_readlink(td, name, UIO_SYSSPACE, args->buf, UIO_USERSPACE,
- args->count);
+ error = kern_readlinkat(td, AT_FDCWD, name, UIO_SYSSPACE,
+ args->buf, UIO_USERSPACE, args->count);
LFREEPATH(name);
return (error);
}
@@ -972,7 +977,8 @@ linux_link(struct thread *td, struct lin
if (ldebug(link))
printf(ARGS(link, "%s, %s"), path, to);
#endif
- error = kern_link(td, path, to, UIO_SYSSPACE);
+ error = kern_linkat(td, AT_FDCWD, AT_FDCWD, path, to, UIO_SYSSPACE,
+ FOLLOW);
LFREEPATH(path);
LFREEPATH(to);
return (error);
@@ -1487,7 +1493,8 @@ linux_chown(struct thread *td, struct li
if (ldebug(chown))
printf(ARGS(chown, "%s, %d, %d"), path, args->uid, args->gid);
#endif
- error = kern_chown(td, path, UIO_SYSSPACE, args->uid, args->gid);
+ error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, args->uid,
+ args->gid, 0);
LFREEPATH(path);
return (error);
}
@@ -1529,7 +1536,8 @@ linux_lchown(struct thread *td, struct l
if (ldebug(lchown))
printf(ARGS(lchown, "%s, %d, %d"), path, args->uid, args->gid);
#endif
- error = kern_lchown(td, path, UIO_SYSSPACE, args->uid, args->gid);
+ error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, args->uid,
+ args->gid, AT_SYMLINK_NOFOLLOW);
LFREEPATH(path);
return (error);
}
Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/linux/linux_misc.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -777,7 +777,8 @@ linux_utime(struct thread *td, struct li
} else
tvp = NULL;
- error = kern_utimes(td, fname, UIO_SYSSPACE, tvp, UIO_SYSSPACE);
+ error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE, tvp,
+ UIO_SYSSPACE);
LFREEPATH(fname);
return (error);
}
@@ -809,7 +810,8 @@ linux_utimes(struct thread *td, struct l
tvp = tv;
}
- error = kern_utimes(td, fname, UIO_SYSSPACE, tvp, UIO_SYSSPACE);
+ error = kern_utimesat(td, AT_FDCWD, fname, UIO_SYSSPACE,
+ tvp, UIO_SYSSPACE);
LFREEPATH(fname);
return (error);
}
@@ -914,13 +916,14 @@ linux_mknod(struct thread *td, struct li
switch (args->mode & S_IFMT) {
case S_IFIFO:
case S_IFSOCK:
- error = kern_mkfifo(td, path, UIO_SYSSPACE, args->mode);
+ error = kern_mkfifoat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ args->mode);
break;
case S_IFCHR:
case S_IFBLK:
- error = kern_mknod(td, path, UIO_SYSSPACE, args->mode,
- args->dev);
+ error = kern_mknodat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ args->mode, args->dev);
break;
case S_IFDIR:
@@ -931,7 +934,7 @@ linux_mknod(struct thread *td, struct li
args->mode |= S_IFREG;
/* FALLTHROUGH */
case S_IFREG:
- error = kern_open(td, path, UIO_SYSSPACE,
+ error = kern_openat(td, AT_FDCWD, path, UIO_SYSSPACE,
O_WRONLY | O_CREAT | O_TRUNC, args->mode);
if (error == 0)
kern_close(td, td->td_retval[0]);
Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/linux/linux_socket.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -731,7 +731,7 @@ linux_bind(struct thread *td, struct lin
if (error)
return (error);
- error = kern_bind(td, args->s, sa);
+ error = kern_bindat(td, AT_FDCWD, args->s, sa);
free(sa, M_SONAME);
if (error == EADDRNOTAVAIL && args->namelen != sizeof(struct sockaddr_in))
return (EINVAL);
@@ -759,7 +759,7 @@ linux_connect(struct thread *td, struct
if (error)
return (error);
- error = kern_connect(td, args->s, sa);
+ error = kern_connectat(td, AT_FDCWD, args->s, sa);
free(sa, M_SONAME);
if (error != EISCONN)
return (error);
Modified: head/sys/compat/linux/linux_stats.c
==============================================================================
--- head/sys/compat/linux/linux_stats.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/linux/linux_stats.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -77,7 +77,7 @@ linux_kern_statat(struct thread *td, int
enum uio_seg pathseg, struct stat *sbp)
{
- return (kern_statat_vnhook(td, flag, fd, path, pathseg, sbp,
+ return (kern_statat(td, flag, fd, path, pathseg, sbp,
translate_vnhook_major_minor));
}
Modified: head/sys/compat/linux/linux_uid16.c
==============================================================================
--- head/sys/compat/linux/linux_uid16.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/linux/linux_uid16.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -121,8 +121,8 @@ linux_chown16(struct thread *td, struct
args->gid);
LIN_SDT_PROBE1(uid16, linux_chown16, conv_path, path);
- error = kern_chown(td, path, UIO_SYSSPACE, CAST_NOCHG(args->uid),
- CAST_NOCHG(args->gid));
+ error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), 0);
LFREEPATH(path);
LIN_SDT_PROBE1(uid16, linux_chown16, return, error);
@@ -146,8 +146,8 @@ linux_lchown16(struct thread *td, struct
args->gid);
LIN_SDT_PROBE1(uid16, linux_lchown16, conv_path, path);
- error = kern_lchown(td, path, UIO_SYSSPACE, CAST_NOCHG(args->uid),
- CAST_NOCHG(args->gid));
+ error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), AT_SYMLINK_NOFOLLOW);
LFREEPATH(path);
LIN_SDT_PROBE1(uid16, linux_lchown16, return, error);
Modified: head/sys/compat/svr4/svr4_fcntl.c
==============================================================================
--- head/sys/compat/svr4/svr4_fcntl.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/svr4/svr4_fcntl.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -390,7 +390,8 @@ svr4_sys_open(td, uap)
CHECKALTEXIST(td, uap->path, &newpath);
bsd_flags = svr4_to_bsd_flags(uap->flags);
- error = kern_open(td, newpath, UIO_SYSSPACE, bsd_flags, uap->mode);
+ error = kern_openat(td, AT_FDCWD, newpath, UIO_SYSSPACE, bsd_flags,
+ uap->mode);
free(newpath, M_TEMP);
if (error) {
@@ -450,8 +451,8 @@ svr4_sys_creat(td, uap)
CHECKALTEXIST(td, uap->path, &newpath);
- error = kern_open(td, newpath, UIO_SYSSPACE, O_WRONLY | O_CREAT |
- O_TRUNC, uap->mode);
+ error = kern_openat(td, AT_FDCWD, newpath, UIO_SYSSPACE,
+ O_WRONLY | O_CREAT | O_TRUNC, uap->mode);
free(newpath, M_TEMP);
return (error);
}
@@ -494,7 +495,8 @@ svr4_sys_access(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &newpath);
- error = kern_access(td, newpath, UIO_SYSSPACE, uap->amode);
+ error = kern_accessat(td, AT_FDCWD, newpath, UIO_SYSSPACE,
+ 0, uap->amode);
free(newpath, M_TEMP);
return (error);
}
Modified: head/sys/compat/svr4/svr4_misc.c
==============================================================================
--- head/sys/compat/svr4/svr4_misc.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/svr4/svr4_misc.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -653,10 +653,13 @@ svr4_mknod(td, retval, path, mode, dev)
CHECKALTEXIST(td, path, &newpath);
- if (S_ISFIFO(mode))
- error = kern_mkfifo(td, newpath, UIO_SYSSPACE, mode);
- else
- error = kern_mknod(td, newpath, UIO_SYSSPACE, mode, dev);
+ if (S_ISFIFO(mode)) {
+ error = kern_mkfifoat(td, AT_FDCWD, newpath, UIO_SYSSPACE,
+ mode);
+ } else {
+ error = kern_mknodat(td, AT_FDCWD, newpath, UIO_SYSSPACE,
+ mode, dev);
+ }
free(newpath, M_TEMP);
return (error);
}
Modified: head/sys/compat/svr4/svr4_stat.c
==============================================================================
--- head/sys/compat/svr4/svr4_stat.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/svr4/svr4_stat.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/filedesc.h>
+#include <sys/fcntl.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@@ -170,7 +171,7 @@ svr4_sys_stat(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_stat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
@@ -195,7 +196,8 @@ svr4_sys_lstat(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, path,
+ UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
@@ -238,7 +240,7 @@ svr4_sys_xstat(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_stat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
@@ -265,7 +267,8 @@ svr4_sys_lxstat(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, path,
+ UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
@@ -309,7 +312,7 @@ svr4_sys_stat64(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_stat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
@@ -335,7 +338,8 @@ svr4_sys_lstat64(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, path,
+ UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
@@ -582,7 +586,8 @@ svr4_sys_utime(td, uap)
tp = NULL;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_utimes(td, path, UIO_SYSSPACE, tp, UIO_SYSSPACE);
+ error = kern_utimesat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ tp, UIO_SYSSPACE);
free(path, M_TEMP);
return (error);
}
@@ -597,7 +602,8 @@ svr4_sys_utimes(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_utimes(td, path, UIO_SYSSPACE, uap->tptr, UIO_USERSPACE);
+ error = kern_utimesat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ uap->tptr, UIO_USERSPACE);
free(path, M_TEMP);
return (error);
}
Modified: head/sys/compat/svr4/svr4_stream.c
==============================================================================
--- head/sys/compat/svr4/svr4_stream.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/compat/svr4/svr4_stream.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -282,7 +282,8 @@ clean_pipe(td, path)
struct stat st;
int error;
- error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, path,
+ UIO_SYSSPACE, &st, NULL);
/*
* Make sure we are dealing with a mode 0 named pipe.
@@ -293,7 +294,7 @@ clean_pipe(td, path)
if ((st.st_mode & ALLPERMS) != 0)
return (0);
- error = kern_unlink(td, path, UIO_SYSSPACE);
+ error = kern_unlinkat(td, AT_FDCWD, path, UIO_SYSSPACE, 0);
if (error)
DPRINTF(("clean_pipe: unlink failed %d\n", error));
return (error);
@@ -812,7 +813,7 @@ ti_bind(fp, fd, ioc, td)
DPRINTF(("TI_BIND: fileno %d\n", fd));
- if ((error = kern_bind(td, fd, skp)) != 0) {
+ if ((error = kern_bindat(td, AT_FDCWD, fd, skp)) != 0) {
DPRINTF(("TI_BIND: bind failed %d\n", error));
return error;
}
@@ -1586,7 +1587,7 @@ svr4_do_putmsg(td, uap, fp)
case SVR4_TI_CONNECT_REQUEST: /* connect */
{
- return (kern_connect(td, uap->fd, sa));
+ return (kern_connectat(td, AT_FDCWD, uap->fd, sa));
}
case SVR4_TI_SENDTO_REQUEST: /* sendto */
Modified: head/sys/dev/streams/streams.c
==============================================================================
--- head/sys/dev/streams/streams.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/dev/streams/streams.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -302,7 +302,8 @@ svr4_ptm_alloc(td)
ptyname[8] = ttyletters[l];
ptyname[9] = ttynumbers[n];
- error = kern_open(td, ptyname, UIO_SYSSPACE, O_RDWR, 0);
+ error = kern_openat(td, AT_FDCWD, ptyname, UIO_SYSSPACE,
+ O_RDWR, 0);
switch (error) {
case ENOENT:
case ENXIO:
Modified: head/sys/i386/ibcs2/ibcs2_fcntl.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_fcntl.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/i386/ibcs2/ibcs2_fcntl.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -189,7 +189,7 @@ ibcs2_open(td, uap)
CHECKALTCREAT(td, uap->path, &path);
else
CHECKALTEXIST(td, uap->path, &path);
- ret = kern_open(td, path, UIO_SYSSPACE, flags, uap->mode);
+ ret = kern_openat(td, AT_FDCWD, path, UIO_SYSSPACE, flags, uap->mode);
#ifdef SPX_HACK
if (ret == ENXIO) {
@@ -230,8 +230,8 @@ ibcs2_creat(td, uap)
int error;
CHECKALTCREAT(td, uap->path, &path);
- error = kern_open(td, path, UIO_SYSSPACE, O_WRONLY | O_CREAT | O_TRUNC,
- uap->mode);
+ error = kern_openat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ O_WRONLY | O_CREAT | O_TRUNC, uap->mode);
free(path, M_TEMP);
return (error);
}
@@ -245,7 +245,7 @@ ibcs2_access(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_access(td, path, UIO_SYSSPACE, uap->amode);
+ error = kern_accessat(td, AT_FDCWD, path, UIO_SYSSPACE, 0, uap->amode);
free(path, M_TEMP);
return (error);
}
Modified: head/sys/i386/ibcs2/ibcs2_misc.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_misc.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/i386/ibcs2/ibcs2_misc.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -646,10 +646,13 @@ ibcs2_mknod(td, uap)
int error;
CHECKALTCREAT(td, uap->path, &path);
- if (S_ISFIFO(uap->mode))
- error = kern_mkfifo(td, path, UIO_SYSSPACE, uap->mode);
- else
- error = kern_mknod(td, path, UIO_SYSSPACE, uap->mode, uap->dev);
+ if (S_ISFIFO(uap->mode)) {
+ error = kern_mkfifoat(td, AT_FDCWD, path,
+ UIO_SYSSPACE, uap->mode);
+ } else {
+ error = kern_mknodat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ uap->mode, uap->dev);
+ }
free(path, M_TEMP);
return (error);
}
@@ -938,7 +941,8 @@ ibcs2_utime(td, uap)
tp = NULL;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_utimes(td, path, UIO_SYSSPACE, tp, UIO_SYSSPACE);
+ error = kern_utimesat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ tp, UIO_SYSSPACE);
free(path, M_TEMP);
return (error);
}
@@ -1119,7 +1123,7 @@ ibcs2_unlink(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_unlink(td, path, UIO_SYSSPACE);
+ error = kern_unlinkat(td, AT_FDCWD, path, UIO_SYSSPACE, 0);
free(path, M_TEMP);
return (error);
}
@@ -1147,7 +1151,7 @@ ibcs2_chmod(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_chmod(td, path, UIO_SYSSPACE, uap->mode);
+ error = kern_fchmodat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->mode, 0);
free(path, M_TEMP);
return (error);
}
@@ -1161,7 +1165,8 @@ ibcs2_chown(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_chown(td, path, UIO_SYSSPACE, uap->uid, uap->gid);
+ error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->uid,
+ uap->gid, 0);
free(path, M_TEMP);
return (error);
}
@@ -1175,7 +1180,7 @@ ibcs2_rmdir(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_rmdir(td, path, UIO_SYSSPACE);
+ error = kern_rmdirat(td, AT_FDCWD, path, UIO_SYSSPACE);
free(path, M_TEMP);
return (error);
}
@@ -1189,7 +1194,7 @@ ibcs2_mkdir(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_mkdir(td, path, UIO_SYSSPACE, uap->mode);
+ error = kern_mkdirat(td, AT_FDCWD, path, UIO_SYSSPACE, uap->mode);
free(path, M_TEMP);
return (error);
}
@@ -1213,7 +1218,7 @@ ibcs2_symlink(td, uap)
free(path, M_TEMP);
return (error);
}
- error = kern_symlink(td, path, link, UIO_SYSSPACE);
+ error = kern_symlinkat(td, path, AT_FDCWD, link, UIO_SYSSPACE);
free(path, M_TEMP);
free(link, M_TEMP);
return (error);
@@ -1238,7 +1243,7 @@ ibcs2_rename(td, uap)
free(from, M_TEMP);
return (error);
}
- error = kern_rename(td, from, to, UIO_SYSSPACE);
+ error = kern_renameat(td, AT_FDCWD, from, AT_FDCWD, to, UIO_SYSSPACE);
free(from, M_TEMP);
free(to, M_TEMP);
return (error);
@@ -1253,8 +1258,8 @@ ibcs2_readlink(td, uap)
int error;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_readlink(td, path, UIO_SYSSPACE, uap->buf, UIO_USERSPACE,
- uap->count);
+ error = kern_readlinkat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ uap->buf, UIO_USERSPACE, uap->count);
free(path, M_TEMP);
return (error);
}
Modified: head/sys/i386/ibcs2/ibcs2_other.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_other.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/i386/ibcs2/ibcs2_other.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/fcntl.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/syscallsubr.h>
@@ -107,7 +108,7 @@ spx_open(struct thread *td)
sun.sun_len = sizeof(struct sockaddr_un) - sizeof(sun.sun_path) +
strlen(sun.sun_path) + 1;
- error = kern_connect(td, fd, (struct sockaddr *)&sun);
+ error = kern_connectat(td, AT_FDCWD, fd, (struct sockaddr *)&sun);
if (error) {
kern_close(td, fd);
return error;
Modified: head/sys/i386/ibcs2/ibcs2_stat.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_stat.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/i386/ibcs2/ibcs2_stat.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/namei.h>
+#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/filedesc.h>
@@ -145,7 +146,7 @@ ibcs2_stat(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_stat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
@@ -166,7 +167,8 @@ ibcs2_lstat(td, uap)
CHECKALTEXIST(td, uap->path, &path);
- error = kern_lstat(td, path, UIO_SYSSPACE, &st);
+ error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, path,
+ UIO_SYSSPACE, &st, NULL);
free(path, M_TEMP);
if (error)
return (error);
Modified: head/sys/i386/ibcs2/ibcs2_xenix.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_xenix.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/i386/ibcs2/ibcs2_xenix.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/fcntl.h>
#include <sys/namei.h>
#include <sys/sysproto.h>
#include <sys/clock.h>
@@ -209,7 +210,8 @@ xenix_eaccess(struct thread *td, struct
bsd_flags |= X_OK;
CHECKALTEXIST(td, uap->path, &path);
- error = kern_eaccess(td, path, UIO_SYSSPACE, bsd_flags);
+ error = kern_accessat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ AT_EACCESS, bsd_flags);
free(path, M_TEMP);
return (error);
}
Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/kern/kern_descrip.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -2215,8 +2215,8 @@ fdcheckstd(struct thread *td)
if (devnull != -1) {
error = do_dup(td, DUP_FIXED, devnull, i);
} else {
- error = kern_open(td, "/dev/null", UIO_SYSSPACE,
- O_RDWR, 0);
+ error = kern_openat(td, AT_FDCWD, "/dev/null",
+ UIO_SYSSPACE, O_RDWR, 0);
if (error == 0) {
devnull = td->td_retval[0];
KASSERT(devnull == i, ("we didn't get our fd"));
Modified: head/sys/kern/uipc_syscalls.c
==============================================================================
--- head/sys/kern/uipc_syscalls.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/kern/uipc_syscalls.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -242,13 +242,13 @@ sys_bind(td, uap)
error = getsockaddr(&sa, uap->name, uap->namelen);
if (error == 0) {
- error = kern_bind(td, uap->s, sa);
+ error = kern_bindat(td, AT_FDCWD, uap->s, sa);
free(sa, M_SONAME);
}
return (error);
}
-static int
+int
kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
{
struct socket *so;
@@ -282,13 +282,6 @@ kern_bindat(struct thread *td, int dirfd
return (error);
}
-int
-kern_bind(struct thread *td, int fd, struct sockaddr *sa)
-{
-
- return (kern_bindat(td, AT_FDCWD, fd, sa));
-}
-
/* ARGSUSED */
int
sys_bindat(td, uap)
@@ -595,13 +588,13 @@ sys_connect(td, uap)
error = getsockaddr(&sa, uap->name, uap->namelen);
if (error == 0) {
- error = kern_connect(td, uap->s, sa);
+ error = kern_connectat(td, AT_FDCWD, uap->s, sa);
free(sa, M_SONAME);
}
return (error);
}
-static int
+int
kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
{
struct socket *so;
@@ -664,13 +657,6 @@ done1:
return (error);
}
-int
-kern_connect(struct thread *td, int fd, struct sockaddr *sa)
-{
-
- return (kern_connectat(td, AT_FDCWD, fd, sa));
-}
-
/* ARGSUSED */
int
sys_connectat(td, uap)
Modified: head/sys/kern/vfs_mountroot.c
==============================================================================
--- head/sys/kern/vfs_mountroot.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/kern/vfs_mountroot.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -238,7 +238,7 @@ vfs_mountroot_devfs(struct thread *td, s
*mpp = mp;
set_rootvnode();
- error = kern_symlink(td, "/", "dev", UIO_SYSSPACE);
+ error = kern_symlinkat(td, "/", AT_FDCWD, "dev", UIO_SYSSPACE);
if (error)
printf("kern_symlink /dev -> / returns %d\n", error);
@@ -350,7 +350,8 @@ vfs_mountroot_shuffle(struct thread *td,
if (mporoot == mpdevfs) {
vfs_unbusy(mpdevfs);
/* Unlink the no longer needed /dev/dev -> / symlink */
- error = kern_unlink(td, "/dev/dev", UIO_SYSSPACE);
+ error = kern_unlinkat(td, AT_FDCWD, "/dev/dev",
+ UIO_SYSSPACE, 0);
if (error && bootverbose)
printf("mountroot: unable to unlink /dev/dev "
"(error %d)\n", error);
@@ -524,12 +525,13 @@ parse_dir_md(char **conf)
free(tok, M_TEMP);
/* Get file status. */
- error = kern_stat(td, path, UIO_SYSSPACE, &sb);
+ error = kern_statat(td, 0, AT_FDCWD, path, UIO_SYSSPACE, &sb, NULL);
if (error)
goto out;
/* Open /dev/mdctl so that we can attach/detach. */
- error = kern_open(td, "/dev/" MDCTL_NAME, UIO_SYSSPACE, O_RDWR, 0);
+ error = kern_openat(td, AT_FDCWD, "/dev/" MDCTL_NAME, UIO_SYSSPACE,
+ O_RDWR, 0);
if (error)
goto out;
Modified: head/sys/kern/vfs_syscalls.c
==============================================================================
--- head/sys/kern/vfs_syscalls.c Thu Nov 13 17:54:17 2014 (r274475)
+++ head/sys/kern/vfs_syscalls.c Thu Nov 13 18:01:51 2014 (r274476)
@@ -96,8 +96,6 @@ SDT_PROBE_DEFINE2(vfs, , stat, reg, "cha
static int chroot_refuse_vdir_fds(struct filedesc *fdp);
static int getutimes(const struct timeval *, enum uio_seg, struct timespec *);
-static int kern_chflags(struct thread *td, const char *path,
- enum uio_seg pathseg, u_long flags);
static int kern_chflagsat(struct thread *td, int fd, const char *path,
enum uio_seg pathseg, u_long flags, int atflag);
static int setfflags(struct thread *td, struct vnode *, u_long);
@@ -1012,7 +1010,8 @@ sys_open(td, uap)
} */ *uap;
{
- return (kern_open(td, uap->path, UIO_USERSPACE, uap->flags, uap->mode));
+ return (kern_openat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
+ uap->flags, uap->mode));
}
#ifndef _SYS_SYSPROTO_H_
@@ -1032,14 +1031,6 @@ sys_openat(struct thread *td, struct ope
}
int
-kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
- int mode)
-{
-
- return (kern_openat(td, AT_FDCWD, path, pathseg, flags, mode));
-}
-
-int
kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int flags, int mode)
{
@@ -1197,7 +1188,7 @@ ocreat(td, uap)
} */ *uap;
{
- return (kern_open(td, uap->path, UIO_USERSPACE,
+ return (kern_openat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
O_WRONLY | O_CREAT | O_TRUNC, uap->mode));
}
#endif /* COMPAT_43 */
@@ -1222,7 +1213,8 @@ sys_mknod(td, uap)
} */ *uap;
{
- return (kern_mknod(td, uap->path, UIO_USERSPACE, uap->mode, uap->dev));
+ return (kern_mknodat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
+ uap->mode, uap->dev));
}
#ifndef _SYS_SYSPROTO_H_
@@ -1242,14 +1234,6 @@ sys_mknodat(struct thread *td, struct mk
}
int
-kern_mknod(struct thread *td, char *path, enum uio_seg pathseg, int mode,
- int dev)
-{
-
- return (kern_mknodat(td, AT_FDCWD, path, pathseg, mode, dev));
-}
-
-int
kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int mode, int dev)
{
@@ -1368,7 +1352,8 @@ sys_mkfifo(td, uap)
} */ *uap;
{
- return (kern_mkfifo(td, uap->path, UIO_USERSPACE, uap->mode));
+ return (kern_mkfifoat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
+ uap->mode));
}
#ifndef _SYS_SYSPROTO_H_
@@ -1387,13 +1372,6 @@ sys_mkfifoat(struct thread *td, struct m
}
int
-kern_mkfifo(struct thread *td, char *path, enum uio_seg pathseg, int mode)
-{
-
- return (kern_mkfifoat(td, AT_FDCWD, path, pathseg, mode));
-}
-
-int
kern_mkfifoat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int mode)
{
@@ -1465,7 +1443,8 @@ sys_link(td, uap)
} */ *uap;
{
- return (kern_link(td, uap->path, uap->link, UIO_USERSPACE));
+ return (kern_linkat(td, AT_FDCWD, AT_FDCWD, uap->path, uap->link,
+ UIO_USERSPACE, FOLLOW));
}
#ifndef _SYS_SYSPROTO_H_
@@ -1530,13 +1509,6 @@ can_hardlink(struct vnode *vp, struct uc
}
int
-kern_link(struct thread *td, char *path, char *link, enum uio_seg segflg)
-{
-
- return (kern_linkat(td, AT_FDCWD, AT_FDCWD, path,link, segflg, FOLLOW));
-}
-
-int
kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2,
enum uio_seg segflg, int follow)
{
@@ -1638,7 +1610,8 @@ sys_symlink(td, uap)
} */ *uap;
{
- return (kern_symlink(td, uap->path, uap->link, UIO_USERSPACE));
+ return (kern_symlinkat(td, uap->path, AT_FDCWD, uap->link,
+ UIO_USERSPACE));
}
#ifndef _SYS_SYSPROTO_H_
@@ -1657,13 +1630,6 @@ sys_symlinkat(struct thread *td, struct
}
int
-kern_symlink(struct thread *td, char *path, char *link, enum uio_seg segflg)
-{
-
- return (kern_symlinkat(td, path, AT_FDCWD, link, segflg));
-}
-
-int
kern_symlinkat(struct thread *td, char *path1, int fd, char *path2,
enum uio_seg segflg)
{
@@ -1791,7 +1757,7 @@ sys_unlink(td, uap)
} */ *uap;
{
- return (kern_unlink(td, uap->path, UIO_USERSPACE));
+ return (kern_unlinkat(td, AT_FDCWD, uap->path, UIO_USERSPACE, 0));
}
#ifndef _SYS_SYSPROTO_H_
@@ -1818,13 +1784,6 @@ sys_unlinkat(struct thread *td, struct u
}
int
-kern_unlink(struct thread *td, char *path, enum uio_seg pathseg)
-{
-
- return (kern_unlinkat(td, AT_FDCWD, path, pathseg, 0));
-}
-
-int
kern_unlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
ino_t oldinum)
{
@@ -2027,7 +1986,8 @@ sys_access(td, uap)
} */ *uap;
{
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-all
mailing list