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
This commit is contained in:
kib 2014-11-13 18:01:51 +00:00
parent bc10954c50
commit b4ef709604
23 changed files with 185 additions and 326 deletions

View File

@ -282,7 +282,7 @@ vn_rename(char *from, char *to, enum uio_seg seg)
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, enum rm dirflag)
ASSERT(seg == UIO_SYSSPACE);
ASSERT(dirflag == RMFILE);
return (kern_unlink(curthread, fnamep, seg));
return (kern_unlinkat(curthread, AT_FDCWD, fnamep, seg, 0));
}
#endif /* _KERNEL */

View File

@ -1231,7 +1231,8 @@ freebsd32_utimes(struct thread *td, struct freebsd32_utimes_args *uap)
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 freebsd32_stat_args *uap)
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, struct ofreebsd32_stat_args *uap)
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, struct freebsd32_fstatat_args *uap)
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, struct freebsd32_lstat_args *uap)
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, struct ofreebsd32_lstat_args *uap)
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);

View File

@ -82,8 +82,8 @@ linux_creat(struct thread *td, struct linux_creat_args *args)
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 linux_access_args *args)
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 linux_unlink_args *args)
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 linux_unlinkat_args *args)
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 linux_chmod_args *args)
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 linux_mkdir_args *args)
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 linux_rmdir_args *args)
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 linux_rename_args *args)
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 linux_symlink_args *args)
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 linux_readlink_args *args)
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 linux_link_args *args)
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 linux_chown_args *args)
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 linux_lchown_args *args)
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);
}

View File

@ -777,7 +777,8 @@ linux_utime(struct thread *td, struct linux_utime_args *args)
} 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 linux_utimes_args *args)
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 linux_mknod_args *args)
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 linux_mknod_args *args)
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]);

View File

@ -731,7 +731,7 @@ linux_bind(struct thread *td, struct linux_bind_args *args)
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 linux_connect_args *args)
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);

View File

@ -77,7 +77,7 @@ linux_kern_statat(struct thread *td, int flag, int fd, char *path,
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));
}

View File

@ -121,8 +121,8 @@ linux_chown16(struct thread *td, struct linux_chown16_args *args)
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 linux_lchown16_args *args)
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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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 */

View File

@ -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:

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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 xenix_eaccess_args *uap)
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);
}

View File

@ -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"));

View File

@ -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, int fd, struct sockaddr *sa)
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 @@ kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
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)

View File

@ -238,7 +238,7 @@ vfs_mountroot_devfs(struct thread *td, struct mount **mpp)
*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, struct mount *mpdevfs)
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;

View File

@ -96,8 +96,6 @@ SDT_PROBE_DEFINE2(vfs, , stat, reg, "char *", "int");
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_
@ -1031,14 +1030,6 @@ sys_openat(struct thread *td, struct openat_args *uap)
uap->mode));
}
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_
@ -1241,14 +1233,6 @@ sys_mknodat(struct thread *td, struct mknodat_args *uap)
uap->dev));
}
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_
@ -1386,13 +1371,6 @@ sys_mkfifoat(struct thread *td, struct mkfifoat_args *uap)
uap->mode));
}
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_
@ -1529,13 +1508,6 @@ can_hardlink(struct vnode *vp, struct ucred *cred)
return (0);
}
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_
@ -1656,13 +1629,6 @@ sys_symlinkat(struct thread *td, struct symlinkat_args *uap)
UIO_USERSPACE));
}
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_
@ -1817,13 +1783,6 @@ sys_unlinkat(struct thread *td, struct unlinkat_args *uap)
return (kern_unlinkat(td, fd, path, UIO_USERSPACE, 0));
}
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;
{
return (kern_access(td, uap->path, UIO_USERSPACE, uap->amode));
return (kern_accessat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
0, uap->amode));
}
#ifndef _SYS_SYSPROTO_H_
@ -2042,19 +2002,10 @@ int
sys_faccessat(struct thread *td, struct faccessat_args *uap)
{
if (uap->flag & ~AT_EACCESS)
return (EINVAL);
return (kern_accessat(td, uap->fd, uap->path, UIO_USERSPACE, uap->flag,
uap->amode));
}
int
kern_access(struct thread *td, char *path, enum uio_seg pathseg, int amode)
{
return (kern_accessat(td, AT_FDCWD, path, pathseg, 0, amode));
}
int
kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int flag, int amode)
@ -2065,6 +2016,8 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
cap_rights_t rights;
int error;
if (flag & ~AT_EACCESS)
return (EINVAL);
if (amode != F_OK && (amode & ~(R_OK | W_OK | X_OK)) != 0)
return (EINVAL);
@ -2119,14 +2072,8 @@ sys_eaccess(td, uap)
} */ *uap;
{
return (kern_eaccess(td, uap->path, UIO_USERSPACE, uap->amode));
}
int
kern_eaccess(struct thread *td, char *path, enum uio_seg pathseg, int amode)
{
return (kern_accessat(td, AT_FDCWD, path, pathseg, AT_EACCESS, amode));
return (kern_accessat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
AT_EACCESS, uap->amode));
}
#if defined(COMPAT_43)
@ -2151,7 +2098,8 @@ ostat(td, uap)
struct ostat osb;
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 != 0)
return (error);
cvtstat(&sb, &osb);
@ -2179,7 +2127,8 @@ olstat(td, uap)
struct ostat osb;
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 != 0)
return (error);
cvtstat(&sb, &osb);
@ -2236,7 +2185,8 @@ sys_stat(td, uap)
struct stat sb;
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 == 0)
error = copyout(&sb, uap->ub, sizeof (sb));
return (error);
@ -2257,29 +2207,14 @@ sys_fstatat(struct thread *td, struct fstatat_args *uap)
int error;
error = kern_statat(td, uap->flag, uap->fd, uap->path,
UIO_USERSPACE, &sb);
UIO_USERSPACE, &sb, NULL);
if (error == 0)
error = copyout(&sb, uap->buf, sizeof (sb));
return (error);
}
int
kern_stat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
{
return (kern_statat(td, 0, AT_FDCWD, path, pathseg, sbp));
}
int
kern_statat(struct thread *td, int flag, int fd, char *path,
enum uio_seg pathseg, struct stat *sbp)
{
return (kern_statat_vnhook(td, flag, fd, path, pathseg, sbp, NULL));
}
int
kern_statat_vnhook(struct thread *td, int flag, int fd, char *path,
enum uio_seg pathseg, struct stat *sbp,
void (*hook)(struct vnode *vp, struct stat *sbp))
{
@ -2337,20 +2272,13 @@ sys_lstat(td, uap)
struct stat sb;
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 == 0)
error = copyout(&sb, uap->ub, sizeof (sb));
return (error);
}
int
kern_lstat(struct thread *td, char *path, enum uio_seg pathseg, struct stat *sbp)
{
return (kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, path, pathseg,
sbp));
}
/*
* Implementation of the NetBSD [l]stat() functions.
*/
@ -2397,7 +2325,8 @@ sys_nstat(td, uap)
struct nstat nsb;
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 != 0)
return (error);
cvtnstat(&sb, &nsb);
@ -2425,7 +2354,8 @@ sys_nlstat(td, uap)
struct nstat nsb;
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 != 0)
return (error);
cvtnstat(&sb, &nsb);
@ -2514,8 +2444,8 @@ sys_readlink(td, uap)
} */ *uap;
{
return (kern_readlink(td, uap->path, UIO_USERSPACE, uap->buf,
UIO_USERSPACE, uap->count));
return (kern_readlinkat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->buf, UIO_USERSPACE, uap->count));
}
#ifndef _SYS_SYSPROTO_H_
struct readlinkat_args {
@ -2533,15 +2463,6 @@ sys_readlinkat(struct thread *td, struct readlinkat_args *uap)
uap->buf, UIO_USERSPACE, uap->bufsize));
}
int
kern_readlink(struct thread *td, char *path, enum uio_seg pathseg, char *buf,
enum uio_seg bufseg, size_t count)
{
return (kern_readlinkat(td, AT_FDCWD, path, pathseg, buf, bufseg,
count));
}
int
kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
char *buf, enum uio_seg bufseg, size_t count)
@ -2650,7 +2571,8 @@ sys_chflags(td, uap)
} */ *uap;
{
return (kern_chflags(td, uap->path, UIO_USERSPACE, uap->flags));
return (kern_chflagsat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->flags, 0));
}
#ifndef _SYS_SYSPROTO_H_
@ -2675,14 +2597,6 @@ sys_chflagsat(struct thread *td, struct chflagsat_args *uap)
return (kern_chflagsat(td, fd, path, UIO_USERSPACE, flags, atflag));
}
static int
kern_chflags(struct thread *td, const char *path, enum uio_seg pathseg,
u_long flags)
{
return (kern_chflagsat(td, AT_FDCWD, path, pathseg, flags, 0));
}
/*
* Same as chflags() but doesn't follow symlinks.
*/
@ -2803,7 +2717,8 @@ sys_chmod(td, uap)
} */ *uap;
{
return (kern_chmod(td, uap->path, UIO_USERSPACE, uap->mode));
return (kern_fchmodat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->mode, 0));
}
#ifndef _SYS_SYSPROTO_H_
@ -2828,13 +2743,6 @@ sys_fchmodat(struct thread *td, struct fchmodat_args *uap)
return (kern_fchmodat(td, fd, path, UIO_USERSPACE, mode, flag));
}
int
kern_chmod(struct thread *td, char *path, enum uio_seg pathseg, int mode)
{
return (kern_fchmodat(td, AT_FDCWD, path, pathseg, mode, 0));
}
/*
* Change mode of a file given path name (don't follow links.)
*/
@ -2956,7 +2864,8 @@ sys_chown(td, uap)
} */ *uap;
{
return (kern_chown(td, uap->path, UIO_USERSPACE, uap->uid, uap->gid));
return (kern_fchownat(td, 0, uap->path, UIO_USERSPACE, uap->uid,
uap->gid, 0));
}
#ifndef _SYS_SYSPROTO_H_
@ -2981,14 +2890,6 @@ sys_fchownat(struct thread *td, struct fchownat_args *uap)
uap->gid, uap->flag));
}
int
kern_chown(struct thread *td, char *path, enum uio_seg pathseg, int uid,
int gid)
{
return (kern_fchownat(td, AT_FDCWD, path, pathseg, uid, gid, 0));
}
int
kern_fchownat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int uid, int gid, int flag)
@ -3030,16 +2931,8 @@ sys_lchown(td, uap)
} */ *uap;
{
return (kern_lchown(td, uap->path, UIO_USERSPACE, uap->uid, uap->gid));
}
int
kern_lchown(struct thread *td, char *path, enum uio_seg pathseg, int uid,
int gid)
{
return (kern_fchownat(td, AT_FDCWD, path, pathseg, uid, gid,
AT_SYMLINK_NOFOLLOW));
return (kern_fchownat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->uid, uap->gid, AT_SYMLINK_NOFOLLOW));
}
/*
@ -3169,8 +3062,8 @@ sys_utimes(td, uap)
} */ *uap;
{
return (kern_utimes(td, uap->path, UIO_USERSPACE, uap->tptr,
UIO_USERSPACE));
return (kern_utimesat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->tptr, UIO_USERSPACE));
}
#ifndef _SYS_SYSPROTO_H_
@ -3188,14 +3081,6 @@ sys_futimesat(struct thread *td, struct futimesat_args *uap)
uap->times, UIO_USERSPACE));
}
int
kern_utimes(struct thread *td, char *path, enum uio_seg pathseg,
struct timeval *tptr, enum uio_seg tptrseg)
{
return (kern_utimesat(td, AT_FDCWD, path, pathseg, tptr, tptrseg));
}
int
kern_utimesat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
struct timeval *tptr, enum uio_seg tptrseg)
@ -3495,7 +3380,8 @@ sys_rename(td, uap)
} */ *uap;
{
return (kern_rename(td, uap->from, uap->to, UIO_USERSPACE));
return (kern_renameat(td, AT_FDCWD, uap->from, AT_FDCWD,
uap->to, UIO_USERSPACE));
}
#ifndef _SYS_SYSPROTO_H_
@ -3514,13 +3400,6 @@ sys_renameat(struct thread *td, struct renameat_args *uap)
UIO_USERSPACE));
}
int
kern_rename(struct thread *td, char *from, char *to, enum uio_seg pathseg)
{
return (kern_renameat(td, AT_FDCWD, from, AT_FDCWD, to, pathseg));
}
int
kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new,
enum uio_seg pathseg)
@ -3670,7 +3549,8 @@ sys_mkdir(td, uap)
} */ *uap;
{
return (kern_mkdir(td, uap->path, UIO_USERSPACE, uap->mode));
return (kern_mkdirat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->mode));
}
#ifndef _SYS_SYSPROTO_H_
@ -3687,13 +3567,6 @@ sys_mkdirat(struct thread *td, struct mkdirat_args *uap)
return (kern_mkdirat(td, uap->fd, uap->path, UIO_USERSPACE, uap->mode));
}
int
kern_mkdir(struct thread *td, char *path, enum uio_seg segflg, int mode)
{
return (kern_mkdirat(td, AT_FDCWD, path, segflg, mode));
}
int
kern_mkdirat(struct thread *td, int fd, char *path, enum uio_seg segflg,
int mode)
@ -3772,14 +3645,7 @@ sys_rmdir(td, uap)
} */ *uap;
{
return (kern_rmdir(td, uap->path, UIO_USERSPACE));
}
int
kern_rmdir(struct thread *td, char *path, enum uio_seg pathseg)
{
return (kern_rmdirat(td, AT_FDCWD, path, pathseg));
return (kern_rmdirat(td, AT_FDCWD, uap->path, UIO_USERSPACE));
}
int

View File

@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 1100046 /* Master, propagated to newvers */
#define __FreeBSD_version 1100047 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,

View File

@ -63,22 +63,16 @@ int kern_accept(struct thread *td, int s, struct sockaddr **name,
socklen_t *namelen, struct file **fp);
int kern_accept4(struct thread *td, int s, struct sockaddr **name,
socklen_t *namelen, int flags, struct file **fp);
int kern_access(struct thread *td, char *path, enum uio_seg pathseg,
int flags);
int kern_accessat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int flags, int mode);
int kern_adjtime(struct thread *td, struct timeval *delta,
struct timeval *olddelta);
int kern_alternate_path(struct thread *td, const char *prefix, const char *path,
enum uio_seg pathseg, char **pathbuf, int create, int dirfd);
int kern_bind(struct thread *td, int fd, struct sockaddr *sa);
int kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa);
int kern_cap_ioctls_limit(struct thread *td, int fd, u_long *cmds,
size_t ncmds);
int kern_chdir(struct thread *td, char *path, enum uio_seg pathseg);
int kern_chmod(struct thread *td, char *path, enum uio_seg pathseg,
int mode);
int kern_chown(struct thread *td, char *path, enum uio_seg pathseg, int uid,
int gid);
int kern_clock_getcpuclockid2(struct thread *td, id_t id, int which,
clockid_t *clk_id);
int kern_clock_getres(struct thread *td, clockid_t clock_id,
@ -88,9 +82,8 @@ int kern_clock_gettime(struct thread *td, clockid_t clock_id,
int kern_clock_settime(struct thread *td, clockid_t clock_id,
struct timespec *ats);
int kern_close(struct thread *td, int fd);
int kern_connect(struct thread *td, int fd, struct sockaddr *sa);
int kern_eaccess(struct thread *td, char *path, enum uio_seg pathseg,
int flags);
int kern_connectat(struct thread *td, int dirfd, int fd,
struct sockaddr *sa);
int kern_execve(struct thread *td, struct image_args *args,
struct mac *mac_p);
int kern_fchmodat(struct thread *td, int fd, char *path,
@ -128,26 +121,14 @@ int kern_kevent(struct thread *td, int fd, int nchanges, int nevents,
int kern_kldload(struct thread *td, const char *file, int *fileid);
int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat);
int kern_kldunload(struct thread *td, int fileid, int flags);
int kern_lchown(struct thread *td, char *path, enum uio_seg pathseg,
int uid, int gid);
int kern_link(struct thread *td, char *path, char *link,
enum uio_seg segflg);
int kern_linkat(struct thread *td, int fd1, int fd2, char *path1,
char *path2, enum uio_seg segflg, int follow);
int kern_lstat(struct thread *td, char *path, enum uio_seg pathseg,
struct stat *sbp);
int kern_lutimes(struct thread *td, char *path, enum uio_seg pathseg,
struct timeval *tptr, enum uio_seg tptrseg);
int kern_mkdir(struct thread *td, char *path, enum uio_seg segflg,
int mode);
int kern_mkdirat(struct thread *td, int fd, char *path,
enum uio_seg segflg, int mode);
int kern_mkfifo(struct thread *td, char *path, enum uio_seg pathseg,
int mode);
int kern_mkfifoat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int mode);
int kern_mknod(struct thread *td, char *path, enum uio_seg pathseg,
int mode, int dev);
int kern_mknodat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int mode, int dev);
int kern_msgctl(struct thread *, int, int, struct msqid_ds *);
@ -157,8 +138,6 @@ int kern_nanosleep(struct thread *td, struct timespec *rqt,
struct timespec *rmt);
int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,
long *ploff);
int kern_open(struct thread *td, char *path, enum uio_seg pathseg,
int flags, int mode);
int kern_openat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int flags, int mode);
int kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg,
@ -179,18 +158,13 @@ int kern_pselect(struct thread *td, int nd, fd_set *in, fd_set *ou,
int kern_ptrace(struct thread *td, int req, pid_t pid, void *addr,
int data);
int kern_pwritev(struct thread *td, int fd, struct uio *auio, off_t offset);
int kern_readlink(struct thread *td, char *path, enum uio_seg pathseg,
char *buf, enum uio_seg bufseg, size_t count);
int kern_readlinkat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, char *buf, enum uio_seg bufseg, size_t count);
int kern_readv(struct thread *td, int fd, struct uio *auio);
int kern_recvit(struct thread *td, int s, struct msghdr *mp,
enum uio_seg fromseg, struct mbuf **controlp);
int kern_rename(struct thread *td, char *from, char *to,
enum uio_seg pathseg);
int kern_renameat(struct thread *td, int oldfd, char *old, int newfd,
char *new, enum uio_seg pathseg);
int kern_rmdir(struct thread *td, char *path, enum uio_seg pathseg);
int kern_rmdirat(struct thread *td, int fd, char *path,
enum uio_seg pathseg);
int kern_sched_rr_get_interval(struct thread *td, pid_t pid,
@ -223,17 +197,11 @@ int kern_sigprocmask(struct thread *td, int how,
int kern_sigsuspend(struct thread *td, sigset_t mask);
int kern_sigtimedwait(struct thread *td, sigset_t waitset,
struct ksiginfo *ksi, struct timespec *timeout);
int kern_stat(struct thread *td, char *path, enum uio_seg pathseg,
struct stat *sbp);
int kern_statat(struct thread *td, int flag, int fd, char *path,
enum uio_seg pathseg, struct stat *sbp);
int kern_statat_vnhook(struct thread *td, int flag, int fd, char *path,
enum uio_seg pathseg, struct stat *sbp,
void (*hook)(struct vnode *vp, struct stat *sbp));
int kern_statfs(struct thread *td, char *path, enum uio_seg pathseg,
struct statfs *buf);
int kern_symlink(struct thread *td, char *path, char *link,
enum uio_seg segflg);
int kern_symlinkat(struct thread *td, char *path1, int fd, char *path2,
enum uio_seg segflg);
int kern_ktimer_create(struct thread *td, clockid_t clock_id,
@ -248,11 +216,8 @@ int kern_thr_new(struct thread *td, struct thr_param *param);
int kern_thr_suspend(struct thread *td, struct timespec *tsp);
int kern_truncate(struct thread *td, char *path, enum uio_seg pathseg,
off_t length);
int kern_unlink(struct thread *td, char *path, enum uio_seg pathseg);
int kern_unlinkat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, ino_t oldinum);
int kern_utimes(struct thread *td, char *path, enum uio_seg pathseg,
struct timeval *tptr, enum uio_seg tptrseg);
int kern_utimesat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, struct timeval *tptr, enum uio_seg tptrseg);
int kern_wait(struct thread *td, pid_t pid, int *status, int options,