Commit the 64-bit inode project.

Extend the ino_t, dev_t, nlink_t types to 64-bit ints.  Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment.  Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.

ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks.  Unfortunately, not everything can be
fixed, especially outside the base system.  For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.

Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.

Struct xvnode changed layout, no compat shims are provided.

For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.

Update note: strictly follow the instructions in UPDATING.  Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.

Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb).  Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver.  Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem).  Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).

Sponsored by:	The FreeBSD Foundation (emaste, kib)
Differential revision:	https://reviews.freebsd.org/D10439
This commit is contained in:
Konstantin Belousov 2017-05-23 09:29:05 +00:00
parent 5f7c516f21
commit 6992112349
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=318736
97 changed files with 4978 additions and 656 deletions

View File

@ -37,6 +37,7 @@ SRCS+= libzfs_changelist.c \
zprop_common.c \ zprop_common.c \
WARNS?= 0 WARNS?= 0
SHLIB_MAJOR= 3
CSTD= c99 CSTD= c99
CFLAGS+= -DZFS_NO_ACL CFLAGS+= -DZFS_NO_ACL
CFLAGS+= -I${SRCTOP}/sbin/mount CFLAGS+= -I${SRCTOP}/sbin/mount

View File

@ -223,7 +223,8 @@ static void kernel_stat_to_stat(struct kernel_stat *in, struct stat *out) {
uptr internal_stat(const char *path, void *buf) { uptr internal_stat(const char *path, void *buf) {
#if SANITIZER_FREEBSD #if SANITIZER_FREEBSD
return internal_syscall(SYSCALL(stat), path, buf); return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
(uptr)buf, 0);
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path,
(uptr)buf, 0); (uptr)buf, 0);
@ -247,7 +248,8 @@ uptr internal_stat(const char *path, void *buf) {
uptr internal_lstat(const char *path, void *buf) { uptr internal_lstat(const char *path, void *buf) {
#if SANITIZER_FREEBSD #if SANITIZER_FREEBSD
return internal_syscall(SYSCALL(lstat), path, buf); return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
(uptr)buf, AT_SYMLINK_NOFOLLOW);
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path,
(uptr)buf, AT_SYMLINK_NOFOLLOW); (uptr)buf, AT_SYMLINK_NOFOLLOW);
@ -590,7 +592,9 @@ uptr internal_getppid() {
} }
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) { uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS #if SANITIZER_FREEBSD
return internal_syscall(SYSCALL(getdirentries), fd, (uptr)dirp, count, NULL);
#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count); return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count);
#else #else
return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count); return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count);

View File

@ -489,7 +489,8 @@ namespace __sanitizer {
}; };
#elif SANITIZER_FREEBSD #elif SANITIZER_FREEBSD
struct __sanitizer_dirent { struct __sanitizer_dirent {
unsigned int d_fileno; unsigned long long d_fileno;
unsigned long long d_off;
unsigned short d_reclen; unsigned short d_reclen;
// more fields that we don't care about // more fields that we don't care about
}; };

View File

@ -264,12 +264,14 @@ audit_set_terminal_host(uint32_t *m)
int int
audit_set_terminal_id(au_tid_t *tid) audit_set_terminal_id(au_tid_t *tid)
{ {
dev_t port;
int ret; int ret;
if (tid == NULL) if (tid == NULL)
return (kAUBadParamErr); return (kAUBadParamErr);
if ((ret = audit_set_terminal_port(&tid->port)) != kAUNoErr) if ((ret = audit_set_terminal_port(&port)) != kAUNoErr)
return (ret); return (ret);
tid->port = port;
return (audit_set_terminal_host(&tid->machine)); return (audit_set_terminal_host(&tid->machine));
} }

View File

@ -41,6 +41,25 @@
#include <sys/_types.h> #include <sys/_types.h>
#include <sys/dirent.h> #include <sys/dirent.h>
#if __BSD_VISIBLE
#ifndef _SIZE_T_DECLARED
typedef __size_t size_t;
#define _SIZE_T_DECLARED
#endif
#ifndef _SSIZE_T_DECLARED
typedef __ssize_t ssize_t;
#define _SSIZE_T_DECLARED
#endif
#ifndef _OFF_T_DECLARED
typedef __off_t off_t;
#define _OFF_T_DECLARED
#endif
#endif /* __BSD_VISIBLE */
#if __XSI_VISIBLE #if __XSI_VISIBLE
#ifndef _INO_T_DECLARED #ifndef _INO_T_DECLARED
@ -89,8 +108,8 @@ int dirfd(DIR *);
#if __BSD_VISIBLE #if __BSD_VISIBLE
DIR *__opendir2(const char *, int); DIR *__opendir2(const char *, int);
int fdclosedir(DIR *); int fdclosedir(DIR *);
int getdents(int, char *, int); ssize_t getdents(int, char *, size_t);
int getdirentries(int, char *, int, long *); ssize_t getdirentries(int, char *, size_t, off_t *);
#endif #endif
DIR *opendir(const char *); DIR *opendir(const char *);
DIR *fdopendir(int); DIR *fdopendir(int);

View File

@ -11,7 +11,7 @@ CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
# FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system. # FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system.
# It has no real relation to the libarchive version number. # It has no real relation to the libarchive version number.
SHLIB_MAJOR= 6 SHLIB_MAJOR= 7
CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\" CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\"
CFLAGS+= -I${.OBJDIR} CFLAGS+= -I${.OBJDIR}

View File

@ -148,7 +148,15 @@ SRCS+= __getosreldate.c \
waitid.c \ waitid.c \
wordexp.c wordexp.c
.if ${MK_SYMVER} == yes .if ${MK_SYMVER} == yes
SRCS+= fts-compat.c \ SRCS+= devname-compat11.c \
fts-compat.c \
fts-compat11.c \
ftw-compat11.c \
getmntinfo-compat11.c \
glob-compat11.c \
nftw-compat11.c \
readdir-compat11.c \
scandir-compat11.c \
unvis-compat.c unvis-compat.c
.endif .endif

View File

@ -75,8 +75,6 @@ FBSD_1.0 {
ctermid; ctermid;
ctermid_r; ctermid_r;
daemon; daemon;
devname;
devname_r;
getdiskbyname; getdiskbyname;
dladdr; dladdr;
dlclose; dlclose;
@ -128,9 +126,6 @@ FBSD_1.0 {
setfsent; setfsent;
endfsent; endfsent;
ftok; ftok;
ftw;
glob;
globfree;
getbootfile; getbootfile;
getbsize; getbsize;
cgetset; cgetset;
@ -163,7 +158,6 @@ FBSD_1.0 {
getloadavg; getloadavg;
getlogin; getlogin;
getlogin_r; getlogin_r;
getmntinfo;
setnetgrent; setnetgrent;
getnetgrent; getnetgrent;
endnetgrent; endnetgrent;
@ -209,7 +203,6 @@ FBSD_1.0 {
lrand48; lrand48;
modf; modf;
mrand48; mrand48;
nftw;
nice; nice;
nlist; nlist;
nrand48; nrand48;
@ -220,13 +213,9 @@ FBSD_1.0 {
pclose; pclose;
psignal; psignal;
raise; raise;
readdir;
readdir_r;
readpassphrase; readpassphrase;
getpass; getpass;
rewinddir; rewinddir;
scandir;
alphasort;
seed48; seed48;
seekdir; seekdir;
user_from_uid; user_from_uid;
@ -314,14 +303,6 @@ FBSD_1.1 {
fdevname_r; fdevname_r;
fdopendir; fdopendir;
feature_present; feature_present;
fts_children;
fts_close;
fts_get_clientptr;
fts_get_stream;
fts_open;
fts_read;
fts_set;
fts_set_clientptr;
posix_spawn; posix_spawn;
posix_spawn_file_actions_addclose; posix_spawn_file_actions_addclose;
posix_spawn_file_actions_adddup2; posix_spawn_file_actions_adddup2;
@ -408,13 +389,32 @@ FBSD_1.4 {
pthread_mutex_consistent; pthread_mutex_consistent;
pthread_mutexattr_getrobust; pthread_mutexattr_getrobust;
pthread_mutexattr_setrobust; pthread_mutexattr_setrobust;
scandir_b;
stravis; stravis;
}; };
FBSD_1.5 { FBSD_1.5 {
alphasort;
basename; basename;
devname;
devname_r;
dirname; dirname;
fts_children;
fts_close;
fts_get_clientptr;
fts_get_stream;
fts_open;
fts_read;
fts_set;
fts_set_clientptr;
ftw;
getmntinfo;
glob;
globfree;
nftw;
readdir;
readdir_r;
scandir;
scandir_b;
sem_clockwait_np; sem_clockwait_np;
}; };

View File

@ -59,6 +59,7 @@ fdclosedir(DIR *dirp)
dirp->dd_fd = -1; dirp->dd_fd = -1;
dirp->dd_loc = 0; dirp->dd_loc = 0;
free((void *)dirp->dd_buf); free((void *)dirp->dd_buf);
free(dirp->dd_compat_de);
_reclaim_telldir(dirp); _reclaim_telldir(dirp);
if (__isthreaded) { if (__isthreaded) {
_pthread_mutex_unlock(&dirp->dd_lock); _pthread_mutex_unlock(&dirp->dd_lock);

View File

@ -0,0 +1,50 @@
/*-
* Copyright (c) 2011 Gleb Kurtsou <gleb@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include "gen-compat.h"
char *
freebsd11_devname(uint32_t dev, mode_t type)
{
return (devname(dev, type));
}
char *
freebsd11_devname_r(uint32_t dev, mode_t type, char *buf, int len)
{
return (devname_r(dev, type, buf, len));
}
__sym_compat(devname, freebsd11_devname, FBSD_1.0);
__sym_compat(devname_r, freebsd11_devname_r, FBSD_1.0);

View File

@ -40,15 +40,19 @@ __FBSDID("$FreeBSD$");
#include "namespace.h" #include "namespace.h"
#include <sys/param.h> #include <sys/param.h>
#define _WANT_FREEBSD11_STATFS
#include <sys/mount.h> #include <sys/mount.h>
#define _WANT_FREEBSD11_STAT
#include <sys/stat.h> #include <sys/stat.h>
#define _WANT_FREEBSD11_DIRENT
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "gen-compat.h"
#include "fts-compat.h" #include "fts-compat.h"
#include "un-namespace.h" #include "un-namespace.h"
@ -96,8 +100,8 @@ static int fts_ufslinks(FTS *, const FTSENT *);
*/ */
struct _fts_private { struct _fts_private {
FTS ftsp_fts; FTS ftsp_fts;
struct statfs ftsp_statfs; struct freebsd11_statfs ftsp_statfs;
dev_t ftsp_dev; uint32_t ftsp_dev;
int ftsp_linksreliable; int ftsp_linksreliable;
}; };
@ -626,7 +630,7 @@ __fts_set_clientptr_44bsd(FTS *sp, void *clientptr)
static FTSENT * static FTSENT *
fts_build(FTS *sp, int type) fts_build(FTS *sp, int type)
{ {
struct dirent *dp; struct freebsd11_dirent *dp;
FTSENT *p, *head; FTSENT *p, *head;
int nitems; int nitems;
FTSENT *cur, *tail; FTSENT *cur, *tail;
@ -738,7 +742,8 @@ fts_build(FTS *sp, int type)
/* Read the directory, attaching each entry to the `link' pointer. */ /* Read the directory, attaching each entry to the `link' pointer. */
doadjust = 0; doadjust = 0;
for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) { for (head = tail = NULL, nitems = 0;
dirp && (dp = freebsd11_readdir(dirp));) {
dnamlen = dp->d_namlen; dnamlen = dp->d_namlen;
if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
continue; continue;
@ -891,9 +896,9 @@ static u_short
fts_stat(FTS *sp, FTSENT *p, int follow) fts_stat(FTS *sp, FTSENT *p, int follow)
{ {
FTSENT *t; FTSENT *t;
dev_t dev; uint32_t dev;
ino_t ino; uint32_t ino;
struct stat *sbp, sb; struct freebsd11_stat *sbp, sb;
int saved_errno; int saved_errno;
/* If user needs stat info, stat buffer already allocated. */ /* If user needs stat info, stat buffer already allocated. */
@ -916,16 +921,16 @@ fts_stat(FTS *sp, FTSENT *p, int follow)
* fail, set the errno from the stat call. * fail, set the errno from the stat call.
*/ */
if (ISSET(FTS_LOGICAL) || follow) { if (ISSET(FTS_LOGICAL) || follow) {
if (stat(p->fts_accpath, sbp)) { if (freebsd11_stat(p->fts_accpath, sbp)) {
saved_errno = errno; saved_errno = errno;
if (!lstat(p->fts_accpath, sbp)) { if (!freebsd11_lstat(p->fts_accpath, sbp)) {
errno = 0; errno = 0;
return (FTS_SLNONE); return (FTS_SLNONE);
} }
p->fts_errno = saved_errno; p->fts_errno = saved_errno;
goto err; goto err;
} }
} else if (lstat(p->fts_accpath, sbp)) { } else if (freebsd11_lstat(p->fts_accpath, sbp)) {
p->fts_errno = errno; p->fts_errno = errno;
err: memset(sbp, 0, sizeof(struct stat)); err: memset(sbp, 0, sizeof(struct stat));
return (FTS_NS); return (FTS_NS);
@ -1019,7 +1024,7 @@ fts_alloc(FTS *sp, char *name, int namelen)
struct ftsent_withstat { struct ftsent_withstat {
FTSENT ent; FTSENT ent;
struct stat statbuf; struct freebsd11_stat statbuf;
}; };
/* /*
@ -1145,14 +1150,14 @@ static int
fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path) fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
{ {
int ret, oerrno, newfd; int ret, oerrno, newfd;
struct stat sb; struct freebsd11_stat sb;
newfd = fd; newfd = fd;
if (ISSET(FTS_NOCHDIR)) if (ISSET(FTS_NOCHDIR))
return (0); return (0);
if (fd < 0 && (newfd = _open(path, O_RDONLY | O_CLOEXEC, 0)) < 0) if (fd < 0 && (newfd = _open(path, O_RDONLY | O_CLOEXEC, 0)) < 0)
return (-1); return (-1);
if (_fstat(newfd, &sb)) { if (freebsd11_fstat(newfd, &sb)) {
ret = -1; ret = -1;
goto bail; goto bail;
} }
@ -1187,7 +1192,7 @@ fts_ufslinks(FTS *sp, const FTSENT *ent)
* avoidance. * avoidance.
*/ */
if (priv->ftsp_dev != ent->fts_dev) { if (priv->ftsp_dev != ent->fts_dev) {
if (statfs(ent->fts_path, &priv->ftsp_statfs) != -1) { if (freebsd11_statfs(ent->fts_path, &priv->ftsp_statfs) != -1) {
priv->ftsp_dev = ent->fts_dev; priv->ftsp_dev = ent->fts_dev;
priv->ftsp_linksreliable = 0; priv->ftsp_linksreliable = 0;
for (cpp = ufslike_filesystems; *cpp; cpp++) { for (cpp = ufslike_filesystems; *cpp; cpp++) {

View File

@ -37,7 +37,7 @@ typedef struct {
struct _ftsent *fts_cur; /* current node */ struct _ftsent *fts_cur; /* current node */
struct _ftsent *fts_child; /* linked list of children */ struct _ftsent *fts_child; /* linked list of children */
struct _ftsent **fts_array; /* sort array */ struct _ftsent **fts_array; /* sort array */
dev_t fts_dev; /* starting device # */ uint32_t fts_dev; /* starting device # */
char *fts_path; /* path for this descent */ char *fts_path; /* path for this descent */
int fts_rfd; /* fd for root */ int fts_rfd; /* fd for root */
int fts_pathlen; /* sizeof(path) */ int fts_pathlen; /* sizeof(path) */
@ -82,9 +82,9 @@ typedef struct _ftsent {
u_short fts_pathlen; /* strlen(fts_path) */ u_short fts_pathlen; /* strlen(fts_path) */
u_short fts_namelen; /* strlen(fts_name) */ u_short fts_namelen; /* strlen(fts_name) */
ino_t fts_ino; /* inode */ uint32_t fts_ino; /* inode */
dev_t fts_dev; /* device */ uint32_t fts_dev; /* device */
nlink_t fts_nlink; /* link count */ uint16_t fts_nlink; /* link count */
#define FTS_ROOTPARENTLEVEL -1 #define FTS_ROOTPARENTLEVEL -1
#define FTS_ROOTLEVEL 0 #define FTS_ROOTLEVEL 0
@ -117,7 +117,7 @@ typedef struct _ftsent {
#define FTS_SKIP 4 /* discard node */ #define FTS_SKIP 4 /* discard node */
u_short fts_instr; /* fts_set() instructions */ u_short fts_instr; /* fts_set() instructions */
struct stat *fts_statp; /* stat(2) information */ struct freebsd11_stat *fts_statp; /* stat(2) information */
char *fts_name; /* file name */ char *fts_name; /* file name */
FTS *fts_fts; /* back pointer to main FTS */ FTS *fts_fts; /* back pointer to main FTS */
} FTSENT; } FTSENT;

1199
lib/libc/gen/fts-compat11.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fts.h 8.3 (Berkeley) 8/14/94
* $FreeBSD$
*/
#ifndef _FTS_COPMAT11_H_
#define _FTS_COPMAT11_H_
typedef struct {
struct _ftsent11 *fts_cur; /* current node */
struct _ftsent11 *fts_child; /* linked list of children */
struct _ftsent11 **fts_array; /* sort array */
uint32_t fts_dev; /* starting device # */
char *fts_path; /* path for this descent */
int fts_rfd; /* fd for root */
__size_t fts_pathlen; /* sizeof(path) */
__size_t fts_nitems; /* elements in the sort array */
int (*fts_compar) /* compare function */
(const struct _ftsent11 * const *,
const struct _ftsent11 * const *);
int fts_options; /* fts_open options, global flags */
void *fts_clientptr; /* thunk for sort function */
} FTS11;
typedef struct _ftsent11 {
struct _ftsent11 *fts_cycle; /* cycle node */
struct _ftsent11 *fts_parent; /* parent directory */
struct _ftsent11 *fts_link; /* next file in directory */
long long fts_number; /* local numeric value */
void *fts_pointer; /* local address value */
char *fts_accpath; /* access path */
char *fts_path; /* root path */
int fts_errno; /* errno for this node */
int fts_symfd; /* fd for symlink */
__size_t fts_pathlen; /* strlen(fts_path) */
__size_t fts_namelen; /* strlen(fts_name) */
uint32_t fts_ino; /* inode */
uint32_t fts_dev; /* device */
uint16_t fts_nlink; /* link count */
long fts_level; /* depth (-1 to N) */
int fts_info; /* user status for FTSENT structure */
unsigned fts_flags; /* private flags for FTSENT structure */
int fts_instr; /* fts_set() instructions */
struct freebsd11_stat *fts_statp; /* stat(2) information */
char *fts_name; /* file name */
FTS11 *fts_fts; /* back pointer to main FTS */
} FTSENT11;
FTSENT11 *freebsd11_fts_children(FTS11 *, int);
int freebsd11_fts_close(FTS11 *);
void *freebsd11_fts_get_clientptr(FTS11 *);
#define freebsd11_fts_get_clientptr(fts) ((fts)->fts_clientptr)
FTS11 *freebsd11_fts_get_stream(FTSENT11 *);
#define freebsd11_fts_get_stream(ftsent) ((ftsent)->fts_fts)
FTS11 *freebsd11_fts_open(char * const *, int,
int (*)(const FTSENT11 * const *,
const FTSENT11 * const *));
FTSENT11 *freebsd11_fts_read(FTS11 *);
int freebsd11_fts_set(FTS11 *, FTSENT11 *, int);
void freebsd11_fts_set_clientptr(FTS11 *, void *);
#endif /* !_FTS_COMPAT11_H_ */

View File

@ -0,0 +1,98 @@
/* $OpenBSD: ftw.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */
/*
* Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*
* from: $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fts.h>
#include <ftw.h>
#include "fts-compat11.h"
int
freebsd11_ftw(const char *path,
int (*fn)(const char *, const struct freebsd11_stat *, int), int nfds)
{
char * const paths[2] = { (char *)path, NULL };
FTSENT11 *cur;
FTS11 *ftsp;
int error = 0, fnflag, sverrno;
/* XXX - nfds is currently unused */
if (nfds < 1) {
errno = EINVAL;
return (-1);
}
ftsp = freebsd11_fts_open(paths,
FTS_LOGICAL | FTS_COMFOLLOW | FTS_NOCHDIR, NULL);
if (ftsp == NULL)
return (-1);
while ((cur = freebsd11_fts_read(ftsp)) != NULL) {
switch (cur->fts_info) {
case FTS_D:
fnflag = FTW_D;
break;
case FTS_DNR:
fnflag = FTW_DNR;
break;
case FTS_DP:
/* we only visit in preorder */
continue;
case FTS_F:
case FTS_DEFAULT:
fnflag = FTW_F;
break;
case FTS_NS:
case FTS_NSOK:
case FTS_SLNONE:
fnflag = FTW_NS;
break;
case FTS_SL:
fnflag = FTW_SL;
break;
case FTS_DC:
errno = ELOOP;
/* FALLTHROUGH */
default:
error = -1;
goto done;
}
error = fn(cur->fts_path, cur->fts_statp, fnflag);
if (error != 0)
break;
}
done:
sverrno = errno;
if (freebsd11_fts_close(ftsp) != 0 && error == 0)
error = -1;
else
errno = sverrno;
return (error);
}
__sym_compat(ftw, freebsd11_ftw, FBSD_1.0);

57
lib/libc/gen/gen-compat.h Normal file
View File

@ -0,0 +1,57 @@
/*-
* Copyright (c) 2012 Gleb Kurtsou <gleb@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _GEN_COMPAT_H_
#define _GEN_COMPAT_H_
#include <dirent.h>
#define FREEBSD11_DIRSIZ(dp) \
(sizeof(struct freebsd11_dirent) - sizeof((dp)->d_name) + \
(((dp)->d_namlen + 1 + 3) &~ 3))
struct freebsd11_dirent;
struct freebsd11_stat;
struct freebsd11_statfs;
struct freebsd11_dirent *freebsd11_readdir(DIR *);
int freebsd11_readdir_r(DIR *, struct freebsd11_dirent *,
struct freebsd11_dirent **);
int freebsd11_stat(const char *, struct freebsd11_stat *);
int freebsd11_lstat(const char *, struct freebsd11_stat *);
int freebsd11_fstat(int, struct freebsd11_stat *);
int freebsd11_fstatat(int, const char *, struct freebsd11_stat *, int);
int freebsd11_statfs(const char *, struct freebsd11_statfs *);
int freebsd11_getfsstat(struct freebsd11_statfs *, long, int);
int freebsd11_getmntinfo(struct freebsd11_statfs **, int);
char *freebsd11_devname(__uint32_t dev, __mode_t type);
char *freebsd11_devname_r(__uint32_t dev, __mode_t type, char *buf, int len);
#endif /* _GEN_COMPAT_H_ */

View File

@ -47,12 +47,16 @@ struct _dirdesc {
long dd_size; /* amount of data returned by getdirentries */ long dd_size; /* amount of data returned by getdirentries */
char *dd_buf; /* data buffer */ char *dd_buf; /* data buffer */
int dd_len; /* size of data buffer */ int dd_len; /* size of data buffer */
long dd_seek; /* magic cookie returned by getdirentries */ off_t dd_seek; /* magic cookie returned by getdirentries */
int dd_flags; /* flags for readdir */ int dd_flags; /* flags for readdir */
struct pthread_mutex *dd_lock; /* lock */ struct pthread_mutex *dd_lock; /* lock */
struct _telldir *dd_td; /* telldir position recording */ struct _telldir *dd_td; /* telldir position recording */
void *dd_compat_de; /* compat dirent */
}; };
#define _dirfd(dirp) ((dirp)->dd_fd) #define _dirfd(dirp) ((dirp)->dd_fd)
struct dirent;
int __readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
#endif /* !_GEN_PRIVATE_H_ */ #endif /* !_GEN_PRIVATE_H_ */

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/ucred.h>
#define _WANT_FREEBSD11_STATFS
#include <sys/mount.h>
#include <stdlib.h>
#include "gen-compat.h"
/*
* Return information about mounted filesystems.
*/
int
freebsd11_getmntinfo(struct freebsd11_statfs **mntbufp, int flags)
{
static struct freebsd11_statfs *mntbuf;
static int mntsize;
static long bufsize;
if (mntsize <= 0 &&
(mntsize = freebsd11_getfsstat(0, 0, MNT_NOWAIT)) < 0)
return (0);
if (bufsize > 0 &&
(mntsize = freebsd11_getfsstat(mntbuf, bufsize, flags)) < 0)
return (0);
while (bufsize <= mntsize * sizeof(struct freebsd11_statfs)) {
if (mntbuf)
free(mntbuf);
bufsize = (mntsize + 1) * sizeof(struct freebsd11_statfs);
if ((mntbuf = (struct freebsd11_statfs *)malloc(bufsize)) == 0)
return (0);
if ((mntsize = freebsd11_getfsstat(mntbuf, bufsize, flags)) < 0)
return (0);
}
*mntbufp = mntbuf;
return (mntsize);
}
__sym_compat(getmntinfo, freebsd11_getmntinfo, FBSD_1.0);

1093
lib/libc/gen/glob-compat11.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Guido van Rossum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)glob.h 8.1 (Berkeley) 6/2/93
* from: $FreeBSD$
* $FreeBSD$
*/
#ifndef _GLOB_COMPAT11_H_
#define _GLOB_COMPAT11_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <glob.h>
struct freebsd11_stat;
typedef struct {
size_t gl_pathc; /* Count of total paths so far. */
size_t gl_matchc; /* Count of paths matching pattern. */
size_t gl_offs; /* Reserved at beginning of gl_pathv. */
int gl_flags; /* Copy of flags parameter to glob. */
char **gl_pathv; /* List of paths matching pattern. */
/* Copy of errfunc parameter to glob. */
int (*gl_errfunc)(const char *, int);
/*
* Alternate filesystem access methods for glob; replacement
* versions of closedir(3), readdir(3), opendir(3), stat(2)
* and lstat(2).
*/
void (*gl_closedir)(void *);
struct freebsd11_dirent *(*gl_readdir)(void *);
void *(*gl_opendir)(const char *);
int (*gl_lstat)(const char *, struct freebsd11_stat *);
int (*gl_stat)(const char *, struct freebsd11_stat *);
} glob11_t;
__BEGIN_DECLS
int freebsd11_glob(const char * __restrict, int,
int (*)(const char *, int), glob11_t * __restrict);
void freebsd11_globfree(glob11_t *);
__END_DECLS
#endif /* !_GLOB_COMPAT11_H_ */

View File

@ -0,0 +1,115 @@
/*
* Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Sponsored in part by the Defense Advanced Research Projects
* Agency (DARPA) and Air Force Research Laboratory, Air Force
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*
* from: $OpenBSD: nftw.c,v 1.7 2006/03/31 19:41:44 millert Exp $
* from: $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fts.h>
#include <ftw.h>
#include "fts-compat11.h"
int
freebsd11_nftw(const char *path,
int (*fn)(const char *, const struct freebsd11_stat *, int, struct FTW *),
int nfds, int ftwflags)
{
char * const paths[2] = { (char *)path, NULL };
struct FTW ftw;
FTSENT11 *cur;
FTS11 *ftsp;
int error = 0, ftsflags, fnflag, postorder, sverrno;
/* XXX - nfds is currently unused */
if (nfds < 1) {
errno = EINVAL;
return (-1);
}
ftsflags = FTS_COMFOLLOW;
if (!(ftwflags & FTW_CHDIR))
ftsflags |= FTS_NOCHDIR;
if (ftwflags & FTW_MOUNT)
ftsflags |= FTS_XDEV;
if (ftwflags & FTW_PHYS)
ftsflags |= FTS_PHYSICAL;
else
ftsflags |= FTS_LOGICAL;
postorder = (ftwflags & FTW_DEPTH) != 0;
ftsp = freebsd11_fts_open(paths, ftsflags, NULL);
if (ftsp == NULL)
return (-1);
while ((cur = freebsd11_fts_read(ftsp)) != NULL) {
switch (cur->fts_info) {
case FTS_D:
if (postorder)
continue;
fnflag = FTW_D;
break;
case FTS_DC:
continue;
case FTS_DNR:
fnflag = FTW_DNR;
break;
case FTS_DP:
if (!postorder)
continue;
fnflag = FTW_DP;
break;
case FTS_F:
case FTS_DEFAULT:
fnflag = FTW_F;
break;
case FTS_NS:
case FTS_NSOK:
fnflag = FTW_NS;
break;
case FTS_SL:
fnflag = FTW_SL;
break;
case FTS_SLNONE:
fnflag = FTW_SLN;
break;
default:
error = -1;
goto done;
}
ftw.base = cur->fts_pathlen - cur->fts_namelen;
ftw.level = cur->fts_level;
error = fn(cur->fts_path, cur->fts_statp, fnflag, &ftw);
if (error != 0)
break;
}
done:
sverrno = errno;
if (freebsd11_fts_close(ftsp) != 0 && error == 0)
error = -1;
else
errno = sverrno;
return (error);
}
__sym_compat(nftw, freebsd11_nftw, FBSD_1.0);

View File

@ -296,6 +296,7 @@ __opendir_common(int fd, int flags, bool use_current_pos)
dirp->dd_td = (struct _telldir *)((char *)dirp + sizeof(DIR)); dirp->dd_td = (struct _telldir *)((char *)dirp + sizeof(DIR));
LIST_INIT(&dirp->dd_td->td_locq); LIST_INIT(&dirp->dd_td->td_locq);
dirp->dd_td->td_loccnt = 0; dirp->dd_td->td_loccnt = 0;
dirp->dd_compat_de = NULL;
/* /*
* Use the system page size if that is a multiple of DIRBLKSIZ. * Use the system page size if that is a multiple of DIRBLKSIZ.

View File

@ -0,0 +1,120 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from:
* $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/param.h>
#define _WANT_FREEBSD11_DIRENT
#include <dirent.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "un-namespace.h"
#include "libc_private.h"
#include "gen-private.h"
#include "telldir.h"
#include "gen-compat.h"
static bool
freebsd11_cvtdirent(struct freebsd11_dirent *dstdp, struct dirent *srcdp)
{
if (srcdp->d_namlen >= sizeof(dstdp->d_name))
return (false);
dstdp->d_type = srcdp->d_type;
dstdp->d_namlen = srcdp->d_namlen;
dstdp->d_fileno = srcdp->d_fileno; /* truncate */
dstdp->d_reclen = FREEBSD11_DIRSIZ(dstdp);
bcopy(srcdp->d_name, dstdp->d_name, dstdp->d_namlen);
bzero(dstdp->d_name + dstdp->d_namlen,
dstdp->d_reclen - offsetof(struct freebsd11_dirent, d_name) -
dstdp->d_namlen);
return (true);
}
struct freebsd11_dirent *
freebsd11_readdir(DIR *dirp)
{
struct freebsd11_dirent *dstdp;
struct dirent *dp;
if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock);
dp = _readdir_unlocked(dirp, RDU_SKIP);
if (dp != NULL) {
if (dirp->dd_compat_de == NULL)
dirp->dd_compat_de = malloc(sizeof(struct
freebsd11_dirent));
if (freebsd11_cvtdirent(dirp->dd_compat_de, dp))
dstdp = dirp->dd_compat_de;
else
dstdp = NULL;
} else
dstdp = NULL;
if (__isthreaded)
_pthread_mutex_unlock(&dirp->dd_lock);
return (dstdp);
}
int
freebsd11_readdir_r(DIR *dirp, struct freebsd11_dirent *entry,
struct freebsd11_dirent **result)
{
struct dirent xentry, *xresult;
int error;
error = __readdir_r(dirp, &xentry, &xresult);
if (error != 0)
return (error);
if (xresult != NULL) {
if (freebsd11_cvtdirent(entry, &xentry))
*result = entry;
else /* should not happen due to RDU_SHORT */
*result = NULL;
} else
*result = NULL;
return (0);
}
__sym_compat(readdir, freebsd11_readdir, FBSD_1.0);
__sym_compat(readdir_r, freebsd11_readdir_r, FBSD_1.0);

View File

@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
* get next entry in a directory. * get next entry in a directory.
*/ */
struct dirent * struct dirent *
_readdir_unlocked(DIR *dirp, int skip) _readdir_unlocked(DIR *dirp, int flags)
{ {
struct dirent *dp; struct dirent *dp;
long initial_seek; long initial_seek;
@ -80,10 +80,13 @@ _readdir_unlocked(DIR *dirp, int skip)
dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc)
return (NULL); return (NULL);
dirp->dd_loc += dp->d_reclen; dirp->dd_loc += dp->d_reclen;
if (dp->d_ino == 0 && skip) if (dp->d_ino == 0 && (flags & RDU_SKIP) != 0)
continue; continue;
if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW)) if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW))
continue; continue;
if (dp->d_namlen >= sizeof(dp->d_name) &&
(flags & RDU_SHORT) != 0)
continue;
return (dp); return (dp);
} }
} }
@ -91,34 +94,31 @@ _readdir_unlocked(DIR *dirp, int skip)
struct dirent * struct dirent *
readdir(DIR *dirp) readdir(DIR *dirp)
{ {
struct dirent *dp; struct dirent *dp;
if (__isthreaded) { if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock); _pthread_mutex_lock(&dirp->dd_lock);
dp = _readdir_unlocked(dirp, 1); dp = _readdir_unlocked(dirp, RDU_SKIP);
if (__isthreaded)
_pthread_mutex_unlock(&dirp->dd_lock); _pthread_mutex_unlock(&dirp->dd_lock);
}
else
dp = _readdir_unlocked(dirp, 1);
return (dp); return (dp);
} }
int int
readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) __readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
{ {
struct dirent *dp; struct dirent *dp;
int saved_errno; int saved_errno;
saved_errno = errno; saved_errno = errno;
errno = 0; errno = 0;
if (__isthreaded) { if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock); _pthread_mutex_lock(&dirp->dd_lock);
if ((dp = _readdir_unlocked(dirp, 1)) != NULL) dp = _readdir_unlocked(dirp, RDU_SKIP | RDU_SHORT);
memcpy(entry, dp, _GENERIC_DIRSIZ(dp)); if (dp != NULL)
_pthread_mutex_unlock(&dirp->dd_lock);
}
else if ((dp = _readdir_unlocked(dirp, 1)) != NULL)
memcpy(entry, dp, _GENERIC_DIRSIZ(dp)); memcpy(entry, dp, _GENERIC_DIRSIZ(dp));
if (__isthreaded)
_pthread_mutex_unlock(&dirp->dd_lock);
if (errno != 0) { if (errno != 0) {
if (dp == NULL) if (dp == NULL)
@ -133,3 +133,5 @@ readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
return (0); return (0);
} }
__strong_reference(__readdir_r, readdir_r);

View File

@ -0,0 +1,174 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from:
* $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* Scan the directory dirname calling select to make a list of selected
* directory entries then sort using qsort and compare routine dcomp.
* Returns the number of entries and a pointer to a list of pointers to
* struct dirent (through namelist). Returns -1 if there were any errors.
*/
#include "namespace.h"
#define _WANT_FREEBSD11_DIRENT
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include "un-namespace.h"
#include "gen-compat.h"
#ifdef I_AM_SCANDIR_B
#include "block_abi.h"
#define SELECT(x) CALL_BLOCK(select, x)
#ifndef __BLOCKS__
void
qsort_b(void *, size_t, size_t, void*);
#endif
#else
#define SELECT(x) select(x)
#endif
static int freebsd11_alphasort_thunk(void *thunk, const void *p1,
const void *p2);
int
#ifdef I_AM_SCANDIR_B
freebsd11_scandir_b(const char *dirname, struct freebsd11_dirent ***namelist,
DECLARE_BLOCK(int, select, const struct freebsd11_dirent *),
DECLARE_BLOCK(int, dcomp, const struct freebsd11_dirent **,
const struct freebsd11_dirent **))
#else
freebsd11_scandir(const char *dirname, struct freebsd11_dirent ***namelist,
int (*select)(const struct freebsd11_dirent *),
int (*dcomp)(const struct freebsd11_dirent **,
const struct freebsd11_dirent **))
#endif
{
struct freebsd11_dirent *d, *p, **names = NULL;
size_t arraysz, numitems;
DIR *dirp;
if ((dirp = opendir(dirname)) == NULL)
return(-1);
numitems = 0;
arraysz = 32; /* initial estimate of the array size */
names = (struct freebsd11_dirent **)malloc(
arraysz * sizeof(struct freebsd11_dirent *));
if (names == NULL)
goto fail;
while ((d = freebsd11_readdir(dirp)) != NULL) {
if (select != NULL && !SELECT(d))
continue; /* just selected names */
/*
* Make a minimum size copy of the data
*/
p = (struct freebsd11_dirent *)malloc(FREEBSD11_DIRSIZ(d));
if (p == NULL)
goto fail;
p->d_fileno = d->d_fileno;
p->d_type = d->d_type;
p->d_reclen = d->d_reclen;
p->d_namlen = d->d_namlen;
bcopy(d->d_name, p->d_name, p->d_namlen + 1);
/*
* Check to make sure the array has space left and
* realloc the maximum size.
*/
if (numitems >= arraysz) {
struct freebsd11_dirent **names2;
names2 = reallocarray(names, arraysz,
2 * sizeof(struct freebsd11_dirent *));
if (names2 == NULL) {
free(p);
goto fail;
}
names = names2;
arraysz *= 2;
}
names[numitems++] = p;
}
closedir(dirp);
if (numitems && dcomp != NULL)
#ifdef I_AM_SCANDIR_B
qsort_b(names, numitems, sizeof(struct freebsd11_dirent *),
(void*)dcomp);
#else
qsort_r(names, numitems, sizeof(struct freebsd11_dirent *),
&dcomp, freebsd11_alphasort_thunk);
#endif
*namelist = names;
return (numitems);
fail:
while (numitems > 0)
free(names[--numitems]);
free(names);
closedir(dirp);
return (-1);
}
/*
* Alphabetic order comparison routine for those who want it.
* POSIX 2008 requires that alphasort() uses strcoll().
*/
int
freebsd11_alphasort(const struct freebsd11_dirent **d1,
const struct freebsd11_dirent **d2)
{
return (strcoll((*d1)->d_name, (*d2)->d_name));
}
static int
freebsd11_alphasort_thunk(void *thunk, const void *p1, const void *p2)
{
int (*dc)(const struct freebsd11_dirent **, const struct
freebsd11_dirent **);
dc = *(int (**)(const struct freebsd11_dirent **,
const struct freebsd11_dirent **))thunk;
return (dc((const struct freebsd11_dirent **)p1,
(const struct freebsd11_dirent **)p2));
}
__sym_compat(alphasort, freebsd11_alphasort, FBSD_1.0);
__sym_compat(scandir, freebsd11_scandir, FBSD_1.0);
__sym_compat(scandir_b, freebsd11_scandir_b, FBSD_1.4);

View File

@ -59,17 +59,6 @@ qsort_b(void *, size_t, size_t, void*);
static int alphasort_thunk(void *thunk, const void *p1, const void *p2); static int alphasort_thunk(void *thunk, const void *p1, const void *p2);
/*
* The DIRSIZ macro is the minimum record length which will hold the directory
* entry. This requires the amount of space in struct dirent without the
* d_name field, plus enough space for the name and a terminating nul byte
* (dp->d_namlen + 1), rounded up to a 4 byte boundary.
*/
#undef DIRSIZ
#define DIRSIZ(dp) \
((sizeof(struct dirent) - sizeof(dp)->d_name) + \
(((dp)->d_namlen + 1 + 3) &~ 3))
int int
#ifdef I_AM_SCANDIR_B #ifdef I_AM_SCANDIR_B
scandir_b(const char *dirname, struct dirent ***namelist, scandir_b(const char *dirname, struct dirent ***namelist,
@ -100,7 +89,7 @@ scandir(const char *dirname, struct dirent ***namelist,
/* /*
* Make a minimum size copy of the data * Make a minimum size copy of the data
*/ */
p = (struct dirent *)malloc(DIRSIZ(d)); p = (struct dirent *)malloc(_GENERIC_DIRSIZ(d));
if (p == NULL) if (p == NULL)
goto fail; goto fail;
p->d_fileno = d->d_fileno; p->d_fileno = d->d_fileno;

View File

@ -47,7 +47,7 @@
struct ddloc { struct ddloc {
LIST_ENTRY(ddloc) loc_lqe; /* entry in list */ LIST_ENTRY(ddloc) loc_lqe; /* entry in list */
long loc_index; /* key associated with structure */ long loc_index; /* key associated with structure */
long loc_seek; /* magic cookie returned by getdirentries */ off_t loc_seek; /* magic cookie returned by getdirentries */
long loc_loc; /* offset of entry in buffer */ long loc_loc; /* offset of entry in buffer */
}; };
@ -66,4 +66,7 @@ void _reclaim_telldir(DIR *);
void _seekdir(DIR *, long); void _seekdir(DIR *, long);
void _fixtelldir(DIR *dirp, long oldseek, long oldloc); void _fixtelldir(DIR *dirp, long oldseek, long oldloc);
#define RDU_SKIP 0x0001
#define RDU_SHORT 0x0002
#endif #endif

View File

@ -44,6 +44,27 @@ __sym_compat(msgctl, freebsd7_msgctl, FBSD_1.0);
__sym_compat(shmctl, freebsd7_shmctl, FBSD_1.0); __sym_compat(shmctl, freebsd7_shmctl, FBSD_1.0);
#endif #endif
__sym_compat(nfstat, freebsd11_nfstat, FBSD_1.0);
__sym_compat(nlstat, freebsd11_nlstat, FBSD_1.0);
__sym_compat(nstat, freebsd11_nstat, FBSD_1.0);
__sym_compat(fhstat, freebsd11_fhstat, FBSD_1.0);
__sym_compat(fstat, freebsd11_fstat, FBSD_1.0);
__sym_compat(fstatat, freebsd11_fstatat, FBSD_1.1);
__sym_compat(lstat, freebsd11_lstat, FBSD_1.0);
__sym_compat(stat, freebsd11_stat, FBSD_1.0);
__sym_compat(getdents, freebsd11_getdents, FBSD_1.0);
__sym_compat(getdirentries, freebsd11_getdirentries, FBSD_1.0);
__sym_compat(getfsstat, freebsd11_getfsstat, FBSD_1.0);
__sym_compat(fhstatfs, freebsd11_fhstatfs, FBSD_1.0);
__sym_compat(fstatfs, freebsd11_fstatfs, FBSD_1.0);
__sym_compat(statfs, freebsd11_statfs, FBSD_1.0);
__sym_compat(mknod, freebsd11_mknod, FBSD_1.0);
__sym_compat(mknodat, freebsd11_mknodat, FBSD_1.1);
#undef __sym_compat #undef __sym_compat
#define __weak_reference(sym,alias) \ #define __weak_reference(sym,alias) \

View File

@ -307,6 +307,7 @@ struct pollfd;
struct rusage; struct rusage;
struct sigaction; struct sigaction;
struct sockaddr; struct sockaddr;
struct stat;
struct timespec; struct timespec;
struct timeval; struct timeval;
struct timezone; struct timezone;
@ -323,8 +324,10 @@ int __sys_clock_nanosleep(__clockid_t, int,
const struct timespec *, struct timespec *); const struct timespec *, struct timespec *);
int __sys_close(int); int __sys_close(int);
int __sys_connect(int, const struct sockaddr *, __socklen_t); int __sys_connect(int, const struct sockaddr *, __socklen_t);
__ssize_t __sys_getdirentries(int, char *, __size_t, __off_t *);
int __sys_fcntl(int, int, ...); int __sys_fcntl(int, int, ...);
int __sys_fdatasync(int); int __sys_fdatasync(int);
int __sys_fstatat(int, const char *, struct stat *, int);
int __sys_fsync(int); int __sys_fsync(int);
__pid_t __sys_fork(void); __pid_t __sys_fork(void);
int __sys_ftruncate(int, __off_t); int __sys_ftruncate(int, __off_t);

View File

@ -35,6 +35,8 @@ SRCS+= \
__error.c \ __error.c \
interposing_table.c interposing_table.c
SRCS+= getdents.c lstat.c mknod.c stat.c
SRCS+= futimens.c utimensat.c SRCS+= futimens.c utimensat.c
NOASM+= futimens.o utimensat.o NOASM+= futimens.o utimensat.o
PSEUDO+= _futimens.o _utimensat.o PSEUDO+= _futimens.o _utimensat.o

View File

@ -85,26 +85,19 @@ FBSD_1.0 {
fchown; fchown;
fcntl; fcntl;
fhopen; fhopen;
fhstat;
fhstatfs;
flock; flock;
fork; fork;
fpathconf; fpathconf;
fstat;
fstatfs;
fsync; fsync;
futimes; futimes;
getaudit; getaudit;
getaudit_addr; getaudit_addr;
getauid; getauid;
getcontext; getcontext;
getdents;
getdirentries;
getdtablesize; getdtablesize;
getegid; getegid;
geteuid; geteuid;
getfh; getfh;
getfsstat;
getgid; getgid;
getgroups; getgroups;
getitimer; getitimer;
@ -163,7 +156,6 @@ FBSD_1.0 {
link; link;
lio_listio; lio_listio;
listen; listen;
lstat;
lutimes; lutimes;
mac_syscall; mac_syscall;
madvise; madvise;
@ -171,7 +163,6 @@ FBSD_1.0 {
minherit; minherit;
mkdir; mkdir;
mkfifo; mkfifo;
mknod;
mlock; mlock;
mlockall; mlockall;
modfind; modfind;
@ -192,10 +183,7 @@ FBSD_1.0 {
netbsd_lchown; netbsd_lchown;
netbsd_msync; netbsd_msync;
nfssvc; nfssvc;
nfstat;
nlstat;
nmount; nmount;
nstat;
ntp_adjtime; ntp_adjtime;
ntp_gettime; ntp_gettime;
open; open;
@ -275,8 +263,6 @@ FBSD_1.0 {
sigwaitinfo; sigwaitinfo;
socket; socket;
socketpair; socketpair;
stat;
statfs;
swapoff; swapoff;
swapon; swapon;
symlink; symlink;
@ -330,7 +316,6 @@ FBSD_1.1 {
fchmodat; fchmodat;
fchownat; fchownat;
fexecve; fexecve;
fstatat;
futimesat; futimesat;
jail_get; jail_get;
jail_set; jail_set;
@ -339,7 +324,6 @@ FBSD_1.1 {
lpathconf; lpathconf;
mkdirat; mkdirat;
mkfifoat; mkfifoat;
mknodat;
msgctl; msgctl;
readlinkat; readlinkat;
renameat; renameat;
@ -401,6 +385,19 @@ FBSD_1.4 {
FBSD_1.5 { FBSD_1.5 {
clock_nanosleep; clock_nanosleep;
fdatasync; fdatasync;
fhstat;
fhstatfs;
fstat;
fstatat;
fstatfs;
getdents;
getdirentries;
getfsstat;
lstat;
mknod;
mknodat;
stat;
statfs;
}; };
FBSDprivate_1.0 { FBSDprivate_1.0 {
@ -606,8 +603,6 @@ FBSDprivate_1.0 {
__sys_getauid; __sys_getauid;
_getcontext; _getcontext;
__sys_getcontext; __sys_getcontext;
_getdents;
__sys_getdents;
_getdirentries; _getdirentries;
__sys_getdirentries; __sys_getdirentries;
_getdtablesize; _getdtablesize;
@ -736,8 +731,6 @@ FBSDprivate_1.0 {
__sys_lio_listio; __sys_lio_listio;
_listen; _listen;
__sys_listen; __sys_listen;
_lstat;
__sys_lstat;
_lutimes; _lutimes;
__sys_lutimes; __sys_lutimes;
_mac_syscall; _mac_syscall;
@ -796,14 +789,8 @@ FBSDprivate_1.0 {
__sys_netbsd_msync; __sys_netbsd_msync;
_nfssvc; _nfssvc;
__sys_nfssvc; __sys_nfssvc;
_nfstat;
__sys_nfstat;
_nlstat;
__sys_nlstat;
_nmount; _nmount;
__sys_nmount; __sys_nmount;
_nstat;
__sys_nstat;
_ntp_adjtime; _ntp_adjtime;
__sys_ntp_adjtime; __sys_ntp_adjtime;
_ntp_gettime; _ntp_gettime;
@ -971,8 +958,6 @@ FBSDprivate_1.0 {
__sys_socket; __sys_socket;
_socketpair; _socketpair;
__sys_socketpair; __sys_socketpair;
_stat;
__sys_stat;
_statfs; _statfs;
__sys_statfs; __sys_statfs;
_swapcontext; _swapcontext;

41
lib/libc/sys/getdents.c Normal file
View File

@ -0,0 +1,41 @@
/*-
* Copyright (c) 2012 Gleb Kurtsou <gleb@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/param.h>
#include <sys/syscall.h>
#include <dirent.h>
#include "libc_private.h"
ssize_t
getdents(int fd, char *buf, size_t nbytes)
{
return (__sys_getdirentries(fd, buf, nbytes, NULL));
}

View File

@ -40,10 +40,10 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.In sys/types.h .In sys/types.h
.In dirent.h .In dirent.h
.Ft int .Ft ssize_t
.Fn getdirentries "int fd" "char *buf" "int nbytes" "long *basep" .Fn getdirentries "int fd" "char *buf" "size_t nbytes" "off_t *basep"
.Ft int .Ft ssize_t
.Fn getdents "int fd" "char *buf" "int nbytes" .Fn getdents "int fd" "char *buf" "size_t nbytes"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Fn getdirentries .Fn getdirentries

43
lib/libc/sys/lstat.c Normal file
View File

@ -0,0 +1,43 @@
/*-
* Copyright (c) 2012 Gleb Kurtsou <gleb@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/param.h>
#include <sys/fcntl.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <unistd.h>
#include "libc_private.h"
int
lstat(const char *path, struct stat *sb)
{
return (__sys_fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
}

45
lib/libc/sys/mknod.c Normal file
View File

@ -0,0 +1,45 @@
/*-
* Copyright (c) 2011 Gleb Kurtsou <gleb@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/param.h>
#include <sys/fcntl.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <unistd.h>
#include "libc_private.h"
int __sys_mknodat(int, const char *, mode_t, dev_t);
int
mknod(const char *path, mode_t mode, dev_t dev)
{
return (__sys_mknodat(AT_FDCWD, path, mode, dev));
}

43
lib/libc/sys/stat.c Normal file
View File

@ -0,0 +1,43 @@
/*-
* Copyright (c) 2012 Gleb Kurtsou <gleb@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/param.h>
#include <sys/fcntl.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <unistd.h>
#include "libc_private.h"
int
stat(const char *path, struct stat *sb)
{
return (__sys_fstatat(AT_FDCWD, path, sb, 0));
}

View File

@ -28,7 +28,7 @@
.\" @(#)statfs.2 8.5 (Berkeley) 5/24/95 .\" @(#)statfs.2 8.5 (Berkeley) 5/24/95
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd November 1, 2006 .Dd February 13, 2017
.Dt STATFS 2 .Dt STATFS 2
.Os .Os
.Sh NAME .Sh NAME
@ -66,8 +66,8 @@ typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
*/ */
#define MFSNAMELEN 16 /* length of type name including null */ #define MFSNAMELEN 16 /* length of type name including null */
#define MNAMELEN 88 /* size of on/from name bufs */ #define MNAMELEN 1024 /* size of on/from name bufs */
#define STATFS_VERSION 0x20030518 /* current version number */ #define STATFS_VERSION 0x20140518 /* current version number */
struct statfs { struct statfs {
uint32_t f_version; /* structure version number */ uint32_t f_version; /* structure version number */

View File

@ -452,6 +452,7 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
} else { } else {
kp->ki_stat = SZOMB; kp->ki_stat = SZOMB;
} }
kp->ki_tdev_freebsd11 = kp->ki_tdev; /* truncate */
bcopy(&kinfo_proc, bp, sizeof(kinfo_proc)); bcopy(&kinfo_proc, bp, sizeof(kinfo_proc));
++bp; ++bp;
++cnt; ++cnt;

View File

@ -29,6 +29,7 @@ SRCS+= main.c engine.c listener.c handler.c comm.c monitor.c smfi.c \
CLEANFILES+=sm_os.h CLEANFILES+=sm_os.h
WARNS?= 0 WARNS?= 0
SHLIB_MAJOR= 6
sm_os.h: ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h .NOMETA sm_os.h: ${SENDMAIL_DIR}/include/sm/os/sm_os_freebsd.h .NOMETA
ln -sf ${.ALLSRC} ${.TARGET} ln -sf ${.ALLSRC} ${.TARGET}

View File

@ -13,6 +13,10 @@ SRCS= cd9660.c \
smbfs.c \ smbfs.c \
udf.c udf.c
.if ${MK_SYMVER} == yes
SRCS+= libprocstat_compat.c
.endif
VERSION_DEF= ${LIBCSRCDIR}/Versions.def VERSION_DEF= ${LIBCSRCDIR}/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map SYMBOL_MAPS= ${.CURDIR}/Symbol.map

View File

@ -6,9 +6,7 @@ FBSD_1.2 {
procstat_freefiles; procstat_freefiles;
procstat_freeprocs; procstat_freeprocs;
procstat_get_pipe_info; procstat_get_pipe_info;
procstat_get_pts_info;
procstat_get_socket_info; procstat_get_socket_info;
procstat_get_vnode_info;
procstat_getfiles; procstat_getfiles;
procstat_getprocs; procstat_getprocs;
procstat_open_kvm; procstat_open_kvm;
@ -22,8 +20,6 @@ FBSD_1.3 {
procstat_freegroups; procstat_freegroups;
procstat_freekstack; procstat_freekstack;
procstat_freevmmap; procstat_freevmmap;
procstat_get_sem_info;
procstat_get_shm_info;
procstat_getargv; procstat_getargv;
procstat_getauxv; procstat_getauxv;
procstat_getenvv; procstat_getenvv;
@ -40,4 +36,8 @@ FBSD_1.3 {
FBSD_1.5 { FBSD_1.5 {
procstat_freeptlwpinfo; procstat_freeptlwpinfo;
procstat_getptlwpinfo; procstat_getptlwpinfo;
procstat_get_pts_info;
procstat_get_sem_info;
procstat_get_shm_info;
procstat_get_vnode_info;
}; };

View File

@ -1337,12 +1337,12 @@ procstat_get_vnode_info_sysctl(struct filestat *fst, struct vnstat *vn,
struct statfs stbuf; struct statfs stbuf;
struct kinfo_file *kif; struct kinfo_file *kif;
struct kinfo_vmentry *kve; struct kinfo_vmentry *kve;
char *name, *path;
uint64_t fileid; uint64_t fileid;
uint64_t size; uint64_t size;
char *name, *path; uint64_t fsid;
uint32_t fsid; uint64_t rdev;
uint16_t mode; uint16_t mode;
uint32_t rdev;
int vntype; int vntype;
int status; int status;
@ -1545,8 +1545,10 @@ procstat_get_socket_info_sysctl(struct filestat *fst, struct sockstat *sock,
sock->dom_family = kif->kf_sock_domain; sock->dom_family = kif->kf_sock_domain;
sock->so_pcb = kif->kf_un.kf_sock.kf_sock_pcb; sock->so_pcb = kif->kf_un.kf_sock.kf_sock_pcb;
strlcpy(sock->dname, kif->kf_path, sizeof(sock->dname)); strlcpy(sock->dname, kif->kf_path, sizeof(sock->dname));
bcopy(&kif->kf_sa_local, &sock->sa_local, kif->kf_sa_local.ss_len); bcopy(&kif->kf_un.kf_sock.kf_sa_local, &sock->sa_local,
bcopy(&kif->kf_sa_peer, &sock->sa_peer, kif->kf_sa_peer.ss_len); kif->kf_un.kf_sock.kf_sa_local.ss_len);
bcopy(&kif->kf_un.kf_sock.kf_sa_peer, &sock->sa_peer,
kif->kf_un.kf_sock.kf_sa_peer.ss_len);
/* /*
* Protocol specific data. * Protocol specific data.

View File

@ -120,15 +120,15 @@ struct filestat {
struct vnstat { struct vnstat {
uint64_t vn_fileid; uint64_t vn_fileid;
uint64_t vn_size; uint64_t vn_size;
uint64_t vn_dev;
uint64_t vn_fsid;
char *vn_mntdir; char *vn_mntdir;
uint32_t vn_dev;
uint32_t vn_fsid;
int vn_type; int vn_type;
uint16_t vn_mode; uint16_t vn_mode;
char vn_devname[SPECNAMELEN + 1]; char vn_devname[SPECNAMELEN + 1];
}; };
struct ptsstat { struct ptsstat {
uint32_t dev; uint64_t dev;
char devname[SPECNAMELEN + 1]; char devname[SPECNAMELEN + 1];
}; };
struct pipestat { struct pipestat {

View File

@ -0,0 +1,144 @@
/*-
* Copyright (c) 2014 Gleb Kurtsou <gleb@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/user.h>
#include <sys/socket.h>
#include <string.h>
#include "libprocstat.h"
struct freebsd11_ptsstat {
uint32_t dev;
char devname[SPECNAMELEN + 1];
};
struct freebsd11_vnstat {
uint64_t vn_fileid;
uint64_t vn_size;
char *vn_mntdir;
uint32_t vn_dev;
uint32_t vn_fsid;
int vn_type;
uint16_t vn_mode;
char vn_devname[SPECNAMELEN + 1];
};
struct freebsd11_semstat {
uint32_t value;
uint16_t mode;
};
struct freebsd11_shmstat {
uint64_t size;
uint16_t mode;
};
int freebsd11_procstat_get_pts_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_ptsstat *pts, char *errbuf);
int freebsd11_procstat_get_sem_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_semstat *sem, char *errbuf);
int freebsd11_procstat_get_shm_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_shmstat *shm, char *errbuf);
int freebsd11_procstat_get_vnode_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_vnstat *vn, char *errbuf);
int
freebsd11_procstat_get_pts_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_ptsstat *pts_compat, char *errbuf)
{
struct ptsstat pts;
int r;
r = procstat_get_pts_info(procstat, fst, &pts, errbuf);
if (r != 0)
return (r);
pts_compat->dev = pts.dev;
memcpy(pts_compat->devname, pts.devname,
sizeof(pts_compat->devname));
return (0);
}
int
freebsd11_procstat_get_sem_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_semstat *sem_compat, char *errbuf)
{
struct semstat sem;
int r;
r = procstat_get_sem_info(procstat, fst, &sem, errbuf);
if (r != 0)
return (r);
sem_compat->value = sem.value;
sem_compat->mode = sem.mode;
return (0);
}
int
freebsd11_procstat_get_shm_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_shmstat *shm_compat, char *errbuf)
{
struct shmstat shm;
int r;
r = procstat_get_shm_info(procstat, fst, &shm, errbuf);
if (r != 0)
return (r);
shm_compat->size = shm.size;
shm_compat->mode = shm.mode;
return (0);
}
int
freebsd11_procstat_get_vnode_info(struct procstat *procstat,
struct filestat *fst, struct freebsd11_vnstat *vn_compat, char *errbuf)
{
struct vnstat vn;
int r;
r = procstat_get_vnode_info(procstat, fst, &vn, errbuf);
if (r != 0)
return (r);
vn_compat->vn_fileid = vn.vn_fileid;
vn_compat->vn_size = vn.vn_size;
vn_compat->vn_mntdir = vn.vn_mntdir;
vn_compat->vn_dev = vn.vn_dev;
vn_compat->vn_fsid = vn.vn_fsid;
vn_compat->vn_type = vn.vn_type;
vn_compat->vn_mode = vn.vn_mode;
memcpy(vn_compat->vn_devname, vn.vn_devname,
sizeof(vn_compat->vn_devname));
return (0);
}
__sym_compat(procstat_get_pts_info, freebsd11_procstat_get_pts_info, FBSD_1.2);
__sym_compat(procstat_get_vnode_info, freebsd11_procstat_get_vnode_info,
FBSD_1.2);
__sym_compat(procstat_get_sem_info, freebsd11_procstat_get_sem_info, FBSD_1.3);
__sym_compat(procstat_get_shm_info, freebsd11_procstat_get_shm_info, FBSD_1.3);

View File

@ -45,8 +45,8 @@ struct uufsd {
ufs2_daddr_t d_sblock; /* superblock location */ ufs2_daddr_t d_sblock; /* superblock location */
struct csum *d_sbcsum; /* Superblock summary info */ struct csum *d_sbcsum; /* Superblock summary info */
caddr_t d_inoblock; /* inode block */ caddr_t d_inoblock; /* inode block */
ino_t d_inomin; /* low inode */ uint32_t d_inomin; /* low inode (not ino_t for ABI compat) */
ino_t d_inomax; /* high inode */ uint32_t d_inomax; /* high inode (not ino_t for ABI compat) */
union { union {
struct fs d_fs; /* filesystem information */ struct fs d_fs; /* filesystem information */
char d_sb[MAXBSIZE]; char d_sb[MAXBSIZE];

View File

@ -129,19 +129,8 @@ main(int argc, char *argv[])
err(8, "%s", *argv); err(8, "%s", *argv);
if (chkuse(number, 1)) if (chkuse(number, 1))
continue; continue;
/*
* Print a warning if converting the block number to a dev_t
* will truncate it. badsect was not very useful in versions
* of BSD before 4.4 because dev_t was 16 bits and another
* bit was lost by bogus sign extensions.
*/
diskbn = dbtofsb(fs, number); diskbn = dbtofsb(fs, number);
if ((dev_t)diskbn != diskbn) { if (mknod(*argv, IFMT|0600, (dev_t)diskbn) < 0) {
printf("sector %ld cannot be represented as a dev_t\n",
(long)number);
errs++;
}
else if (mknod(*argv, IFMT|0600, (dev_t)diskbn) < 0) {
warn("%s", *argv); warn("%s", *argv);
errs++; errs++;
} }

View File

@ -1347,8 +1347,8 @@ ino_adjust(struct suj_ino *sino)
struct suj_ino *stmp; struct suj_ino *stmp;
union dinode *ip; union dinode *ip;
nlink_t nlink; nlink_t nlink;
nlink_t reqlink;
int recmode; int recmode;
int reqlink;
int isdot; int isdot;
int mode; int mode;
ino_t ino; ino_t ino;
@ -1635,9 +1635,9 @@ ino_check(struct suj_ino *sino)
struct suj_rec *srec; struct suj_rec *srec;
struct jrefrec *rrec; struct jrefrec *rrec;
nlink_t dotlinks; nlink_t dotlinks;
int newlinks; nlink_t newlinks;
int removes; nlink_t removes;
int nlink; nlink_t nlink;
ino_t ino; ino_t ino;
int isdot; int isdot;
int isat; int isat;

View File

@ -28,7 +28,7 @@
.\" @(#)acct.5 8.1 (Berkeley) 6/5/93 .\" @(#)acct.5 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd May 15, 2007 .Dd February 13, 2017
.Dt ACCT 5 .Dt ACCT 5
.Os .Os
.Sh NAME .Sh NAME
@ -51,12 +51,12 @@ to the accounting file.
#define AC_COMM_LEN 16 #define AC_COMM_LEN 16
/* /*
* Accounting structure version 2 (current). * Accounting structure version 3 (current).
* The first byte is always zero. * The first byte is always zero.
* Time units are microseconds. * Time units are microseconds.
*/ */
struct acctv2 { struct acctv3 {
uint8_t ac_zero; /* zero identifies new version */ uint8_t ac_zero; /* zero identifies new version */
uint8_t ac_version; /* record version number */ uint8_t ac_version; /* record version number */
uint16_t ac_len; /* record length */ uint16_t ac_len; /* record length */
@ -74,7 +74,7 @@ struct acctv2 {
uint16_t ac_len2; /* record length */ uint16_t ac_len2; /* record length */
union { union {
__dev_t ac_align; /* force v1 compatible alignment */ uint32_t ac_align; /* force v1 compatible alignment */
#define AFORK 0x01 /* forked but not exec'ed */ #define AFORK 0x01 /* forked but not exec'ed */
/* ASU is no longer supported */ /* ASU is no longer supported */

View File

@ -28,7 +28,7 @@
.\" @(#)dir.5 8.3 (Berkeley) 4/19/94 .\" @(#)dir.5 8.3 (Berkeley) 4/19/94
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd April 19, 1994 .Dd February 13, 2017
.Dt DIR 5 .Dt DIR 5
.Os .Os
.Sh NAME .Sh NAME
@ -93,18 +93,24 @@ The directory entry format is defined in the file
* contained in the entry. These are followed by the name padded to a 4 * contained in the entry. These are followed by the name padded to a 4
* byte boundary with null bytes. All names are guaranteed null terminated. * byte boundary with null bytes. All names are guaranteed null terminated.
* The maximum length of a name in a directory is MAXNAMLEN. * The maximum length of a name in a directory is MAXNAMLEN.
* Explicit pad is added between the last member of the header and
* d_name, to avoid having the ABI padding in the end of dirent on
* LP64 arches. There is code depending on d_name being last. Also,
* keeping this pad for ILP32 architectures simplifies compat32 layer.
*/ */
struct dirent { struct dirent {
__uint32_t d_fileno; /* file number of entry */ ino_t d_fileno; /* file number of entry */
off_t d_off; /* directory offset of entry */
__uint16_t d_reclen; /* length of this record */ __uint16_t d_reclen; /* length of this record */
__uint8_t d_type; /* file type, see below */ __uint8_t d_type; /* file type, see below */
__uint8_t d_namlen; /* length of string in d_name */ __uint8_t d_namlen; /* length of string in d_name */
#ifdef _POSIX_SOURCE __uint32_t d_pad0;
char d_name[255 + 1]; /* name must be no longer than this */ #if __BSD_VISIBLE
#else
#define MAXNAMLEN 255 #define MAXNAMLEN 255
char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
#else
char d_name[255 + 1]; /* name must be no longer than this */
#endif #endif
}; };
@ -129,12 +135,17 @@ struct dirent {
/* /*
* The _GENERIC_DIRSIZ macro gives the minimum record length which will hold * The _GENERIC_DIRSIZ macro gives the minimum record length which will hold
* the directory entry. This requires the amount of space in struct direct * the directory entry. This returns the amount of space in struct direct
* without the d_name field, plus enough space for the name with a terminating * without the d_name field, plus enough space for the name with a terminating
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. * null byte (dp->d_namlen+1), rounded up to a 8 byte boundary.
*
* XXX although this macro is in the implementation namespace, it requires
* a manifest constant that is not.
*/ */
#define _GENERIC_DIRSIZ(dp) \ #define _GENERIC_DIRLEN(namlen) \
((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) ((__offsetof(struct dirent, d_name) + (namlen) + 1 + 7) & ~7)
#define _GENERIC_DIRSIZ(dp) _GENERIC_DIRLEN((dp)->d_namlen)
#endif /* __BSD_VISIBLE */
#ifdef _KERNEL #ifdef _KERNEL
#define GENERIC_DIRSIZ(dp) _GENERIC_DIRSIZ(dp) #define GENERIC_DIRSIZ(dp) _GENERIC_DIRSIZ(dp)

View File

@ -183,13 +183,13 @@ typedef u_int32_t au_class_t;
typedef u_int64_t au_asflgs_t __attribute__ ((aligned (8))); typedef u_int64_t au_asflgs_t __attribute__ ((aligned (8)));
struct au_tid { struct au_tid {
dev_t port; u_int32_t port; /* XXX dev_t compatibility */
u_int32_t machine; u_int32_t machine;
}; };
typedef struct au_tid au_tid_t; typedef struct au_tid au_tid_t;
struct au_tid_addr { struct au_tid_addr {
dev_t at_port; u_int32_t at_port; /* XXX dev_t compatibility */
u_int32_t at_type; u_int32_t at_type;
u_int32_t at_addr[4]; u_int32_t at_addr[4];
}; };

View File

@ -40,8 +40,6 @@ typedef ino_t ino64_t;
#define d_ino d_fileno #define d_ino d_fileno
#define DIRENT64_RECLEN(len) ((sizeof(struct dirent) - \ #define DIRENT64_RECLEN(len) _GENERIC_DIRLEN(len)
sizeof(((struct dirent *)NULL)->d_name) + \
(len) + 1 + 3) & ~3)
#endif /* !_OPENSOLARIS_SYS_DIRENT_H_ */ #endif /* !_OPENSOLARIS_SYS_DIRENT_H_ */

View File

@ -94,6 +94,11 @@ freebsd32_fexecve
flock flock
fork fork
fpathconf fpathconf
freebsd11_freebsd32_fstat
freebsd11_freebsd32_fstatat
freebsd11_freebsd32_getdirentries
freebsd11_freebsd32_fstatfs
freebsd11_freebsd32_mknodat
freebsd6_freebsd32_ftruncate freebsd6_freebsd32_ftruncate
freebsd6_freebsd32_lseek freebsd6_freebsd32_lseek
freebsd6_freebsd32_mmap freebsd6_freebsd32_mmap

View File

@ -107,7 +107,8 @@ struct itimerval32 {
struct timeval32 it_value; struct timeval32 it_value;
}; };
#define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */ #define FREEBSD4_MFSNAMELEN 16
#define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t))
/* 4.x version */ /* 4.x version */
struct statfs32 { struct statfs32 {
@ -125,7 +126,7 @@ struct statfs32 {
int32_t f_flags; int32_t f_flags;
int32_t f_syncwrites; int32_t f_syncwrites;
int32_t f_asyncwrites; int32_t f_asyncwrites;
char f_fstypename[MFSNAMELEN]; char f_fstypename[FREEBSD4_MFSNAMELEN];
char f_mntonname[FREEBSD4_MNAMELEN]; char f_mntonname[FREEBSD4_MNAMELEN];
int32_t f_syncreads; int32_t f_syncreads;
int32_t f_asyncreads; int32_t f_asyncreads;
@ -159,14 +160,51 @@ struct msghdr32 {
int msg_flags; int msg_flags;
}; };
#if defined(__amd64__)
#define __STAT32_TIME_T_EXT 1
#endif
struct stat32 { struct stat32 {
dev_t st_dev; dev_t st_dev;
ino_t st_ino; ino_t st_ino;
nlink_t st_nlink;
mode_t st_mode; mode_t st_mode;
nlink_t st_nlink; u_int16_t st_padding0;
uid_t st_uid; uid_t st_uid;
gid_t st_gid; gid_t st_gid;
dev_t st_rdev; u_int32_t st_padding1;
dev_t st_rdev;
#ifdef __STAT32_TIME_T_EXT
__int32_t st_atim_ext;
#endif
struct timespec32 st_atim;
#ifdef __STAT32_TIME_T_EXT
__int32_t st_mtim_ext;
#endif
struct timespec32 st_mtim;
#ifdef __STAT32_TIME_T_EXT
__int32_t st_ctim_ext;
#endif
struct timespec32 st_ctim;
#ifdef __STAT32_TIME_T_EXT
__int32_t st_btim_ext;
#endif
struct timespec32 st_birthtim;
off_t st_size;
int64_t st_blocks;
u_int32_t st_blksize;
u_int32_t st_flags;
u_int64_t st_gen;
u_int64_t st_spare[10];
};
struct freebsd11_stat32 {
u_int32_t st_dev;
u_int32_t st_ino;
mode_t st_mode;
u_int16_t st_nlink;
uid_t st_uid;
gid_t st_gid;
u_int32_t st_rdev;
struct timespec32 st_atim; struct timespec32 st_atim;
struct timespec32 st_mtim; struct timespec32 st_mtim;
struct timespec32 st_ctim; struct timespec32 st_ctim;
@ -183,9 +221,9 @@ struct stat32 {
struct ostat32 { struct ostat32 {
__uint16_t st_dev; __uint16_t st_dev;
ino_t st_ino; __uint32_t st_ino;
mode_t st_mode; mode_t st_mode;
nlink_t st_nlink; __uint16_t st_nlink;
__uint16_t st_uid; __uint16_t st_uid;
__uint16_t st_gid; __uint16_t st_gid;
__uint16_t st_rdev; __uint16_t st_rdev;
@ -270,7 +308,7 @@ struct kinfo_proc32 {
pid_t ki_tsid; pid_t ki_tsid;
short ki_jobc; short ki_jobc;
short ki_spare_short1; short ki_spare_short1;
dev_t ki_tdev; uint32_t ki_tdev_freebsd11;
sigset_t ki_siglist; sigset_t ki_siglist;
sigset_t ki_sigmask; sigset_t ki_sigmask;
sigset_t ki_sigignore; sigset_t ki_sigignore;
@ -318,6 +356,7 @@ struct kinfo_proc32 {
char ki_moretdname[MAXCOMLEN-TDNAMLEN+1]; char ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
char ki_sparestrings[46]; char ki_sparestrings[46];
int ki_spareints[KI_NSPARE_INT]; int ki_spareints[KI_NSPARE_INT];
uint64_t ki_tdev;
int ki_oncpu; int ki_oncpu;
int ki_lastcpu; int ki_lastcpu;
int ki_tracer; int ki_tracer;

View File

@ -122,8 +122,11 @@ CTASSERT(sizeof(struct sigaltstack32) == 12);
CTASSERT(sizeof(struct kevent32) == 20); CTASSERT(sizeof(struct kevent32) == 20);
CTASSERT(sizeof(struct iovec32) == 8); CTASSERT(sizeof(struct iovec32) == 8);
CTASSERT(sizeof(struct msghdr32) == 28); CTASSERT(sizeof(struct msghdr32) == 28);
#ifdef __amd64__
CTASSERT(sizeof(struct stat32) == 208);
#endif
#ifndef __mips__ #ifndef __mips__
CTASSERT(sizeof(struct stat32) == 96); CTASSERT(sizeof(struct freebsd11_stat32) == 96);
#endif #endif
CTASSERT(sizeof(struct sigaction32) == 24); CTASSERT(sizeof(struct sigaction32) == 24);
@ -448,6 +451,26 @@ freebsd32_fexecve(struct thread *td, struct freebsd32_fexecve_args *uap)
return (error); return (error);
} }
#if defined(COMPAT_FREEBSD11)
int
freebsd11_freebsd32_mknod(struct thread *td,
struct freebsd11_freebsd32_mknod_args *uap)
{
return (kern_mknodat(td, AT_FDCWD, uap->path, UIO_USERSPACE, uap->mode,
uap->dev));
}
int
freebsd11_freebsd32_mknodat(struct thread *td,
struct freebsd11_freebsd32_mknodat_args *uap)
{
return (kern_mknodat(td, uap->fd, uap->path, UIO_USERSPACE, uap->mode,
uap->dev));
}
#endif /* COMPAT_FREEBSD11 */
int int
freebsd32_mprotect(struct thread *td, struct freebsd32_mprotect_args *uap) freebsd32_mprotect(struct thread *td, struct freebsd32_mprotect_args *uap)
{ {
@ -1519,6 +1542,40 @@ ofreebsd32_getdirentries(struct thread *td,
} }
#endif #endif
#if defined(COMPAT_FREEBSD11)
int
freebsd11_freebsd32_getdirentries(struct thread *td,
struct freebsd11_freebsd32_getdirentries_args *uap)
{
long base;
int32_t base32;
int error;
error = freebsd11_kern_getdirentries(td, uap->fd, uap->buf, uap->count,
&base, NULL);
if (error)
return (error);
if (uap->basep != NULL) {
base32 = base;
error = copyout(&base32, uap->basep, sizeof(int32_t));
}
return (error);
}
int
freebsd11_freebsd32_getdents(struct thread *td,
struct freebsd11_freebsd32_getdents_args *uap)
{
struct freebsd11_freebsd32_getdirentries_args ap;
ap.fd = uap->fd;
ap.buf = uap->buf;
ap.count = uap->count;
ap.basep = NULL;
return (freebsd11_freebsd32_getdirentries(td, &ap));
}
#endif /* COMPAT_FREEBSD11 */
int int
freebsd32_getdirentries(struct thread *td, freebsd32_getdirentries(struct thread *td,
struct freebsd32_getdirentries_args *uap) struct freebsd32_getdirentries_args *uap)
@ -1709,6 +1766,15 @@ copy_stat(struct stat *in, struct stat32 *out)
CP(*in, *out, st_flags); CP(*in, *out, st_flags);
CP(*in, *out, st_gen); CP(*in, *out, st_gen);
TS_CP(*in, *out, st_birthtim); TS_CP(*in, *out, st_birthtim);
out->st_padding0 = 0;
out->st_padding1 = 0;
#ifdef __STAT32_TIME_T_EXT
out->st_atim_ext = 0;
out->st_mtim_ext = 0;
out->st_ctim_ext = 0;
out->st_btim_ext = 0;
#endif
bzero(out->st_spare, sizeof(out->st_spare));
} }
#ifdef COMPAT_43 #ifdef COMPAT_43
@ -1734,22 +1800,6 @@ copy_ostat(struct stat *in, struct ostat32 *out)
} }
#endif #endif
int
freebsd32_stat(struct thread *td, struct freebsd32_stat_args *uap)
{
struct stat sb;
struct stat32 sb32;
int error;
error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
&sb, NULL);
if (error)
return (error);
copy_stat(&sb, &sb32);
error = copyout(&sb32, uap->ub, sizeof (sb32));
return (error);
}
#ifdef COMPAT_43 #ifdef COMPAT_43
int int
ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap) ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap)
@ -1816,22 +1866,6 @@ freebsd32_fstatat(struct thread *td, struct freebsd32_fstatat_args *uap)
return (error); return (error);
} }
int
freebsd32_lstat(struct thread *td, struct freebsd32_lstat_args *uap)
{
struct stat sb;
struct stat32 sb32;
int error;
error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
UIO_USERSPACE, &sb, NULL);
if (error)
return (error);
copy_stat(&sb, &sb32);
error = copyout(&sb32, uap->ub, sizeof (sb32));
return (error);
}
#ifdef COMPAT_43 #ifdef COMPAT_43
int int
ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap) ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap)
@ -1850,6 +1884,140 @@ ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap)
} }
#endif #endif
int
freebsd32_fhstat(struct thread *td, struct freebsd32_fhstat_args *uap)
{
struct stat sb;
struct stat32 sb32;
struct fhandle fh;
int error;
error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
if (error != 0)
return (error);
error = kern_fhstat(td, fh, &sb);
if (error != 0)
return (error);
copy_stat(&sb, &sb32);
error = copyout(&sb32, uap->sb, sizeof (sb32));
return (error);
}
#if defined(COMPAT_FREEBSD11)
static void
freebsd11_cvtstat32(struct stat *in, struct freebsd11_stat32 *out)
{
CP(*in, *out, st_ino);
CP(*in, *out, st_nlink);
CP(*in, *out, st_dev);
CP(*in, *out, st_mode);
CP(*in, *out, st_uid);
CP(*in, *out, st_gid);
CP(*in, *out, st_rdev);
TS_CP(*in, *out, st_atim);
TS_CP(*in, *out, st_mtim);
TS_CP(*in, *out, st_ctim);
CP(*in, *out, st_size);
CP(*in, *out, st_blocks);
CP(*in, *out, st_blksize);
CP(*in, *out, st_flags);
CP(*in, *out, st_gen);
TS_CP(*in, *out, st_birthtim);
out->st_lspare = 0;
bzero((char *)&out->st_birthtim + sizeof(out->st_birthtim),
sizeof(*out) - offsetof(struct freebsd11_stat32,
st_birthtim) - sizeof(out->st_birthtim));
}
int
freebsd11_freebsd32_stat(struct thread *td,
struct freebsd11_freebsd32_stat_args *uap)
{
struct stat sb;
struct freebsd11_stat32 sb32;
int error;
error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
&sb, NULL);
if (error != 0)
return (error);
freebsd11_cvtstat32(&sb, &sb32);
error = copyout(&sb32, uap->ub, sizeof (sb32));
return (error);
}
int
freebsd11_freebsd32_fstat(struct thread *td,
struct freebsd11_freebsd32_fstat_args *uap)
{
struct stat sb;
struct freebsd11_stat32 sb32;
int error;
error = kern_fstat(td, uap->fd, &sb);
if (error != 0)
return (error);
freebsd11_cvtstat32(&sb, &sb32);
error = copyout(&sb32, uap->ub, sizeof (sb32));
return (error);
}
int
freebsd11_freebsd32_fstatat(struct thread *td,
struct freebsd11_freebsd32_fstatat_args *uap)
{
struct stat sb;
struct freebsd11_stat32 sb32;
int error;
error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE,
&sb, NULL);
if (error != 0)
return (error);
freebsd11_cvtstat32(&sb, &sb32);
error = copyout(&sb32, uap->buf, sizeof (sb32));
return (error);
}
int
freebsd11_freebsd32_lstat(struct thread *td,
struct freebsd11_freebsd32_lstat_args *uap)
{
struct stat sb;
struct freebsd11_stat32 sb32;
int error;
error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
UIO_USERSPACE, &sb, NULL);
if (error)
return (error);
freebsd11_cvtstat32(&sb, &sb32);
error = copyout(&sb32, uap->ub, sizeof (sb32));
return (error);
}
int
freebsd11_freebsd32_fhstat(struct thread *td,
struct freebsd11_freebsd32_fhstat_args *uap)
{
struct stat sb;
struct freebsd11_stat32 sb32;
struct fhandle fh;
int error;
error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
if (error != 0)
return (error);
error = kern_fhstat(td, fh, &sb);
if (error != 0)
return (error);
freebsd11_cvtstat32(&sb, &sb32);
error = copyout(&sb32, uap->sb, sizeof (sb32));
return (error);
}
#endif
int int
freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap) freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap)
{ {

View File

@ -13,7 +13,7 @@
; case where the event exists, but we don't want auditing, the ; case where the event exists, but we don't want auditing, the
; event should be #defined to AUE_NULL in audit_kevents.h. ; event should be #defined to AUE_NULL in audit_kevents.h.
; type one of STD, OBSOL, UNIMPL, COMPAT, COMPAT4, COMPAT6, ; type one of STD, OBSOL, UNIMPL, COMPAT, COMPAT4, COMPAT6,
; COMPAT7, NODEF, NOARGS, NOPROTO, NOSTD ; COMPAT7, COMPAT11, NODEF, NOARGS, NOPROTO, NOSTD
; The COMPAT* options may be combined with one or more NO* ; The COMPAT* options may be combined with one or more NO*
; options separated by '|' with no spaces (e.g. COMPAT|NOARGS) ; options separated by '|' with no spaces (e.g. COMPAT|NOARGS)
; name psuedo-prototype of syscall routine ; name psuedo-prototype of syscall routine
@ -30,6 +30,7 @@
; COMPAT6 included on COMPAT6 #ifdef (FreeBSD 6 compat) ; COMPAT6 included on COMPAT6 #ifdef (FreeBSD 6 compat)
; COMPAT7 included on COMPAT7 #ifdef (FreeBSD 7 compat) ; COMPAT7 included on COMPAT7 #ifdef (FreeBSD 7 compat)
; COMPAT10 included on COMPAT10 #ifdef (FreeBSD 10 compat) ; COMPAT10 included on COMPAT10 #ifdef (FreeBSD 10 compat)
; COMPAT11 included on COMPAT11 #ifdef (FreeBSD 11 compat)
; OBSOL obsolete, not included in system, only specifies name ; OBSOL obsolete, not included in system, only specifies name
; UNIMPL not implemented, placeholder only ; UNIMPL not implemented, placeholder only
; NOSTD implemented but as a lkm that can be statically ; NOSTD implemented but as a lkm that can be statically
@ -82,7 +83,8 @@
11 AUE_NULL OBSOL execv 11 AUE_NULL OBSOL execv
12 AUE_CHDIR NOPROTO { int chdir(char *path); } 12 AUE_CHDIR NOPROTO { int chdir(char *path); }
13 AUE_FCHDIR NOPROTO { int fchdir(int fd); } 13 AUE_FCHDIR NOPROTO { int fchdir(int fd); }
14 AUE_MKNOD NOPROTO { int mknod(char *path, int mode, int dev); } 14 AUE_MKNOD COMPAT11 { int freebsd32_mknod(char *path, \
int mode, int dev); }
15 AUE_CHMOD NOPROTO { int chmod(char *path, int mode); } 15 AUE_CHMOD NOPROTO { int chmod(char *path, int mode); }
16 AUE_CHOWN NOPROTO { int chown(char *path, int uid, int gid); } 16 AUE_CHOWN NOPROTO { int chown(char *path, int uid, int gid); }
17 AUE_NULL NOPROTO { int obreak(char *nsize); } break \ 17 AUE_NULL NOPROTO { int obreak(char *nsize); } break \
@ -348,12 +350,12 @@
185 AUE_NULL UNIMPL lfs_markv 185 AUE_NULL UNIMPL lfs_markv
186 AUE_NULL UNIMPL lfs_segclean 186 AUE_NULL UNIMPL lfs_segclean
187 AUE_NULL UNIMPL lfs_segwait 187 AUE_NULL UNIMPL lfs_segwait
188 AUE_STAT STD { int freebsd32_stat(char *path, \ 188 AUE_STAT COMPAT11 { int freebsd32_stat(char *path, \
struct stat32 *ub); } struct freebsd11_stat32 *ub); }
189 AUE_FSTAT STD { int freebsd32_fstat(int fd, \ 189 AUE_FSTAT COMPAT11 { int freebsd32_fstat(int fd, \
struct stat32 *ub); } struct freebsd11_stat32 *ub); }
190 AUE_LSTAT STD { int freebsd32_lstat(char *path, \ 190 AUE_LSTAT COMPAT11 { int freebsd32_lstat(char *path, \
struct stat32 *ub); } struct freebsd11_stat32 *ub); }
191 AUE_PATHCONF NOPROTO { int pathconf(char *path, int name); } 191 AUE_PATHCONF NOPROTO { int pathconf(char *path, int name); }
192 AUE_FPATHCONF NOPROTO { int fpathconf(int fd, int name); } 192 AUE_FPATHCONF NOPROTO { int fpathconf(int fd, int name); }
193 AUE_NULL UNIMPL nosys 193 AUE_NULL UNIMPL nosys
@ -363,7 +365,7 @@
195 AUE_SETRLIMIT NOPROTO { int setrlimit(u_int which, \ 195 AUE_SETRLIMIT NOPROTO { int setrlimit(u_int which, \
struct rlimit *rlp); } setrlimit \ struct rlimit *rlp); } setrlimit \
__setrlimit_args int __setrlimit_args int
196 AUE_GETDIRENTRIES STD { int freebsd32_getdirentries(int fd, \ 196 AUE_GETDIRENTRIES COMPAT11 { int freebsd32_getdirentries(int fd, \
char *buf, u_int count, int32_t *basep); } char *buf, u_int count, int32_t *basep); }
197 AUE_MMAP COMPAT6 { caddr_t freebsd32_mmap(caddr_t addr, \ 197 AUE_MMAP COMPAT6 { caddr_t freebsd32_mmap(caddr_t addr, \
size_t len, int prot, int flags, int fd, \ size_t len, int prot, int flags, int fd, \
@ -501,8 +503,8 @@
269 AUE_NULL UNIMPL nosys 269 AUE_NULL UNIMPL nosys
270 AUE_NULL UNIMPL nosys 270 AUE_NULL UNIMPL nosys
271 AUE_NULL UNIMPL nosys 271 AUE_NULL UNIMPL nosys
272 AUE_O_GETDENTS NOPROTO { int getdents(int fd, char *buf, \ 272 AUE_O_GETDENTS COMPAT11 { int freebsd32_getdents(int fd, char *buf, \
size_t count); } int count); }
273 AUE_NULL UNIMPL nosys 273 AUE_NULL UNIMPL nosys
274 AUE_LCHMOD NOPROTO { int lchmod(char *path, mode_t mode); } 274 AUE_LCHMOD NOPROTO { int lchmod(char *path, mode_t mode); }
275 AUE_LCHOWN NOPROTO { int lchown(char *path, uid_t uid, \ 275 AUE_LCHOWN NOPROTO { int lchown(char *path, uid_t uid, \
@ -512,9 +514,9 @@
struct timeval32 *tptr); } struct timeval32 *tptr); }
277 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \ 277 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \
int flags); } netbsd_msync msync_args int int flags); } netbsd_msync msync_args int
278 AUE_STAT NOPROTO { int nstat(char *path, struct nstat *ub); } 278 AUE_STAT COMPAT11|NOPROTO { int nstat(char *path, struct nstat *ub); }
279 AUE_FSTAT NOPROTO { int nfstat(int fd, struct nstat *sb); } 279 AUE_FSTAT COMPAT11|NOPROTO { int nfstat(int fd, struct nstat *sb); }
280 AUE_LSTAT NOPROTO { int nlstat(char *path, struct nstat *ub); } 280 AUE_LSTAT COMPAT11|NOPROTO { int nlstat(char *path, struct nstat *ub); }
281 AUE_NULL UNIMPL nosys 281 AUE_NULL UNIMPL nosys
282 AUE_NULL UNIMPL nosys 282 AUE_NULL UNIMPL nosys
283 AUE_NULL UNIMPL nosys 283 AUE_NULL UNIMPL nosys
@ -544,8 +546,9 @@
struct statfs32 *buf); } struct statfs32 *buf); }
298 AUE_FHOPEN NOPROTO { int fhopen(const struct fhandle *u_fhp, \ 298 AUE_FHOPEN NOPROTO { int fhopen(const struct fhandle *u_fhp, \
int flags); } int flags); }
299 AUE_FHSTAT NOPROTO { int fhstat(const struct fhandle *u_fhp, \ 299 AUE_FHSTAT COMPAT11 { int freebsd32_fhstat( \
struct stat *sb); } const struct fhandle *u_fhp, \
struct freebsd11_stat32 *sb); }
; syscall numbers for FreeBSD ; syscall numbers for FreeBSD
300 AUE_NULL NOPROTO { int modnext(int modid); } 300 AUE_NULL NOPROTO { int modnext(int modid); }
301 AUE_NULL STD { int freebsd32_modstat(int modid, \ 301 AUE_NULL STD { int freebsd32_modstat(int modid, \
@ -713,13 +716,16 @@
size_t nbytes, struct sf_hdtr32 *hdtr, \ size_t nbytes, struct sf_hdtr32 *hdtr, \
off_t *sbytes, int flags); } off_t *sbytes, int flags); }
394 AUE_NULL UNIMPL mac_syscall 394 AUE_NULL UNIMPL mac_syscall
395 AUE_GETFSSTAT NOPROTO { int getfsstat(struct statfs *buf, \ 395 AUE_GETFSSTAT COMPAT11|NOPROTO { int getfsstat( \
struct freebsd11_statfs *buf, \
long bufsize, int mode); } long bufsize, int mode); }
396 AUE_STATFS NOPROTO { int statfs(char *path, \ 396 AUE_STATFS COMPAT11|NOPROTO { int statfs(char *path, \
struct statfs *buf); }
397 AUE_FSTATFS NOPROTO { int fstatfs(int fd, struct statfs *buf); }
398 AUE_FHSTATFS NOPROTO { int fhstatfs(const struct fhandle *u_fhp, \
struct statfs *buf); } struct statfs *buf); }
397 AUE_FSTATFS COMPAT11|NOPROTO { int fstatfs(int fd, \
struct freebsd11_statfs *buf); }
398 AUE_FHSTATFS COMPAT11|NOPROTO { int fhstatfs( \
const struct fhandle *u_fhp, \
struct freebsd11_statfs *buf); }
399 AUE_NULL UNIMPL nosys 399 AUE_NULL UNIMPL nosys
400 AUE_SEMCLOSE NOSTD|NOPROTO { int ksem_close(semid_t id); } 400 AUE_SEMCLOSE NOSTD|NOPROTO { int ksem_close(semid_t id); }
401 AUE_SEMPOST NOSTD|NOPROTO { int ksem_post(semid_t id); } 401 AUE_SEMPOST NOSTD|NOPROTO { int ksem_post(semid_t id); }
@ -936,8 +942,9 @@
gid_t gid, int flag); } gid_t gid, int flag); }
492 AUE_FEXECVE STD { int freebsd32_fexecve(int fd, \ 492 AUE_FEXECVE STD { int freebsd32_fexecve(int fd, \
uint32_t *argv, uint32_t *envv); } uint32_t *argv, uint32_t *envv); }
493 AUE_FSTATAT STD { int freebsd32_fstatat(int fd, char *path, \ 493 AUE_FSTATAT COMPAT11 { int freebsd32_fstatat(int fd, \
struct stat *buf, int flag); } char *path, struct freebsd11_stat32 *buf, \
int flag); }
494 AUE_FUTIMESAT STD { int freebsd32_futimesat(int fd, char *path, \ 494 AUE_FUTIMESAT STD { int freebsd32_futimesat(int fd, char *path, \
struct timeval *times); } struct timeval *times); }
495 AUE_LINKAT NOPROTO { int linkat(int fd1, char *path1, int fd2, \ 495 AUE_LINKAT NOPROTO { int linkat(int fd1, char *path1, int fd2, \
@ -946,8 +953,8 @@
mode_t mode); } mode_t mode); }
497 AUE_MKFIFOAT NOPROTO { int mkfifoat(int fd, char *path, \ 497 AUE_MKFIFOAT NOPROTO { int mkfifoat(int fd, char *path, \
mode_t mode); } mode_t mode); }
498 AUE_MKNODAT NOPROTO { int mknodat(int fd, char *path, \ 498 AUE_MKNODAT COMPAT11 { int freebsd32_mknodat(int fd, char *path, \
mode_t mode, dev_t dev); } mode_t mode, uint32_t dev); }
499 AUE_OPENAT_RWTC NOPROTO { int openat(int fd, char *path, int flag, \ 499 AUE_OPENAT_RWTC NOPROTO { int openat(int fd, char *path, int flag, \
mode_t mode); } mode_t mode); }
500 AUE_READLINKAT NOPROTO { int readlinkat(int fd, char *path, char *buf, \ 500 AUE_READLINKAT NOPROTO { int readlinkat(int fd, char *path, char *buf, \
@ -1084,3 +1091,23 @@
id_t id, \ id_t id, \
const struct vm_domain_policy *policy); } const struct vm_domain_policy *policy); }
550 AUE_FSYNC NOPROTO { int fdatasync(int fd); } 550 AUE_FSYNC NOPROTO { int fdatasync(int fd); }
551 AUE_FSTAT STD { int freebsd32_fstat(int fd, \
struct stat32 *ub); }
552 AUE_FSTATAT STD { int freebsd32_fstatat(int fd, \
char *path, struct stat32 *buf, \
int flag); }
553 AUE_FHSTAT STD { int freebsd32_fhstat( \
const struct fhandle *u_fhp, \
struct stat32 *sb); }
554 AUE_GETDIRENTRIES STD { ssize_t freebsd32_getdirentries( \
int fd, char *buf, size_t count, \
int32_t *basep); }
555 AUE_STATFS NOPROTO { int statfs(char *path, \
struct statfs32 *buf); }
556 AUE_FSTATFS NOPROTO { int fstatfs(int fd, struct statfs32 *buf); }
557 AUE_GETFSSTAT NOPROTO { int getfsstat(struct statfs32 *buf, \
long bufsize, int mode); }
558 AUE_FHSTATFS NOPROTO { int fhstatfs(const struct fhandle *u_fhp, \
struct statfs32 *buf); }
559 AUE_MKNODAT NOPROTO { int mknodat(int fd, char *path, mode_t mode, \
dev_t dev); }

View File

@ -328,7 +328,7 @@ linux_getdents(struct thread *td, struct linux_getdents_args *args)
caddr_t outp; /* Linux-format */ caddr_t outp; /* Linux-format */
int resid, linuxreclen; /* Linux-format */ int resid, linuxreclen; /* Linux-format */
caddr_t lbuf; /* Linux-format */ caddr_t lbuf; /* Linux-format */
long base; off_t base;
struct l_dirent *linux_dirent; struct l_dirent *linux_dirent;
int buflen, error; int buflen, error;
size_t retval; size_t retval;
@ -409,7 +409,7 @@ linux_getdents64(struct thread *td, struct linux_getdents64_args *args)
caddr_t outp; /* Linux-format */ caddr_t outp; /* Linux-format */
int resid, linuxreclen; /* Linux-format */ int resid, linuxreclen; /* Linux-format */
caddr_t lbuf; /* Linux-format */ caddr_t lbuf; /* Linux-format */
long base; off_t base;
struct l_dirent64 *linux_dirent64; struct l_dirent64 *linux_dirent64;
int buflen, error; int buflen, error;
size_t retval; size_t retval;
@ -486,7 +486,7 @@ linux_readdir(struct thread *td, struct linux_readdir_args *args)
caddr_t buf; /* BSD-format */ caddr_t buf; /* BSD-format */
int linuxreclen; /* Linux-format */ int linuxreclen; /* Linux-format */
caddr_t lbuf; /* Linux-format */ caddr_t lbuf; /* Linux-format */
long base; off_t base;
struct l_dirent *linux_dirent; struct l_dirent *linux_dirent;
int buflen, error; int buflen, error;
@ -1087,20 +1087,21 @@ int
linux_mount(struct thread *td, struct linux_mount_args *args) linux_mount(struct thread *td, struct linux_mount_args *args)
{ {
char fstypename[MFSNAMELEN]; char fstypename[MFSNAMELEN];
char mntonname[MNAMELEN], mntfromname[MNAMELEN]; char *mntonname, *mntfromname;
int error; int error, fsflags;
int fsflags;
mntonname = malloc(MNAMELEN, M_TEMP, M_WAITOK);
mntfromname = malloc(MNAMELEN, M_TEMP, M_WAITOK);
error = copyinstr(args->filesystemtype, fstypename, MFSNAMELEN - 1, error = copyinstr(args->filesystemtype, fstypename, MFSNAMELEN - 1,
NULL); NULL);
if (error) if (error != 0)
return (error); goto out;
error = copyinstr(args->specialfile, mntfromname, MNAMELEN - 1, NULL); error = copyinstr(args->specialfile, mntfromname, MNAMELEN - 1, NULL);
if (error) if (error != 0)
return (error); goto out;
error = copyinstr(args->dir, mntonname, MNAMELEN - 1, NULL); error = copyinstr(args->dir, mntonname, MNAMELEN - 1, NULL);
if (error) if (error != 0)
return (error); goto out;
#ifdef DEBUG #ifdef DEBUG
if (ldebug(mount)) if (ldebug(mount))
@ -1138,6 +1139,9 @@ linux_mount(struct thread *td, struct linux_mount_args *args)
"fspath", mntonname, "fspath", mntonname,
"from", mntfromname, "from", mntfromname,
NULL); NULL);
out:
free(mntonname, M_TEMP);
free(mntfromname, M_TEMP);
return (error); return (error);
} }

View File

@ -60,6 +60,8 @@ SX_SYSINIT(snp_register_lock, &snp_register_lock,
#define SNP_UNLOCK() sx_xunlock(&snp_register_lock) #define SNP_UNLOCK() sx_xunlock(&snp_register_lock)
#endif #endif
#define SNPGTYY_32DEV _IOR('T', 89, uint32_t)
/* /*
* There is no need to have a big input buffer. In most typical setups, * There is no need to have a big input buffer. In most typical setups,
* we won't inject much data into the TTY, because users can't type * we won't inject much data into the TTY, because users can't type
@ -275,6 +277,12 @@ snp_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
else else
*(dev_t *)data = tty_udev(ss->snp_tty); *(dev_t *)data = tty_udev(ss->snp_tty);
return (0); return (0);
case SNPGTYY_32DEV:
if (ss->snp_tty == NULL)
*(uint32_t *)data = -1;
else
*(uint32_t *)data = tty_udev(ss->snp_tty); /* trunc */
return (0);
case FIONREAD: case FIONREAD:
tp = ss->snp_tty; tp = ss->snp_tty;
if (tp != NULL) { if (tp != NULL) {

View File

@ -28,6 +28,8 @@
* $FreeBSD$ * $FreeBSD$
*/ */
#include "opt_compat.h"
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/conf.h> #include <sys/conf.h>
@ -80,10 +82,20 @@ sysctl_devname(SYSCTL_HANDLER_ARGS)
{ {
int error; int error;
dev_t ud; dev_t ud;
#ifdef COMPAT_FREEBSD11
uint32_t ud_compat;
#endif
struct cdev_priv *cdp; struct cdev_priv *cdp;
struct cdev *dev; struct cdev *dev;
error = SYSCTL_IN(req, &ud, sizeof (ud)); #ifdef COMPAT_FREEBSD11
if (req->newlen == sizeof(ud_compat)) {
error = SYSCTL_IN(req, &ud_compat, sizeof(ud_compat));
if (error == 0)
ud = ud_compat == (uint32_t)NODEV ? NODEV : ud_compat;
} else
#endif
error = SYSCTL_IN(req, &ud, sizeof (ud));
if (error) if (error)
return (error); return (error);
if (ud == NODEV) if (ud == NODEV)

View File

@ -1315,6 +1315,7 @@ devfs_readdir(struct vop_readdir_args *ap)
else else
de = dd; de = dd;
dp = dd->de_dirent; dp = dd->de_dirent;
MPASS(dp->d_reclen == GENERIC_DIRSIZ(dp));
if (dp->d_reclen > uio->uio_resid) if (dp->d_reclen > uio->uio_resid)
break; break;
dp->d_fileno = de->de_inode; dp->d_fileno = de->de_inode;

View File

@ -485,7 +485,7 @@ fdesc_setattr(struct vop_setattr_args *ap)
return (error); return (error);
} }
#define UIO_MX 16 #define UIO_MX _GENERIC_DIRLEN(10) /* number of symbols in INT_MAX printout */
static int static int
fdesc_readdir(struct vop_readdir_args *ap) fdesc_readdir(struct vop_readdir_args *ap)

View File

@ -537,7 +537,7 @@ struct nandfs_bdesc {
#ifndef _KERNEL #ifndef _KERNEL
#ifndef MNAMELEN #ifndef MNAMELEN
#define MNAMELEN 88 #define MNAMELEN 1024
#endif #endif
#endif #endif

View File

@ -729,12 +729,6 @@ int nfsmsleep(void *, void *, int, const char *, struct timespec *);
#define NFSMAJOR(d) major(d) #define NFSMAJOR(d) major(d)
#define NFSMINOR(d) minor(d) #define NFSMINOR(d) minor(d)
/*
* Define this to be the macro that returns the minimum size required
* for a directory entry.
*/
#define DIRENT_SIZE(dp) GENERIC_DIRSIZ(dp)
/* /*
* The vnode tag for nfsv4root. * The vnode tag for nfsv4root.
*/ */

View File

@ -72,7 +72,7 @@ short nfsv4_cbport = NFSV4_CBPORT;
int nfstest_openallsetattr = 0; int nfstest_openallsetattr = 0;
#endif /* !APPLEKEXT */ #endif /* !APPLEKEXT */
#define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) #define DIRHDSIZ offsetof(struct dirent, d_name)
/* /*
* nfscl_getsameserver() can return one of three values: * nfscl_getsameserver() can return one of three values:
@ -2861,17 +2861,18 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
if (error) if (error)
return (error); return (error);
nd->nd_mrep = NULL; nd->nd_mrep = NULL;
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); dp = (struct dirent *)uio_iov_base(uiop);
dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotfileid; dp->d_fileno = dotfileid;
dp->d_namlen = 1; dp->d_namlen = 1;
*((uint64_t *)dp->d_name) = 0; /* Zero pad it. */
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_name[1] = '\0'; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
tl = (u_int32_t *)&dp->d_name[4]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
@ -2879,18 +2880,19 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
uiop->uio_offset += dp->d_reclen; uiop->uio_offset += dp->d_reclen;
uio_iov_base_add(uiop, dp->d_reclen); uio_iov_base_add(uiop, dp->d_reclen);
uio_iov_len_add(uiop, -(dp->d_reclen)); uio_iov_len_add(uiop, -(dp->d_reclen));
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); dp = (struct dirent *)uio_iov_base(uiop);
dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotdotfileid; dp->d_fileno = dotdotfileid;
dp->d_namlen = 2; dp->d_namlen = 2;
*((uint64_t *)dp->d_name) = 0;
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_name[1] = '.'; dp->d_name[1] = '.';
dp->d_name[2] = '\0'; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
tl = (u_int32_t *)&dp->d_name[4]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
@ -2987,11 +2989,11 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
error = EBADRPC; error = EBADRPC;
goto nfsmout; goto nfsmout;
} }
tlen = NFSM_RNDUP(len); tlen = roundup2(len, 8);
if (tlen == len) if (tlen == len)
tlen += 4; /* To ensure null termination */ tlen += 8; /* To ensure null termination. */
left = DIRBLKSIZ - blksiz; left = DIRBLKSIZ - blksiz;
if ((int)(tlen + DIRHDSIZ + NFSX_HYPER) > left) { if (_GENERIC_DIRLEN(len) + NFSX_HYPER > left) {
dp->d_reclen += left; dp->d_reclen += left;
uio_iov_base_add(uiop, left); uio_iov_base_add(uiop, left);
uio_iov_len_add(uiop, -(left)); uio_iov_len_add(uiop, -(left));
@ -2999,12 +3001,15 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
uiop->uio_offset += left; uiop->uio_offset += left;
blksiz = 0; blksiz = 0;
} }
if ((int)(tlen + DIRHDSIZ + NFSX_HYPER) > uio_uio_resid(uiop)) if (_GENERIC_DIRLEN(len) + NFSX_HYPER >
uio_uio_resid(uiop))
bigenough = 0; bigenough = 0;
if (bigenough) { if (bigenough) {
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); dp = (struct dirent *)uio_iov_base(uiop);
dp->d_off = 0;
dp->d_namlen = len; dp->d_namlen = len;
dp->d_reclen = tlen + DIRHDSIZ + NFSX_HYPER; dp->d_reclen = _GENERIC_DIRLEN(len) +
NFSX_HYPER;
dp->d_type = DT_UNKNOWN; dp->d_type = DT_UNKNOWN;
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
if (blksiz == DIRBLKSIZ) if (blksiz == DIRBLKSIZ)
@ -3016,7 +3021,7 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
error = nfsm_mbufuio(nd, uiop, len); error = nfsm_mbufuio(nd, uiop, len);
if (error) if (error)
goto nfsmout; goto nfsmout;
cp = CAST_DOWN(caddr_t, uio_iov_base(uiop)); cp = uio_iov_base(uiop);
tlen -= len; tlen -= len;
*cp = '\0'; /* null terminate */ *cp = '\0'; /* null terminate */
cp += tlen; /* points to cookie storage */ cp += tlen; /* points to cookie storage */
@ -3131,8 +3136,8 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
/* /*
* Add extra empty records to any remaining DIRBLKSIZ chunks. * Add extra empty records to any remaining DIRBLKSIZ chunks.
*/ */
while (uio_uio_resid(uiop) > 0 && ((size_t)(uio_uio_resid(uiop))) != tresid) { while (uio_uio_resid(uiop) > 0 && uio_uio_resid(uiop) != tresid) {
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); dp = (struct dirent *)uio_iov_base(uiop);
dp->d_type = DT_UNKNOWN; dp->d_type = DT_UNKNOWN;
dp->d_fileno = 0; dp->d_fileno = 0;
dp->d_namlen = 0; dp->d_namlen = 0;
@ -3289,16 +3294,17 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
return (error); return (error);
nd->nd_mrep = NULL; nd->nd_mrep = NULL;
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotfileid; dp->d_fileno = dotfileid;
dp->d_namlen = 1; dp->d_namlen = 1;
*((uint64_t *)dp->d_name) = 0; /* Zero pad it. */
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_name[1] = '\0'; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
tl = (u_int32_t *)&dp->d_name[4]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
@ -3307,17 +3313,18 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
uio_iov_base_add(uiop, dp->d_reclen); uio_iov_base_add(uiop, dp->d_reclen);
uio_iov_len_add(uiop, -(dp->d_reclen)); uio_iov_len_add(uiop, -(dp->d_reclen));
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
dp->d_off = 0;
dp->d_type = DT_DIR; dp->d_type = DT_DIR;
dp->d_fileno = dotdotfileid; dp->d_fileno = dotdotfileid;
dp->d_namlen = 2; dp->d_namlen = 2;
*((uint64_t *)dp->d_name) = 0;
dp->d_name[0] = '.'; dp->d_name[0] = '.';
dp->d_name[1] = '.'; dp->d_name[1] = '.';
dp->d_name[2] = '\0'; dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER;
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER;
/* /*
* Just make these offset cookie 0. * Just make these offset cookie 0.
*/ */
tl = (u_int32_t *)&dp->d_name[4]; tl = (u_int32_t *)&dp->d_name[8];
*tl++ = 0; *tl++ = 0;
*tl = 0; *tl = 0;
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
@ -3395,11 +3402,11 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
error = EBADRPC; error = EBADRPC;
goto nfsmout; goto nfsmout;
} }
tlen = NFSM_RNDUP(len); tlen = roundup2(len, 8);
if (tlen == len) if (tlen == len)
tlen += 4; /* To ensure null termination */ tlen += 8; /* To ensure null termination. */
left = DIRBLKSIZ - blksiz; left = DIRBLKSIZ - blksiz;
if ((tlen + DIRHDSIZ + NFSX_HYPER) > left) { if (_GENERIC_DIRLEN(len) + NFSX_HYPER > left) {
dp->d_reclen += left; dp->d_reclen += left;
uio_iov_base_add(uiop, left); uio_iov_base_add(uiop, left);
uio_iov_len_add(uiop, -(left)); uio_iov_len_add(uiop, -(left));
@ -3407,12 +3414,15 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
uiop->uio_offset += left; uiop->uio_offset += left;
blksiz = 0; blksiz = 0;
} }
if ((tlen + DIRHDSIZ + NFSX_HYPER) > uio_uio_resid(uiop)) if (_GENERIC_DIRLEN(len) + NFSX_HYPER >
uio_uio_resid(uiop))
bigenough = 0; bigenough = 0;
if (bigenough) { if (bigenough) {
dp = (struct dirent *)uio_iov_base(uiop); dp = (struct dirent *)uio_iov_base(uiop);
dp->d_off = 0;
dp->d_namlen = len; dp->d_namlen = len;
dp->d_reclen = tlen + DIRHDSIZ + NFSX_HYPER; dp->d_reclen = _GENERIC_DIRLEN(len) +
NFSX_HYPER;
dp->d_type = DT_UNKNOWN; dp->d_type = DT_UNKNOWN;
blksiz += dp->d_reclen; blksiz += dp->d_reclen;
if (blksiz == DIRBLKSIZ) if (blksiz == DIRBLKSIZ)

View File

@ -207,8 +207,6 @@ static int nfs_renameit(struct vnode *sdvp, struct vnode *svp,
/* /*
* Global variables * Global variables
*/ */
#define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1))
SYSCTL_DECL(_vfs_nfs); SYSCTL_DECL(_vfs_nfs);
static int nfsaccess_cache_timeout = NFS_MAXATTRTIMO; static int nfsaccess_cache_timeout = NFS_MAXATTRTIMO;

View File

@ -2020,17 +2020,25 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram,
} }
/* /*
* For now ZFS requires VOP_LOOKUP as a workaround. Until ino_t is changed * Check to see if entries in this directory can be safely acquired
* to 64 bit type a ZFS filesystem with over 1 billion files in it * via VFS_VGET() or if a switch to VOP_LOOKUP() is required.
* will suffer from 64bit -> 32bit truncation. * ZFS snapshot directories need VOP_LOOKUP(), so that any
* automount of the snapshot directory that is required will
* be done.
* This needs to be done here for NFSv4, since NFSv4 never does
* a VFS_VGET() for "." or "..".
*/ */
if (is_zfs == 1) if (is_zfs == 1) {
usevget = 0; r = VFS_VGET(mp, at.na_fileid, LK_SHARED, &nvp);
if (r == EOPNOTSUPP) {
cn.cn_nameiop = LOOKUP; usevget = 0;
cn.cn_lkflags = LK_SHARED | LK_RETRY; cn.cn_nameiop = LOOKUP;
cn.cn_cred = nd->nd_cred; cn.cn_lkflags = LK_SHARED | LK_RETRY;
cn.cn_thread = p; cn.cn_cred = nd->nd_cred;
cn.cn_thread = p;
} else if (r == 0)
vput(nvp);
}
/* /*
* Save this position, in case there is an error before one entry * Save this position, in case there is an error before one entry
@ -2099,7 +2107,16 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram,
else else
r = EOPNOTSUPP; r = EOPNOTSUPP;
if (r == EOPNOTSUPP) { if (r == EOPNOTSUPP) {
usevget = 0; if (usevget) {
usevget = 0;
cn.cn_nameiop = LOOKUP;
cn.cn_lkflags =
LK_SHARED |
LK_RETRY;
cn.cn_cred =
nd->nd_cred;
cn.cn_thread = p;
}
cn.cn_nameptr = dp->d_name; cn.cn_nameptr = dp->d_name;
cn.cn_namelen = nlen; cn.cn_namelen = nlen;
cn.cn_flags = ISLASTCN | cn.cn_flags = ISLASTCN |

View File

@ -197,6 +197,11 @@ fpathconf
## Allow various file descriptor-based I/O operations, subject to capability ## Allow various file descriptor-based I/O operations, subject to capability
## rights. ## rights.
## ##
freebsd11_fstat
freebsd11_fstatat
freebsd11_getdirentries
freebsd11_fstatfs
freebsd11_mknodat
freebsd6_ftruncate freebsd6_ftruncate
freebsd6_lseek freebsd6_lseek
freebsd6_mmap freebsd6_mmap

View File

@ -96,6 +96,11 @@ __FBSDID("$FreeBSD$");
#include <security/mac/mac_framework.h> #include <security/mac/mac_framework.h>
_Static_assert(sizeof(struct acctv3) - offsetof(struct acctv3, ac_trailer) ==
sizeof(struct acctv2) - offsetof(struct acctv2, ac_trailer), "trailer");
_Static_assert(sizeof(struct acctv3) - offsetof(struct acctv3, ac_len2) ==
sizeof(struct acctv2) - offsetof(struct acctv2, ac_len2), "len2");
/* /*
* The routines implemented in this file are described in: * The routines implemented in this file are described in:
* Leffler, et al.: The Design and Implementation of the 4.3BSD * Leffler, et al.: The Design and Implementation of the 4.3BSD
@ -339,7 +344,7 @@ acct_disable(struct thread *td, int logging)
int int
acct_process(struct thread *td) acct_process(struct thread *td)
{ {
struct acctv2 acct; struct acctv3 acct;
struct timeval ut, st, tmp; struct timeval ut, st, tmp;
struct plimit *oldlim; struct plimit *oldlim;
struct proc *p; struct proc *p;
@ -421,7 +426,7 @@ acct_process(struct thread *td)
/* Setup ancillary structure fields. */ /* Setup ancillary structure fields. */
acct.ac_flagx |= ANVER; acct.ac_flagx |= ANVER;
acct.ac_zero = 0; acct.ac_zero = 0;
acct.ac_version = 2; acct.ac_version = 3;
acct.ac_len = acct.ac_len2 = sizeof(acct); acct.ac_len = acct.ac_len2 = sizeof(acct);
/* /*

View File

@ -1304,6 +1304,23 @@ ofstat(struct thread *td, struct ofstat_args *uap)
} }
#endif /* COMPAT_43 */ #endif /* COMPAT_43 */
#if defined(COMPAT_FREEBSD11)
int
freebsd11_fstat(struct thread *td, struct freebsd11_fstat_args *uap)
{
struct stat sb;
struct freebsd11_stat osb;
int error;
error = kern_fstat(td, uap->fd, &sb);
if (error != 0)
return (error);
freebsd11_cvtstat(&sb, &osb);
error = copyout(&osb, uap->sb, sizeof(osb));
return (error);
}
#endif /* COMPAT_FREEBSD11 */
/* /*
* Return status information about a file descriptor. * Return status information about a file descriptor.
*/ */
@ -1343,6 +1360,14 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp)
error = fo_stat(fp, sbp, td->td_ucred, td); error = fo_stat(fp, sbp, td->td_ucred, td);
fdrop(fp, td); fdrop(fp, td);
#ifdef __STAT_TIME_T_EXT
if (error == 0) {
sbp->st_atim_ext = 0;
sbp->st_mtim_ext = 0;
sbp->st_ctim_ext = 0;
sbp->st_btim_ext = 0;
}
#endif
#ifdef KTRACE #ifdef KTRACE
if (error == 0 && KTRPOINT(td, KTR_STRUCT)) if (error == 0 && KTRPOINT(td, KTR_STRUCT))
ktrstat(sbp); ktrstat(sbp);
@ -1350,18 +1375,19 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp)
return (error); return (error);
} }
#if defined(COMPAT_FREEBSD11)
/* /*
* Return status information about a file descriptor. * Return status information about a file descriptor.
*/ */
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct nfstat_args { struct freebsd11_nfstat_args {
int fd; int fd;
struct nstat *sb; struct nstat *sb;
}; };
#endif #endif
/* ARGSUSED */ /* ARGSUSED */
int int
sys_nfstat(struct thread *td, struct nfstat_args *uap) freebsd11_nfstat(struct thread *td, struct freebsd11_nfstat_args *uap)
{ {
struct nstat nub; struct nstat nub;
struct stat ub; struct stat ub;
@ -1369,11 +1395,12 @@ sys_nfstat(struct thread *td, struct nfstat_args *uap)
error = kern_fstat(td, uap->fd, &ub); error = kern_fstat(td, uap->fd, &ub);
if (error == 0) { if (error == 0) {
cvtnstat(&ub, &nub); freebsd11_cvtnstat(&ub, &nub);
error = copyout(&nub, uap->sb, sizeof(nub)); error = copyout(&nub, uap->sb, sizeof(nub));
} }
return (error); return (error);
} }
#endif /* COMPAT_FREEBSD11 */
/* /*
* Return pathconf information about a file descriptor. * Return pathconf information about a file descriptor.
@ -3590,13 +3617,21 @@ kinfo_to_okinfo(struct kinfo_file *kif, struct kinfo_ofile *okif)
KF_FLAG_APPEND | KF_FLAG_ASYNC | KF_FLAG_FSYNC | KF_FLAG_NONBLOCK | KF_FLAG_APPEND | KF_FLAG_ASYNC | KF_FLAG_FSYNC | KF_FLAG_NONBLOCK |
KF_FLAG_DIRECT | KF_FLAG_HASLOCK); KF_FLAG_DIRECT | KF_FLAG_HASLOCK);
okif->kf_offset = kif->kf_offset; okif->kf_offset = kif->kf_offset;
okif->kf_vnode_type = kif->kf_vnode_type; if (kif->kf_type == KF_TYPE_VNODE)
okif->kf_sock_domain = kif->kf_sock_domain; okif->kf_vnode_type = kif->kf_un.kf_file.kf_file_type;
okif->kf_sock_type = kif->kf_sock_type; else
okif->kf_sock_protocol = kif->kf_sock_protocol; okif->kf_vnode_type = KF_VTYPE_VNON;
strlcpy(okif->kf_path, kif->kf_path, sizeof(okif->kf_path)); strlcpy(okif->kf_path, kif->kf_path, sizeof(okif->kf_path));
okif->kf_sa_local = kif->kf_sa_local; if (kif->kf_type == KF_TYPE_SOCKET) {
okif->kf_sa_peer = kif->kf_sa_peer; okif->kf_sock_domain = kif->kf_un.kf_sock.kf_sock_domain0;
okif->kf_sock_type = kif->kf_un.kf_sock.kf_sock_type0;
okif->kf_sock_protocol = kif->kf_un.kf_sock.kf_sock_protocol0;
okif->kf_sa_local = kif->kf_un.kf_sock.kf_sa_local;
okif->kf_sa_peer = kif->kf_un.kf_sock.kf_sa_peer;
} else {
okif->kf_sa_local.ss_family = AF_UNSPEC;
okif->kf_sa_peer.ss_family = AF_UNSPEC;
}
} }
static int static int

View File

@ -986,11 +986,14 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp)
} }
if ((p->p_flag & P_CONTROLT) && tp != NULL) { if ((p->p_flag & P_CONTROLT) && tp != NULL) {
kp->ki_tdev = tty_udev(tp); kp->ki_tdev = tty_udev(tp);
kp->ki_tdev_freebsd11 = kp->ki_tdev; /* truncate */
kp->ki_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID; kp->ki_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
if (tp->t_session) if (tp->t_session)
kp->ki_tsid = tp->t_session->s_sid; kp->ki_tsid = tp->t_session->s_sid;
} else } else {
kp->ki_tdev = NODEV; kp->ki_tdev = NODEV;
kp->ki_tdev_freebsd11 = kp->ki_tdev; /* truncate */
}
if (p->p_comm[0] != '\0') if (p->p_comm[0] != '\0')
strlcpy(kp->ki_comm, p->p_comm, sizeof(kp->ki_comm)); strlcpy(kp->ki_comm, p->p_comm, sizeof(kp->ki_comm));
if (p->p_sysent && p->p_sysent->sv_name != NULL && if (p->p_sysent && p->p_sysent->sv_name != NULL &&
@ -1232,6 +1235,7 @@ freebsd32_kinfo_proc_out(const struct kinfo_proc *ki, struct kinfo_proc32 *ki32)
CP(*ki, *ki32, ki_tsid); CP(*ki, *ki32, ki_tsid);
CP(*ki, *ki32, ki_jobc); CP(*ki, *ki32, ki_jobc);
CP(*ki, *ki32, ki_tdev); CP(*ki, *ki32, ki_tdev);
CP(*ki, *ki32, ki_tdev_freebsd11);
CP(*ki, *ki32, ki_siglist); CP(*ki, *ki32, ki_siglist);
CP(*ki, *ki32, ki_sigmask); CP(*ki, *ki32, ki_sigmask);
CP(*ki, *ki32, ki_sigignore); CP(*ki, *ki32, ki_sigignore);
@ -2204,6 +2208,7 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
vn_lock(vp, LK_SHARED | LK_RETRY); vn_lock(vp, LK_SHARED | LK_RETRY);
if (VOP_GETATTR(vp, &va, cred) == 0) { if (VOP_GETATTR(vp, &va, cred) == 0) {
kve->kve_fileid = va.va_fileid; kve->kve_fileid = va.va_fileid;
/* truncate */
kve->kve_fsid = va.va_fsid; kve->kve_fsid = va.va_fsid;
} }
vput(vp); vput(vp);
@ -2443,10 +2448,14 @@ kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags)
if (VOP_GETATTR(vp, &va, cred) == 0) { if (VOP_GETATTR(vp, &va, cred) == 0) {
kve->kve_vn_fileid = va.va_fileid; kve->kve_vn_fileid = va.va_fileid;
kve->kve_vn_fsid = va.va_fsid; kve->kve_vn_fsid = va.va_fsid;
kve->kve_vn_fsid_freebsd11 =
kve->kve_vn_fsid; /* truncate */
kve->kve_vn_mode = kve->kve_vn_mode =
MAKEIMODE(va.va_type, va.va_mode); MAKEIMODE(va.va_type, va.va_mode);
kve->kve_vn_size = va.va_size; kve->kve_vn_size = va.va_size;
kve->kve_vn_rdev = va.va_rdev; kve->kve_vn_rdev = va.va_rdev;
kve->kve_vn_rdev_freebsd11 =
kve->kve_vn_rdev; /* truncate */
kve->kve_status = KF_ATTR_VALID; kve->kve_status = KF_ATTR_VALID;
} }
vput(vp); vput(vp);

View File

@ -10,6 +10,7 @@ compat4=COMPAT_FREEBSD4
compat6=COMPAT_FREEBSD6 compat6=COMPAT_FREEBSD6
compat7=COMPAT_FREEBSD7 compat7=COMPAT_FREEBSD7
compat10=COMPAT_FREEBSD10 compat10=COMPAT_FREEBSD10
compat11=COMPAT_FREEBSD11
# output files: # output files:
sysnames="syscalls.c" sysnames="syscalls.c"
@ -36,6 +37,8 @@ syscompat7="sysent.compat7.$$"
syscompat7dcl="sysent.compat7dcl.$$" syscompat7dcl="sysent.compat7dcl.$$"
syscompat10="sysent.compat10.$$" syscompat10="sysent.compat10.$$"
syscompat10dcl="sysent.compat10dcl.$$" syscompat10dcl="sysent.compat10dcl.$$"
syscompat11="sysent.compat11.$$"
syscompat11dcl="sysent.compat11dcl.$$"
sysent="sysent.switch.$$" sysent="sysent.switch.$$"
sysinc="sysinc.switch.$$" sysinc="sysinc.switch.$$"
sysarg="sysarg.switch.$$" sysarg="sysarg.switch.$$"
@ -50,9 +53,9 @@ else
capenabled="" capenabled=""
fi fi
trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0 trap "rm $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret" 0
touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret touch $sysaue $sysdcl $syscompat $syscompatdcl $syscompat4 $syscompat4dcl $syscompat6 $syscompat6dcl $syscompat7 $syscompat7dcl $syscompat10 $syscompat10dcl $syscompat11 $syscompat11dcl $sysent $sysinc $sysarg $sysprotoend $systracetmp $systraceret
case $# in case $# in
0) echo "usage: $0 input-file <config-file>" 1>&2 0) echo "usage: $0 input-file <config-file>" 1>&2
@ -92,6 +95,8 @@ sed -e '
syscompat7dcl = \"$syscompat7dcl\" syscompat7dcl = \"$syscompat7dcl\"
syscompat10 = \"$syscompat10\" syscompat10 = \"$syscompat10\"
syscompat10dcl = \"$syscompat10dcl\" syscompat10dcl = \"$syscompat10dcl\"
syscompat11 = \"$syscompat11\"
syscompat11dcl = \"$syscompat11dcl\"
sysent = \"$sysent\" sysent = \"$sysent\"
syssw = \"$syssw\" syssw = \"$syssw\"
sysinc = \"$sysinc\" sysinc = \"$sysinc\"
@ -107,6 +112,7 @@ sed -e '
compat6 = \"$compat6\" compat6 = \"$compat6\"
compat7 = \"$compat7\" compat7 = \"$compat7\"
compat10 = \"$compat10\" compat10 = \"$compat10\"
compat11 = \"$compat11\"
syscallprefix = \"$syscallprefix\" syscallprefix = \"$syscallprefix\"
switchname = \"$switchname\" switchname = \"$switchname\"
namesname = \"$namesname\" namesname = \"$namesname\"
@ -155,6 +161,7 @@ sed -e '
printf "\n#ifdef %s\n\n", compat6 > syscompat6 printf "\n#ifdef %s\n\n", compat6 > syscompat6
printf "\n#ifdef %s\n\n", compat7 > syscompat7 printf "\n#ifdef %s\n\n", compat7 > syscompat7
printf "\n#ifdef %s\n\n", compat10 > syscompat10 printf "\n#ifdef %s\n\n", compat10 > syscompat10
printf "\n#ifdef %s\n\n", compat11 > syscompat11
printf "/*\n * System call names.\n *\n" > sysnames printf "/*\n * System call names.\n *\n" > sysnames
printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
@ -205,6 +212,7 @@ sed -e '
print > syscompat6 print > syscompat6
print > syscompat7 print > syscompat7
print > syscompat10 print > syscompat10
print > syscompat11
print > sysnames print > sysnames
print > systrace print > systrace
print > systracetmp print > systracetmp
@ -221,6 +229,7 @@ sed -e '
print > syscompat6 print > syscompat6
print > syscompat7 print > syscompat7
print > syscompat10 print > syscompat10
print > syscompat11
print > sysnames print > sysnames
print > systrace print > systrace
print > systracetmp print > systracetmp
@ -237,6 +246,7 @@ sed -e '
print > syscompat6 print > syscompat6
print > syscompat7 print > syscompat7
print > syscompat10 print > syscompat10
print > syscompat11
print > sysnames print > sysnames
print > systrace print > systrace
print > systracetmp print > systracetmp
@ -345,6 +355,8 @@ sed -e '
argalias = "freebsd7_" argalias argalias = "freebsd7_" argalias
if (flag("COMPAT10")) if (flag("COMPAT10"))
argalias = "freebsd10_" argalias argalias = "freebsd10_" argalias
if (flag("COMPAT11"))
argalias = "freebsd11_" argalias
} }
f++ f++
@ -497,7 +509,7 @@ sed -e '
next next
} }
type("COMPAT") || type("COMPAT4") || type("COMPAT6") || \ type("COMPAT") || type("COMPAT4") || type("COMPAT6") || \
type("COMPAT7") || type("COMPAT10") { type("COMPAT7") || type("COMPAT10") || type("COMPAT11") {
if (flag("COMPAT")) { if (flag("COMPAT")) {
ncompat++ ncompat++
out = syscompat out = syscompat
@ -533,6 +545,13 @@ sed -e '
wrap = "compat10" wrap = "compat10"
prefix = "freebsd10_" prefix = "freebsd10_"
descr = "freebsd10" descr = "freebsd10"
} else if (flag("COMPAT11")) {
ncompat11++
out = syscompat11
outdcl = syscompat11dcl
wrap = "compat11"
prefix = "freebsd11_"
descr = "freebsd11"
} }
parseline() parseline()
if (argc != 0 && !flag("NOARGS") && !flag("NOPROTO") && \ if (argc != 0 && !flag("NOARGS") && !flag("NOPROTO") && \
@ -608,7 +627,7 @@ sed -e '
END { END {
printf "\n#define AS(name) (sizeof(struct name) / sizeof(register_t))\n" > sysinc printf "\n#define AS(name) (sizeof(struct name) / sizeof(register_t))\n" > sysinc
if (ncompat != 0 || ncompat4 != 0 || ncompat6 != 0 || ncompat7 != 0 || ncompat10 != 0) if (ncompat != 0 || ncompat4 != 0 || ncompat6 != 0 || ncompat7 != 0 || ncompat10 != 0 || ncompat11 != 0)
printf "#include \"opt_compat.h\"\n\n" > syssw printf "#include \"opt_compat.h\"\n\n" > syssw
if (ncompat != 0) { if (ncompat != 0) {
@ -649,11 +668,20 @@ sed -e '
printf "#define compat10(n, name) 0, (sy_call_t *)nosys\n" > sysinc printf "#define compat10(n, name) 0, (sy_call_t *)nosys\n" > sysinc
printf "#endif\n" > sysinc printf "#endif\n" > sysinc
} }
if (ncompat11 != 0) {
printf "\n#ifdef %s\n", compat11 > sysinc
printf "#define compat11(n, name) n, (sy_call_t *)__CONCAT(freebsd11_,name)\n" > sysinc
printf "#else\n" > sysinc
printf "#define compat11(n, name) 0, (sy_call_t *)nosys\n" > sysinc
printf "#endif\n" > sysinc
}
printf("\n#endif /* %s */\n\n", compat) > syscompatdcl printf("\n#endif /* %s */\n\n", compat) > syscompatdcl
printf("\n#endif /* %s */\n\n", compat4) > syscompat4dcl printf("\n#endif /* %s */\n\n", compat4) > syscompat4dcl
printf("\n#endif /* %s */\n\n", compat6) > syscompat6dcl printf("\n#endif /* %s */\n\n", compat6) > syscompat6dcl
printf("\n#endif /* %s */\n\n", compat7) > syscompat7dcl printf("\n#endif /* %s */\n\n", compat7) > syscompat7dcl
printf("\n#endif /* %s */\n\n", compat10) > syscompat10dcl printf("\n#endif /* %s */\n\n", compat10) > syscompat10dcl
printf("\n#endif /* %s */\n\n", compat11) > syscompat11dcl
printf("\n#undef PAD_\n") > sysprotoend printf("\n#undef PAD_\n") > sysprotoend
printf("#undef PADL_\n") > sysprotoend printf("#undef PADL_\n") > sysprotoend
@ -677,6 +705,7 @@ cat $sysarg $sysdcl \
$syscompat6 $syscompat6dcl \ $syscompat6 $syscompat6dcl \
$syscompat7 $syscompat7dcl \ $syscompat7 $syscompat7dcl \
$syscompat10 $syscompat10dcl \ $syscompat10 $syscompat10dcl \
$syscompat11 $syscompat11dcl \
$sysaue $sysprotoend > $sysproto $sysaue $sysprotoend > $sysproto
cat $systracetmp >> $systrace cat $systracetmp >> $systrace
cat $systraceret >> $systrace cat $systraceret >> $systrace

View File

@ -346,14 +346,15 @@ soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
kif->kf_type = KF_TYPE_SOCKET; kif->kf_type = KF_TYPE_SOCKET;
so = fp->f_data; so = fp->f_data;
kif->kf_sock_domain = so->so_proto->pr_domain->dom_family; kif->kf_un.kf_sock.kf_sock_domain0 =
kif->kf_sock_type = so->so_type; so->so_proto->pr_domain->dom_family;
kif->kf_sock_protocol = so->so_proto->pr_protocol; kif->kf_un.kf_sock.kf_sock_type0 = so->so_type;
kif->kf_un.kf_sock.kf_sock_protocol0 = so->so_proto->pr_protocol;
kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb; kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb;
switch (kif->kf_sock_domain) { switch (kif->kf_un.kf_sock.kf_sock_domain0) {
case AF_INET: case AF_INET:
case AF_INET6: case AF_INET6:
if (kif->kf_sock_protocol == IPPROTO_TCP) { if (kif->kf_un.kf_sock.kf_sock_protocol0 == IPPROTO_TCP) {
if (so->so_pcb != NULL) { if (so->so_pcb != NULL) {
inpcb = (struct inpcb *)(so->so_pcb); inpcb = (struct inpcb *)(so->so_pcb);
kif->kf_un.kf_sock.kf_sock_inpcb = kif->kf_un.kf_sock.kf_sock_inpcb =
@ -376,13 +377,15 @@ soo_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
break; break;
} }
error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa); error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_local)) { if (error == 0 &&
bcopy(sa, &kif->kf_sa_local, sa->sa_len); sa->sa_len <= sizeof(kif->kf_un.kf_sock.kf_sa_local)) {
bcopy(sa, &kif->kf_un.kf_sock.kf_sa_local, sa->sa_len);
free(sa, M_SONAME); free(sa, M_SONAME);
} }
error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa); error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa);
if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_peer)) { if (error == 0 &&
bcopy(sa, &kif->kf_sa_peer, sa->sa_len); sa->sa_len <= sizeof(kif->kf_un.kf_sock.kf_sa_peer)) {
bcopy(sa, &kif->kf_un.kf_sock.kf_sa_peer, sa->sa_len);
free(sa, M_SONAME); free(sa, M_SONAME);
} }
strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name, strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name,

View File

@ -12,7 +12,7 @@
; case where the event exists, but we don't want auditing, the ; case where the event exists, but we don't want auditing, the
; event should be #defined to AUE_NULL in audit_kevents.h. ; event should be #defined to AUE_NULL in audit_kevents.h.
; type one of STD, OBSOL, UNIMPL, COMPAT, COMPAT4, COMPAT6, ; type one of STD, OBSOL, UNIMPL, COMPAT, COMPAT4, COMPAT6,
; COMPAT7, NODEF, NOARGS, NOPROTO, NOSTD ; COMPAT7, COMPAT11, NODEF, NOARGS, NOPROTO, NOSTD
; The COMPAT* options may be combined with one or more NO* ; The COMPAT* options may be combined with one or more NO*
; options separated by '|' with no spaces (e.g. COMPAT|NOARGS) ; options separated by '|' with no spaces (e.g. COMPAT|NOARGS)
; name psuedo-prototype of syscall routine ; name psuedo-prototype of syscall routine
@ -29,6 +29,7 @@
; COMPAT6 included on COMPAT_FREEBSD6 #ifdef (FreeBSD 6 compat) ; COMPAT6 included on COMPAT_FREEBSD6 #ifdef (FreeBSD 6 compat)
; COMPAT7 included on COMPAT_FREEBSD7 #ifdef (FreeBSD 7 compat) ; COMPAT7 included on COMPAT_FREEBSD7 #ifdef (FreeBSD 7 compat)
; COMPAT10 included on COMPAT_FREEBSD10 #ifdef (FreeBSD 10 compat) ; COMPAT10 included on COMPAT_FREEBSD10 #ifdef (FreeBSD 10 compat)
; COMPAT11 included on COMPAT11 #ifdef (FreeBSD 11 compat)
; OBSOL obsolete, not included in system, only specifies name ; OBSOL obsolete, not included in system, only specifies name
; UNIMPL not implemented, placeholder only ; UNIMPL not implemented, placeholder only
; NOSTD implemented but as a lkm that can be statically ; NOSTD implemented but as a lkm that can be statically
@ -79,7 +80,7 @@
11 AUE_NULL OBSOL execv 11 AUE_NULL OBSOL execv
12 AUE_CHDIR STD { int chdir(char *path); } 12 AUE_CHDIR STD { int chdir(char *path); }
13 AUE_FCHDIR STD { int fchdir(int fd); } 13 AUE_FCHDIR STD { int fchdir(int fd); }
14 AUE_MKNOD STD { int mknod(char *path, int mode, int dev); } 14 AUE_MKNOD COMPAT11 { int mknod(char *path, int mode, int dev); }
15 AUE_CHMOD STD { int chmod(char *path, int mode); } 15 AUE_CHMOD STD { int chmod(char *path, int mode); }
16 AUE_CHOWN STD { int chown(char *path, int uid, int gid); } 16 AUE_CHOWN STD { int chown(char *path, int uid, int gid); }
17 AUE_NULL STD { int obreak(char *nsize); } break \ 17 AUE_NULL STD { int obreak(char *nsize); } break \
@ -363,9 +364,12 @@
185 AUE_NULL UNIMPL lfs_markv 185 AUE_NULL UNIMPL lfs_markv
186 AUE_NULL UNIMPL lfs_segclean 186 AUE_NULL UNIMPL lfs_segclean
187 AUE_NULL UNIMPL lfs_segwait 187 AUE_NULL UNIMPL lfs_segwait
188 AUE_STAT STD { int stat(char *path, struct stat *ub); } 188 AUE_STAT COMPAT11 { int stat(char *path, \
189 AUE_FSTAT STD { int fstat(int fd, struct stat *sb); } struct freebsd11_stat *ub); }
190 AUE_LSTAT STD { int lstat(char *path, struct stat *ub); } 189 AUE_FSTAT COMPAT11 { int fstat(int fd, \
struct freebsd11_stat *sb); }
190 AUE_LSTAT COMPAT11 { int lstat(char *path, \
struct freebsd11_stat *ub); }
191 AUE_PATHCONF STD { int pathconf(char *path, int name); } 191 AUE_PATHCONF STD { int pathconf(char *path, int name); }
192 AUE_FPATHCONF STD { int fpathconf(int fd, int name); } 192 AUE_FPATHCONF STD { int fpathconf(int fd, int name); }
193 AUE_NULL UNIMPL nosys 193 AUE_NULL UNIMPL nosys
@ -375,7 +379,7 @@
195 AUE_SETRLIMIT STD { int setrlimit(u_int which, \ 195 AUE_SETRLIMIT STD { int setrlimit(u_int which, \
struct rlimit *rlp); } setrlimit \ struct rlimit *rlp); } setrlimit \
__setrlimit_args int __setrlimit_args int
196 AUE_GETDIRENTRIES STD { int getdirentries(int fd, char *buf, \ 196 AUE_GETDIRENTRIES COMPAT11 { int getdirentries(int fd, char *buf, \
u_int count, long *basep); } u_int count, long *basep); }
197 AUE_MMAP COMPAT6 { caddr_t mmap(caddr_t addr, \ 197 AUE_MMAP COMPAT6 { caddr_t mmap(caddr_t addr, \
size_t len, int prot, int flags, int fd, \ size_t len, int prot, int flags, int fd, \
@ -496,7 +500,7 @@
269 AUE_NULL UNIMPL nosys 269 AUE_NULL UNIMPL nosys
270 AUE_NULL UNIMPL nosys 270 AUE_NULL UNIMPL nosys
271 AUE_NULL UNIMPL nosys 271 AUE_NULL UNIMPL nosys
272 AUE_O_GETDENTS STD { int getdents(int fd, char *buf, \ 272 AUE_O_GETDENTS COMPAT11 { int getdents(int fd, char *buf, \
size_t count); } size_t count); }
273 AUE_NULL UNIMPL nosys 273 AUE_NULL UNIMPL nosys
274 AUE_LCHMOD STD { int lchmod(char *path, mode_t mode); } 274 AUE_LCHMOD STD { int lchmod(char *path, mode_t mode); }
@ -507,9 +511,9 @@
struct timeval *tptr); } struct timeval *tptr); }
277 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \ 277 AUE_MSYNC NOPROTO { int msync(void *addr, size_t len, \
int flags); } netbsd_msync msync_args int int flags); } netbsd_msync msync_args int
278 AUE_STAT STD { int nstat(char *path, struct nstat *ub); } 278 AUE_STAT COMPAT11 { int nstat(char *path, struct nstat *ub); }
279 AUE_FSTAT STD { int nfstat(int fd, struct nstat *sb); } 279 AUE_FSTAT COMPAT11 { int nfstat(int fd, struct nstat *sb); }
280 AUE_LSTAT STD { int nlstat(char *path, struct nstat *ub); } 280 AUE_LSTAT COMPAT11 { int nlstat(char *path, struct nstat *ub); }
281 AUE_NULL UNIMPL nosys 281 AUE_NULL UNIMPL nosys
282 AUE_NULL UNIMPL nosys 282 AUE_NULL UNIMPL nosys
283 AUE_NULL UNIMPL nosys 283 AUE_NULL UNIMPL nosys
@ -535,8 +539,8 @@
struct ostatfs *buf); } struct ostatfs *buf); }
298 AUE_FHOPEN STD { int fhopen(const struct fhandle *u_fhp, \ 298 AUE_FHOPEN STD { int fhopen(const struct fhandle *u_fhp, \
int flags); } int flags); }
299 AUE_FHSTAT STD { int fhstat(const struct fhandle *u_fhp, \ 299 AUE_FHSTAT COMPAT11 { int fhstat(const struct fhandle *u_fhp, \
struct stat *sb); } struct freebsd11_stat *sb); }
; syscall numbers for FreeBSD ; syscall numbers for FreeBSD
300 AUE_NULL STD { int modnext(int modid); } 300 AUE_NULL STD { int modnext(int modid); }
301 AUE_NULL STD { int modstat(int modid, \ 301 AUE_NULL STD { int modstat(int modid, \
@ -707,13 +711,14 @@
off_t *sbytes, int flags); } off_t *sbytes, int flags); }
394 AUE_NULL STD { int mac_syscall(const char *policy, \ 394 AUE_NULL STD { int mac_syscall(const char *policy, \
int call, void *arg); } int call, void *arg); }
395 AUE_GETFSSTAT STD { int getfsstat(struct statfs *buf, \ 395 AUE_GETFSSTAT COMPAT11 { int getfsstat(struct freebsd11_statfs *buf, \
long bufsize, int mode); } long bufsize, int mode); }
396 AUE_STATFS STD { int statfs(char *path, \ 396 AUE_STATFS COMPAT11 { int statfs(char *path, \
struct statfs *buf); } struct freebsd11_statfs *buf); }
397 AUE_FSTATFS STD { int fstatfs(int fd, struct statfs *buf); } 397 AUE_FSTATFS COMPAT11 { int fstatfs(int fd, \
398 AUE_FHSTATFS STD { int fhstatfs(const struct fhandle *u_fhp, \ struct freebsd11_statfs *buf); }
struct statfs *buf); } 398 AUE_FHSTATFS COMPAT11 { int fhstatfs(const struct fhandle *u_fhp, \
struct freebsd11_statfs *buf); }
399 AUE_NULL UNIMPL nosys 399 AUE_NULL UNIMPL nosys
400 AUE_SEMCLOSE NOSTD { int ksem_close(semid_t id); } 400 AUE_SEMCLOSE NOSTD { int ksem_close(semid_t id); }
401 AUE_SEMPOST NOSTD { int ksem_post(semid_t id); } 401 AUE_SEMPOST NOSTD { int ksem_post(semid_t id); }
@ -883,16 +888,16 @@
gid_t gid, int flag); } gid_t gid, int flag); }
492 AUE_FEXECVE STD { int fexecve(int fd, char **argv, \ 492 AUE_FEXECVE STD { int fexecve(int fd, char **argv, \
char **envv); } char **envv); }
493 AUE_FSTATAT STD { int fstatat(int fd, char *path, \ 493 AUE_FSTATAT COMPAT11 { int fstatat(int fd, char *path, \
struct stat *buf, int flag); } struct freebsd11_stat *buf, int flag); }
494 AUE_FUTIMESAT STD { int futimesat(int fd, char *path, \ 494 AUE_FUTIMESAT STD { int futimesat(int fd, char *path, \
struct timeval *times); } struct timeval *times); }
495 AUE_LINKAT STD { int linkat(int fd1, char *path1, int fd2, \ 495 AUE_LINKAT STD { int linkat(int fd1, char *path1, int fd2, \
char *path2, int flag); } char *path2, int flag); }
496 AUE_MKDIRAT STD { int mkdirat(int fd, char *path, mode_t mode); } 496 AUE_MKDIRAT STD { int mkdirat(int fd, char *path, mode_t mode); }
497 AUE_MKFIFOAT STD { int mkfifoat(int fd, char *path, mode_t mode); } 497 AUE_MKFIFOAT STD { int mkfifoat(int fd, char *path, mode_t mode); }
498 AUE_MKNODAT STD { int mknodat(int fd, char *path, mode_t mode, \ 498 AUE_MKNODAT COMPAT11 { int mknodat(int fd, char *path, mode_t mode, \
dev_t dev); } uint32_t dev); }
; XXX: see the comment for open ; XXX: see the comment for open
499 AUE_OPENAT_RWTC STD { int openat(int fd, char *path, int flag, \ 499 AUE_OPENAT_RWTC STD { int openat(int fd, char *path, int flag, \
mode_t mode); } mode_t mode); }
@ -997,6 +1002,21 @@
id_t id, const struct \ id_t id, const struct \
vm_domain_policy_entry *policy); } vm_domain_policy_entry *policy); }
550 AUE_FSYNC STD { int fdatasync(int fd); } 550 AUE_FSYNC STD { int fdatasync(int fd); }
551 AUE_FSTAT STD { int fstat(int fd, struct stat *sb); }
552 AUE_FSTATAT STD { int fstatat(int fd, char *path, \
struct stat *buf, int flag); }
553 AUE_FHSTAT STD { int fhstat(const struct fhandle *u_fhp, \
struct stat *sb); }
554 AUE_GETDIRENTRIES STD { ssize_t getdirentries(int fd, char *buf, \
size_t count, off_t *basep); }
555 AUE_STATFS STD { int statfs(char *path, struct statfs *buf); }
556 AUE_FSTATFS STD { int fstatfs(int fd, struct statfs *buf); }
557 AUE_GETFSSTAT STD { int getfsstat(struct statfs *buf, \
long bufsize, int mode); }
558 AUE_FHSTATFS STD { int fhstatfs(const struct fhandle *u_fhp, \
struct statfs *buf); }
559 AUE_MKNODAT STD { int mknodat(int fd, char *path, mode_t mode, \
dev_t dev); }
; Please copy any additions and changes to the following compatability tables: ; Please copy any additions and changes to the following compatability tables:
; sys/compat/freebsd32/syscalls.master ; sys/compat/freebsd32/syscalls.master

View File

@ -1205,7 +1205,7 @@ tty_to_xtty(struct tty *tp, struct xtty *xt)
xt->xt_pgid = tp->t_pgrp ? tp->t_pgrp->pg_id : 0; xt->xt_pgid = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;
xt->xt_sid = tp->t_session ? tp->t_session->s_sid : 0; xt->xt_sid = tp->t_session ? tp->t_session->s_sid : 0;
xt->xt_flags = tp->t_flags; xt->xt_flags = tp->t_flags;
xt->xt_dev = tp->t_dev ? dev2udev(tp->t_dev) : NODEV; xt->xt_dev = tp->t_dev ? dev2udev(tp->t_dev) : (uint32_t)NODEV;
} }
static int static int

View File

@ -592,6 +592,8 @@ ptsdev_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
kif->kf_type = KF_TYPE_PTS; kif->kf_type = KF_TYPE_PTS;
tp = fp->f_data; tp = fp->f_data;
kif->kf_un.kf_pts.kf_pts_dev = tty_udev(tp); kif->kf_un.kf_pts.kf_pts_dev = tty_udev(tp);
kif->kf_un.kf_pts.kf_pts_dev_freebsd11 =
kif->kf_un.kf_pts.kf_pts_dev; /* truncate */
strlcpy(kif->kf_path, tty_devname(tp), sizeof(kif->kf_path)); strlcpy(kif->kf_path, tty_devname(tp), sizeof(kif->kf_path));
return (0); return (0);
} }

View File

@ -525,7 +525,7 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
/* /*
* Get old format filesystem statistics. * Get old format filesystem statistics.
*/ */
static void cvtstatfs(struct statfs *, struct ostatfs *); static void freebsd4_cvtstatfs(struct statfs *, struct ostatfs *);
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct freebsd4_statfs_args { struct freebsd4_statfs_args {
@ -543,7 +543,7 @@ freebsd4_statfs(struct thread *td, struct freebsd4_statfs_args *uap)
sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
error = kern_statfs(td, uap->path, UIO_USERSPACE, sfp); error = kern_statfs(td, uap->path, UIO_USERSPACE, sfp);
if (error == 0) { if (error == 0) {
cvtstatfs(sfp, &osb); freebsd4_cvtstatfs(sfp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb)); error = copyout(&osb, uap->buf, sizeof(osb));
} }
free(sfp, M_STATFS); free(sfp, M_STATFS);
@ -569,7 +569,7 @@ freebsd4_fstatfs(struct thread *td, struct freebsd4_fstatfs_args *uap)
sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
error = kern_fstatfs(td, uap->fd, sfp); error = kern_fstatfs(td, uap->fd, sfp);
if (error == 0) { if (error == 0) {
cvtstatfs(sfp, &osb); freebsd4_cvtstatfs(sfp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb)); error = copyout(&osb, uap->buf, sizeof(osb));
} }
free(sfp, M_STATFS); free(sfp, M_STATFS);
@ -602,11 +602,12 @@ freebsd4_getfsstat(struct thread *td, struct freebsd4_getfsstat_args *uap)
size = count * sizeof(struct statfs); size = count * sizeof(struct statfs);
error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE, error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE,
uap->mode); uap->mode);
td->td_retval[0] = count; if (error == 0)
td->td_retval[0] = count;
if (size != 0) { if (size != 0) {
sp = buf; sp = buf;
while (count != 0 && error == 0) { while (count != 0 && error == 0) {
cvtstatfs(sp, &osb); freebsd4_cvtstatfs(sp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb)); error = copyout(&osb, uap->buf, sizeof(osb));
sp++; sp++;
uap->buf++; uap->buf++;
@ -640,7 +641,7 @@ freebsd4_fhstatfs(struct thread *td, struct freebsd4_fhstatfs_args *uap)
sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
error = kern_fhstatfs(td, fh, sfp); error = kern_fhstatfs(td, fh, sfp);
if (error == 0) { if (error == 0) {
cvtstatfs(sfp, &osb); freebsd4_cvtstatfs(sfp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb)); error = copyout(&osb, uap->buf, sizeof(osb));
} }
free(sfp, M_STATFS); free(sfp, M_STATFS);
@ -651,7 +652,7 @@ freebsd4_fhstatfs(struct thread *td, struct freebsd4_fhstatfs_args *uap)
* Convert a new format statfs structure to an old format statfs structure. * Convert a new format statfs structure to an old format statfs structure.
*/ */
static void static void
cvtstatfs(struct statfs *nsp, struct ostatfs *osp) freebsd4_cvtstatfs(struct statfs *nsp, struct ostatfs *osp)
{ {
statfs_scale_blocks(nsp, LONG_MAX); statfs_scale_blocks(nsp, LONG_MAX);
@ -680,6 +681,138 @@ cvtstatfs(struct statfs *nsp, struct ostatfs *osp)
} }
#endif /* COMPAT_FREEBSD4 */ #endif /* COMPAT_FREEBSD4 */
#if defined(COMPAT_FREEBSD11)
/*
* Get old format filesystem statistics.
*/
static void freebsd11_cvtstatfs(struct statfs *, struct freebsd11_statfs *);
int
freebsd11_statfs(struct thread *td, struct freebsd11_statfs_args *uap)
{
struct freebsd11_statfs osb;
struct statfs *sfp;
int error;
sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
error = kern_statfs(td, uap->path, UIO_USERSPACE, sfp);
if (error == 0) {
freebsd11_cvtstatfs(sfp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb));
}
free(sfp, M_STATFS);
return (error);
}
/*
* Get filesystem statistics.
*/
int
freebsd11_fstatfs(struct thread *td, struct freebsd11_fstatfs_args *uap)
{
struct freebsd11_statfs osb;
struct statfs *sfp;
int error;
sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
error = kern_fstatfs(td, uap->fd, sfp);
if (error == 0) {
freebsd11_cvtstatfs(sfp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb));
}
free(sfp, M_STATFS);
return (error);
}
/*
* Get statistics on all filesystems.
*/
int
freebsd11_getfsstat(struct thread *td, struct freebsd11_getfsstat_args *uap)
{
struct freebsd11_statfs osb;
struct statfs *buf, *sp;
size_t count, size;
int error;
count = uap->bufsize / sizeof(struct ostatfs);
size = count * sizeof(struct statfs);
error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE,
uap->mode);
if (error == 0)
td->td_retval[0] = count;
if (size > 0) {
sp = buf;
while (count > 0 && error == 0) {
freebsd11_cvtstatfs(sp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb));
sp++;
uap->buf++;
count--;
}
free(buf, M_STATFS);
}
return (error);
}
/*
* Implement fstatfs() for (NFS) file handles.
*/
int
freebsd11_fhstatfs(struct thread *td, struct freebsd11_fhstatfs_args *uap)
{
struct freebsd11_statfs osb;
struct statfs *sfp;
fhandle_t fh;
int error;
error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
if (error)
return (error);
sfp = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK);
error = kern_fhstatfs(td, fh, sfp);
if (error == 0) {
freebsd11_cvtstatfs(sfp, &osb);
error = copyout(&osb, uap->buf, sizeof(osb));
}
free(sfp, M_STATFS);
return (error);
}
/*
* Convert a new format statfs structure to an old format statfs structure.
*/
static void
freebsd11_cvtstatfs(struct statfs *nsp, struct freebsd11_statfs *osp)
{
bzero(osp, sizeof(*osp));
osp->f_version = FREEBSD11_STATFS_VERSION;
osp->f_type = nsp->f_type;
osp->f_flags = nsp->f_flags;
osp->f_bsize = nsp->f_bsize;
osp->f_iosize = nsp->f_iosize;
osp->f_blocks = nsp->f_blocks;
osp->f_bfree = nsp->f_bfree;
osp->f_bavail = nsp->f_bavail;
osp->f_files = nsp->f_files;
osp->f_ffree = nsp->f_ffree;
osp->f_syncwrites = nsp->f_syncwrites;
osp->f_asyncwrites = nsp->f_asyncwrites;
osp->f_syncreads = nsp->f_syncreads;
osp->f_asyncreads = nsp->f_asyncreads;
osp->f_namemax = nsp->f_namemax;
osp->f_owner = nsp->f_owner;
osp->f_fsid = nsp->f_fsid;
strlcpy(osp->f_fstypename, nsp->f_fstypename,
MIN(MFSNAMELEN, sizeof(osp->f_fstypename)));
strlcpy(osp->f_mntonname, nsp->f_mntonname,
MIN(MNAMELEN, sizeof(osp->f_mntonname)));
strlcpy(osp->f_mntfromname, nsp->f_mntfromname,
MIN(MNAMELEN, sizeof(osp->f_mntfromname)));
}
#endif /* COMPAT_FREEBSD11 */
/* /*
* Change current working directory to a given file descriptor. * Change current working directory to a given file descriptor.
*/ */
@ -1059,21 +1192,6 @@ ocreat(struct thread *td, struct ocreat_args *uap)
/* /*
* Create a special file. * Create a special file.
*/ */
#ifndef _SYS_SYSPROTO_H_
struct mknod_args {
char *path;
int mode;
int dev;
};
#endif
int
sys_mknod(struct thread *td, struct mknod_args *uap)
{
return (kern_mknodat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->mode, uap->dev));
}
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct mknodat_args { struct mknodat_args {
int fd; int fd;
@ -1090,9 +1208,29 @@ sys_mknodat(struct thread *td, struct mknodat_args *uap)
uap->dev)); uap->dev));
} }
#if defined(COMPAT_FREEBSD11)
int
freebsd11_mknod(struct thread *td,
struct freebsd11_mknod_args *uap)
{
return (kern_mknodat(td, AT_FDCWD, uap->path, UIO_USERSPACE,
uap->mode, uap->dev));
}
int
freebsd11_mknodat(struct thread *td,
struct freebsd11_mknodat_args *uap)
{
return (kern_mknodat(td, uap->fd, uap->path, UIO_USERSPACE, uap->mode,
uap->dev));
}
#endif /* COMPAT_FREEBSD11 */
int int
kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg, kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int mode, int dev) int mode, dev_t dev)
{ {
struct vnode *vp; struct vnode *vp;
struct mount *mp; struct mount *mp;
@ -1968,28 +2106,104 @@ cvtstat(struct stat *st, struct ostat *ost)
} }
#endif /* COMPAT_43 */ #endif /* COMPAT_43 */
/* #if defined(COMPAT_FREEBSD11)
* Get file status; this version follows links. void
*/ freebsd11_cvtstat(struct stat *st, struct freebsd11_stat *ost)
#ifndef _SYS_SYSPROTO_H_ {
struct stat_args {
char *path; ost->st_dev = st->st_dev;
struct stat *ub; ost->st_ino = st->st_ino; /* truncate */
}; ost->st_mode = st->st_mode;
#endif ost->st_nlink = st->st_nlink; /* truncate */
ost->st_uid = st->st_uid;
ost->st_gid = st->st_gid;
ost->st_rdev = st->st_rdev;
ost->st_atim = st->st_atim;
ost->st_mtim = st->st_mtim;
ost->st_ctim = st->st_ctim;
ost->st_size = st->st_size;
ost->st_blocks = st->st_blocks;
ost->st_blksize = st->st_blksize;
ost->st_flags = st->st_flags;
ost->st_gen = st->st_gen;
ost->st_lspare = 0;
ost->st_birthtim = st->st_birthtim;
bzero((char *)&ost->st_birthtim + sizeof(ost->st_birthtim),
sizeof(*ost) - offsetof(struct freebsd11_stat,
st_birthtim) - sizeof(ost->st_birthtim));
}
int int
sys_stat(struct thread *td, struct stat_args *uap) freebsd11_stat(struct thread *td, struct freebsd11_stat_args* uap)
{ {
struct stat sb; struct stat sb;
struct freebsd11_stat osb;
int error; int error;
error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE,
&sb, NULL); &sb, NULL);
if (error == 0) if (error != 0)
error = copyout(&sb, uap->ub, sizeof (sb)); return (error);
freebsd11_cvtstat(&sb, &osb);
error = copyout(&osb, uap->ub, sizeof(osb));
return (error); return (error);
} }
int
freebsd11_lstat(struct thread *td, struct freebsd11_lstat_args* uap)
{
struct stat sb;
struct freebsd11_stat osb;
int error;
error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path,
UIO_USERSPACE, &sb, NULL);
if (error != 0)
return (error);
freebsd11_cvtstat(&sb, &osb);
error = copyout(&osb, uap->ub, sizeof(osb));
return (error);
}
int
freebsd11_fhstat(struct thread *td, struct freebsd11_fhstat_args* uap)
{
struct fhandle fh;
struct stat sb;
struct freebsd11_stat osb;
int error;
error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t));
if (error != 0)
return (error);
error = kern_fhstat(td, fh, &sb);
if (error != 0)
return (error);
freebsd11_cvtstat(&sb, &osb);
error = copyout(&osb, uap->sb, sizeof(osb));
return (error);
}
int
freebsd11_fstatat(struct thread *td, struct freebsd11_fstatat_args* uap)
{
struct stat sb;
struct freebsd11_stat osb;
int error;
error = kern_statat(td, uap->flag, uap->fd, uap->path,
UIO_USERSPACE, &sb, NULL);
if (error != 0)
return (error);
freebsd11_cvtstat(&sb, &osb);
error = copyout(&osb, uap->buf, sizeof(osb));
return (error);
}
#endif /* COMPAT_FREEBSD11 */
/*
* Get file status
*/
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct fstatat_args { struct fstatat_args {
int fd; int fd;
@ -2042,6 +2256,12 @@ kern_statat(struct thread *td, int flag, int fd, char *path,
vput(nd.ni_vp); vput(nd.ni_vp);
if (error != 0) if (error != 0)
return (error); return (error);
#ifdef __STAT_TIME_T_EXT
sb.st_atim_ext = 0;
sb.st_mtim_ext = 0;
sb.st_ctim_ext = 0;
sb.st_btim_ext = 0;
#endif
*sbp = sb; *sbp = sb;
#ifdef KTRACE #ifdef KTRACE
if (KTRPOINT(td, KTR_STRUCT)) if (KTRPOINT(td, KTR_STRUCT))
@ -2050,36 +2270,15 @@ kern_statat(struct thread *td, int flag, int fd, char *path,
return (0); return (0);
} }
/* #if defined(COMPAT_FREEBSD11)
* Get file status; this version does not follow links.
*/
#ifndef _SYS_SYSPROTO_H_
struct lstat_args {
char *path;
struct stat *ub;
};
#endif
int
sys_lstat(struct thread *td, struct lstat_args *uap)
{
struct stat sb;
int error;
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);
}
/* /*
* Implementation of the NetBSD [l]stat() functions. * Implementation of the NetBSD [l]stat() functions.
*/ */
void void
cvtnstat( struct stat *sb, struct nstat *nsb) freebsd11_cvtnstat(struct stat *sb, struct nstat *nsb)
{ {
bzero(nsb, sizeof *nsb); bzero(nsb, sizeof(*nsb));
nsb->st_dev = sb->st_dev; nsb->st_dev = sb->st_dev;
nsb->st_ino = sb->st_ino; nsb->st_ino = sb->st_ino;
nsb->st_mode = sb->st_mode; nsb->st_mode = sb->st_mode;
@ -2099,13 +2298,13 @@ cvtnstat( struct stat *sb, struct nstat *nsb)
} }
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct nstat_args { struct freebsd11_nstat_args {
char *path; char *path;
struct nstat *ub; struct nstat *ub;
}; };
#endif #endif
int int
sys_nstat(struct thread *td, struct nstat_args *uap) freebsd11_nstat(struct thread *td, struct freebsd11_nstat_args *uap)
{ {
struct stat sb; struct stat sb;
struct nstat nsb; struct nstat nsb;
@ -2115,7 +2314,7 @@ sys_nstat(struct thread *td, struct nstat_args *uap)
&sb, NULL); &sb, NULL);
if (error != 0) if (error != 0)
return (error); return (error);
cvtnstat(&sb, &nsb); freebsd11_cvtnstat(&sb, &nsb);
return (copyout(&nsb, uap->ub, sizeof (nsb))); return (copyout(&nsb, uap->ub, sizeof (nsb)));
} }
@ -2123,13 +2322,13 @@ sys_nstat(struct thread *td, struct nstat_args *uap)
* NetBSD lstat. Get file status; this version does not follow links. * NetBSD lstat. Get file status; this version does not follow links.
*/ */
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct lstat_args { struct freebsd11_nlstat_args {
char *path; char *path;
struct stat *ub; struct nstat *ub;
}; };
#endif #endif
int int
sys_nlstat(struct thread *td, struct nlstat_args *uap) freebsd11_nlstat(struct thread *td, struct freebsd11_nlstat_args *uap)
{ {
struct stat sb; struct stat sb;
struct nstat nsb; struct nstat nsb;
@ -2139,9 +2338,10 @@ sys_nlstat(struct thread *td, struct nlstat_args *uap)
UIO_USERSPACE, &sb, NULL); UIO_USERSPACE, &sb, NULL);
if (error != 0) if (error != 0)
return (error); return (error);
cvtnstat(&sb, &nsb); freebsd11_cvtnstat(&sb, &nsb);
return (copyout(&nsb, uap->ub, sizeof (nsb))); return (copyout(&nsb, uap->ub, sizeof (nsb)));
} }
#endif /* COMPAT_FREEBSD11 */
/* /*
* Get configurable pathname variables. * Get configurable pathname variables.
@ -3502,7 +3702,87 @@ kern_rmdirat(struct thread *td, int fd, char *path, enum uio_seg pathseg)
return (error); return (error);
} }
#if defined(COMPAT_43) || defined(COMPAT_FREEBSD11)
int
freebsd11_kern_getdirentries(struct thread *td, int fd, char *ubuf, u_int count,
long *basep, void (*func)(struct freebsd11_dirent *))
{
struct freebsd11_dirent dstdp;
struct dirent *dp, *edp;
char *dirbuf;
off_t base;
ssize_t resid, ucount;
int error;
/* XXX arbitrary sanity limit on `count'. */
count = min(count, 64 * 1024);
dirbuf = malloc(count, M_TEMP, M_WAITOK);
error = kern_getdirentries(td, fd, dirbuf, count, &base, &resid,
UIO_SYSSPACE);
if (error != 0)
goto done;
if (basep != NULL)
*basep = base;
ucount = 0;
for (dp = (struct dirent *)dirbuf,
edp = (struct dirent *)&dirbuf[count - resid];
ucount < count && dp < edp; ) {
if (dp->d_reclen == 0)
break;
MPASS(dp->d_reclen >= _GENERIC_DIRLEN(0));
if (dp->d_namlen >= sizeof(dstdp.d_name))
continue;
dstdp.d_type = dp->d_type;
dstdp.d_namlen = dp->d_namlen;
dstdp.d_fileno = dp->d_fileno; /* truncate */
dstdp.d_reclen = sizeof(dstdp) - sizeof(dstdp.d_name) +
((dp->d_namlen + 1 + 3) &~ 3);
bcopy(dp->d_name, dstdp.d_name, dstdp.d_namlen);
bzero(dstdp.d_name + dstdp.d_namlen,
dstdp.d_reclen - offsetof(struct freebsd11_dirent, d_name) -
dstdp.d_namlen);
MPASS(dstdp.d_reclen <= dp->d_reclen);
MPASS(ucount + dstdp.d_reclen <= count);
if (func != NULL)
func(&dstdp);
error = copyout(&dstdp, ubuf + ucount, dstdp.d_reclen);
if (error != 0)
break;
dp = (struct dirent *)((char *)dp + dp->d_reclen);
ucount += dstdp.d_reclen;
}
done:
free(dirbuf, M_TEMP);
if (error == 0)
td->td_retval[0] = ucount;
return (error);
}
#endif /* COMPAT */
#ifdef COMPAT_43 #ifdef COMPAT_43
static void
ogetdirentries_cvt(struct freebsd11_dirent *dp)
{
#if (BYTE_ORDER == LITTLE_ENDIAN)
/*
* The expected low byte of dp->d_namlen is our dp->d_type.
* The high MBZ byte of dp->d_namlen is our dp->d_namlen.
*/
dp->d_type = dp->d_namlen;
dp->d_namlen = 0;
#else
/*
* The dp->d_type is the high byte of the expected dp->d_namlen,
* so must be zero'ed.
*/
dp->d_type = 0;
#endif
}
/* /*
* Read a block of directory entries in a filesystem independent format. * Read a block of directory entries in a filesystem independent format.
*/ */
@ -3530,138 +3810,26 @@ int
kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,
long *ploff) long *ploff)
{ {
struct vnode *vp; long base;
struct file *fp; int error;
struct uio auio, kuio;
struct iovec aiov, kiov;
struct dirent *dp, *edp;
cap_rights_t rights;
caddr_t dirbuf;
int error, eofflag, readcnt;
long loff;
off_t foffset;
/* XXX arbitrary sanity limit on `count'. */ /* XXX arbitrary sanity limit on `count'. */
if (uap->count > 64 * 1024) if (uap->count > 64 * 1024)
return (EINVAL); return (EINVAL);
error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
if (error != 0) error = freebsd11_kern_getdirentries(td, uap->fd, uap->buf, uap->count,
return (error); &base, ogetdirentries_cvt);
if ((fp->f_flag & FREAD) == 0) {
fdrop(fp, td); if (error == 0 && uap->basep != NULL)
return (EBADF); error = copyout(&base, uap->basep, sizeof(long));
}
vp = fp->f_vnode;
foffset = foffset_lock(fp, 0);
unionread:
if (vp->v_type != VDIR) {
foffset_unlock(fp, foffset, 0);
fdrop(fp, td);
return (EINVAL);
}
aiov.iov_base = uap->buf;
aiov.iov_len = uap->count;
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
auio.uio_rw = UIO_READ;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_td = td;
auio.uio_resid = uap->count;
vn_lock(vp, LK_SHARED | LK_RETRY);
loff = auio.uio_offset = foffset;
#ifdef MAC
error = mac_vnode_check_readdir(td->td_ucred, vp);
if (error != 0) {
VOP_UNLOCK(vp, 0);
foffset_unlock(fp, foffset, FOF_NOUPDATE);
fdrop(fp, td);
return (error);
}
#endif
# if (BYTE_ORDER != LITTLE_ENDIAN)
if (vp->v_mount->mnt_maxsymlinklen <= 0) {
error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag,
NULL, NULL);
foffset = auio.uio_offset;
} else
# endif
{
kuio = auio;
kuio.uio_iov = &kiov;
kuio.uio_segflg = UIO_SYSSPACE;
kiov.iov_len = uap->count;
dirbuf = malloc(uap->count, M_TEMP, M_WAITOK);
kiov.iov_base = dirbuf;
error = VOP_READDIR(vp, &kuio, fp->f_cred, &eofflag,
NULL, NULL);
foffset = kuio.uio_offset;
if (error == 0) {
readcnt = uap->count - kuio.uio_resid;
edp = (struct dirent *)&dirbuf[readcnt];
for (dp = (struct dirent *)dirbuf; dp < edp; ) {
# if (BYTE_ORDER == LITTLE_ENDIAN)
/*
* The expected low byte of
* dp->d_namlen is our dp->d_type.
* The high MBZ byte of dp->d_namlen
* is our dp->d_namlen.
*/
dp->d_type = dp->d_namlen;
dp->d_namlen = 0;
# else
/*
* The dp->d_type is the high byte
* of the expected dp->d_namlen,
* so must be zero'ed.
*/
dp->d_type = 0;
# endif
if (dp->d_reclen > 0) {
dp = (struct dirent *)
((char *)dp + dp->d_reclen);
} else {
error = EIO;
break;
}
}
if (dp >= edp)
error = uiomove(dirbuf, readcnt, &auio);
}
free(dirbuf, M_TEMP);
}
if (error != 0) {
VOP_UNLOCK(vp, 0);
foffset_unlock(fp, foffset, 0);
fdrop(fp, td);
return (error);
}
if (uap->count == auio.uio_resid &&
(vp->v_vflag & VV_ROOT) &&
(vp->v_mount->mnt_flag & MNT_UNION)) {
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
fp->f_vnode = vp;
fp->f_data = vp;
foffset = 0;
vput(tvp);
goto unionread;
}
VOP_UNLOCK(vp, 0);
foffset_unlock(fp, foffset, 0);
fdrop(fp, td);
td->td_retval[0] = uap->count - auio.uio_resid;
if (error == 0)
*ploff = loff;
return (error); return (error);
} }
#endif /* COMPAT_43 */ #endif /* COMPAT_43 */
/* #if defined(COMPAT_FREEBSD11)
* Read a block of directory entries in a filesystem independent format.
*/
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
struct getdirentries_args { struct freebsd11_getdirentries_args {
int fd; int fd;
char *buf; char *buf;
u_int count; u_int count;
@ -3669,30 +3837,61 @@ struct getdirentries_args {
}; };
#endif #endif
int int
sys_getdirentries(struct thread *td, struct getdirentries_args *uap) freebsd11_getdirentries(struct thread *td,
struct freebsd11_getdirentries_args *uap)
{ {
long base; long base;
int error; int error;
error = freebsd11_kern_getdirentries(td, uap->fd, uap->buf, uap->count,
&base, NULL);
if (error == 0 && uap->basep != NULL)
error = copyout(&base, uap->basep, sizeof(long));
return (error);
}
int
freebsd11_getdents(struct thread *td, struct freebsd11_getdents_args *uap)
{
struct freebsd11_getdirentries_args ap;
ap.fd = uap->fd;
ap.buf = uap->buf;
ap.count = uap->count;
ap.basep = NULL;
return (freebsd11_getdirentries(td, &ap));
}
#endif /* COMPAT_FREEBSD11 */
/*
* Read a block of directory entries in a filesystem independent format.
*/
int
sys_getdirentries(struct thread *td, struct getdirentries_args *uap)
{
off_t base;
int error;
error = kern_getdirentries(td, uap->fd, uap->buf, uap->count, &base, error = kern_getdirentries(td, uap->fd, uap->buf, uap->count, &base,
NULL, UIO_USERSPACE); NULL, UIO_USERSPACE);
if (error != 0) if (error != 0)
return (error); return (error);
if (uap->basep != NULL) if (uap->basep != NULL)
error = copyout(&base, uap->basep, sizeof(long)); error = copyout(&base, uap->basep, sizeof(off_t));
return (error); return (error);
} }
int int
kern_getdirentries(struct thread *td, int fd, char *buf, u_int count, kern_getdirentries(struct thread *td, int fd, char *buf, size_t count,
long *basep, ssize_t *residp, enum uio_seg bufseg) off_t *basep, ssize_t *residp, enum uio_seg bufseg)
{ {
struct vnode *vp; struct vnode *vp;
struct file *fp; struct file *fp;
struct uio auio; struct uio auio;
struct iovec aiov; struct iovec aiov;
cap_rights_t rights; cap_rights_t rights;
long loff; off_t loff;
int error, eofflag; int error, eofflag;
off_t foffset; off_t foffset;
@ -3759,25 +3958,6 @@ kern_getdirentries(struct thread *td, int fd, char *buf, u_int count,
return (error); return (error);
} }
#ifndef _SYS_SYSPROTO_H_
struct getdents_args {
int fd;
char *buf;
size_t count;
};
#endif
int
sys_getdents(struct thread *td, struct getdents_args *uap)
{
struct getdirentries_args ap;
ap.fd = uap->fd;
ap.buf = uap->buf;
ap.count = uap->count;
ap.basep = NULL;
return (sys_getdirentries(td, &ap));
}
/* /*
* Set the mode mask for creation of filesystem nodes. * Set the mode mask for creation of filesystem nodes.
*/ */

View File

@ -2340,7 +2340,7 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif)
char *fullpath, *freepath; char *fullpath, *freepath;
int error; int error;
kif->kf_vnode_type = vntype_to_kinfo(vp->v_type); kif->kf_un.kf_file.kf_file_type = vntype_to_kinfo(vp->v_type);
freepath = NULL; freepath = NULL;
fullpath = "-"; fullpath = "-";
error = vn_fullpath(curthread, vp, &fullpath, &freepath); error = vn_fullpath(curthread, vp, &fullpath, &freepath);
@ -2369,10 +2369,14 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif)
else else
kif->kf_un.kf_file.kf_file_fsid = kif->kf_un.kf_file.kf_file_fsid =
vp->v_mount->mnt_stat.f_fsid.val[0]; vp->v_mount->mnt_stat.f_fsid.val[0];
kif->kf_un.kf_file.kf_file_fsid_freebsd11 =
kif->kf_un.kf_file.kf_file_fsid; /* truncate */
kif->kf_un.kf_file.kf_file_fileid = va.va_fileid; kif->kf_un.kf_file.kf_file_fileid = va.va_fileid;
kif->kf_un.kf_file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode); kif->kf_un.kf_file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode);
kif->kf_un.kf_file.kf_file_size = va.va_size; kif->kf_un.kf_file.kf_file_size = va.va_size;
kif->kf_un.kf_file.kf_file_rdev = va.va_rdev; kif->kf_un.kf_file.kf_file_rdev = va.va_rdev;
kif->kf_un.kf_file.kf_file_rdev_freebsd11 =
kif->kf_un.kf_file.kf_file_rdev; /* truncate */
return (0); return (0);
} }

View File

@ -202,7 +202,7 @@ nlm_advlock_internal(struct vnode *vp, void *id, int op, struct flock *fl,
union nfsfh fh; union nfsfh fh;
struct sockaddr *sa; struct sockaddr *sa;
struct sockaddr_storage ss; struct sockaddr_storage ss;
char servername[MNAMELEN]; char *servername;
struct timeval timo; struct timeval timo;
int retries; int retries;
rpcvers_t vers; rpcvers_t vers;
@ -218,6 +218,7 @@ nlm_advlock_internal(struct vnode *vp, void *id, int op, struct flock *fl,
ASSERT_VOP_LOCKED(vp, "nlm_advlock_1"); ASSERT_VOP_LOCKED(vp, "nlm_advlock_1");
servername = malloc(MNAMELEN, M_TEMP, M_WAITOK); /* XXXKIB vp locked */
nmp = VFSTONFS(vp->v_mount); nmp = VFSTONFS(vp->v_mount);
/* /*
* Push any pending writes to the server and flush our cache * Push any pending writes to the server and flush our cache
@ -381,7 +382,7 @@ nlm_advlock_internal(struct vnode *vp, void *id, int op, struct flock *fl,
AUTH_DESTROY(auth); AUTH_DESTROY(auth);
nlm_host_release(host); nlm_host_release(host);
free(servername, M_TEMP);
return (error); return (error);
} }

View File

@ -107,9 +107,9 @@ struct vnode_au_info {
mode_t vn_mode; mode_t vn_mode;
uid_t vn_uid; uid_t vn_uid;
gid_t vn_gid; gid_t vn_gid;
dev_t vn_dev; u_int32_t vn_dev; /* XXX dev_t compatibility */
long vn_fsid; long vn_fsid; /* XXX uint64_t compatibility */
long vn_fileid; long vn_fileid; /* XXX ino_t compatibility */
long vn_gen; long vn_gen;
}; };
@ -210,7 +210,7 @@ struct audit_record {
int ar_arg_atfd2; int ar_arg_atfd2;
int ar_arg_fflags; int ar_arg_fflags;
mode_t ar_arg_mode; mode_t ar_arg_mode;
int ar_arg_dev; int ar_arg_dev; /* XXX dev_t compatibility */
long ar_arg_value; long ar_arg_value;
void *ar_arg_addr; void *ar_arg_addr;
int ar_arg_len; int ar_arg_len;

View File

@ -43,13 +43,13 @@ typedef __uint64_t __fsblkcnt_t;
typedef __uint64_t __fsfilcnt_t; typedef __uint64_t __fsfilcnt_t;
typedef __uint32_t __gid_t; typedef __uint32_t __gid_t;
typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */ typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */
typedef __uint32_t __ino_t; /* inode number */ typedef __uint64_t __ino_t; /* inode number */
typedef long __key_t; /* IPC key (for Sys V IPC) */ typedef long __key_t; /* IPC key (for Sys V IPC) */
typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */ typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
typedef __uint16_t __mode_t; /* permissions */ typedef __uint16_t __mode_t; /* permissions */
typedef int __accmode_t; /* access permissions */ typedef int __accmode_t; /* access permissions */
typedef int __nl_item; typedef int __nl_item;
typedef __uint16_t __nlink_t; /* link count */ typedef __uint64_t __nlink_t; /* link count */
typedef __int64_t __off_t; /* file offset */ typedef __int64_t __off_t; /* file offset */
typedef __int64_t __off64_t; /* file offset (alias) */ typedef __int64_t __off64_t; /* file offset (alias) */
typedef __int32_t __pid_t; /* process [group] */ typedef __int32_t __pid_t; /* process [group] */
@ -105,7 +105,7 @@ typedef struct {
long double __max_align2 __aligned(_Alignof(long double)); long double __max_align2 __aligned(_Alignof(long double));
} __max_align_t; } __max_align_t;
typedef __uint32_t __dev_t; /* device number */ typedef __uint64_t __dev_t; /* device number */
typedef __uint32_t __fixpt_t; /* fixed point number */ typedef __uint32_t __fixpt_t; /* fixed point number */

View File

@ -45,12 +45,12 @@
#define AC_COMM_LEN 16 #define AC_COMM_LEN 16
/* /*
* Accounting structure version 2 (current). * Accounting structure version 3 (current).
* The first byte is always zero. * The first byte is always zero.
* Time units are microseconds. * Time units are microseconds.
*/ */
struct acctv2 { struct acctv3 {
uint8_t ac_zero; /* zero identifies new version */ uint8_t ac_zero; /* zero identifies new version */
uint8_t ac_version; /* record version number */ uint8_t ac_version; /* record version number */
uint16_t ac_len; /* record length */ uint16_t ac_len; /* record length */
@ -65,10 +65,13 @@ struct acctv2 {
float ac_mem; /* average memory usage */ float ac_mem; /* average memory usage */
float ac_io; /* count of IO blocks */ float ac_io; /* count of IO blocks */
__dev_t ac_tty; /* controlling tty */ __dev_t ac_tty; /* controlling tty */
uint32_t ac_pad0;
#if defined(__powerpc__) && !defined(_LP64)
uint32_t ac_pad1;
#endif
uint16_t ac_len2; /* record length */ uint16_t ac_len2; /* record length */
union { union {
__dev_t ac_align; /* force v1 compatible alignment */ uint32_t ac_align; /* force v1 compatible alignment */
#define AFORK 0x01 /* forked but not exec'ed */ #define AFORK 0x01 /* forked but not exec'ed */
/* ASU is no longer supported */ /* ASU is no longer supported */
@ -84,6 +87,28 @@ struct acctv2 {
#define ac_flagx ac_trailer.ac_flag #define ac_flagx ac_trailer.ac_flag
}; };
struct acctv2 {
uint8_t ac_zero; /* zero identifies new version */
uint8_t ac_version; /* record version number */
uint16_t ac_len; /* record length */
char ac_comm[AC_COMM_LEN]; /* command name */
float ac_utime; /* user time */
float ac_stime; /* system time */
float ac_etime; /* elapsed time */
time_t ac_btime; /* starting time */
uid_t ac_uid; /* user id */
gid_t ac_gid; /* group id */
float ac_mem; /* average memory usage */
float ac_io; /* count of IO blocks */
uint32_t ac_tty; /* controlling tty */
uint16_t ac_len2; /* record length */
union {
uint32_t ac_align; /* force v1 compatible alignment */
uint8_t ac_flag; /* accounting flags */
} ac_trailer;
};
/* /*
* Legacy accounting structure (rev. 1.5-1.18). * Legacy accounting structure (rev. 1.5-1.18).
@ -105,7 +130,7 @@ struct acctv1 {
gid_t ac_gid; /* group id */ gid_t ac_gid; /* group id */
uint16_t ac_mem; /* average memory usage */ uint16_t ac_mem; /* average memory usage */
comp_t ac_io; /* count of IO blocks */ comp_t ac_io; /* count of IO blocks */
__dev_t ac_tty; /* controlling tty */ uint32_t ac_tty; /* controlling tty */
uint8_t ac_flag; /* accounting flags */ uint8_t ac_flag; /* accounting flags */
}; };

View File

@ -36,22 +36,39 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include <sys/_types.h> #include <sys/_types.h>
#ifndef _INO_T_DECLARED
typedef __ino_t ino_t;
#define _INO_T_DECLARED
#endif
#ifndef _OFF_T_DECLARED
typedef __off_t off_t;
#define _OFF_T_DECLARED
#endif
/* /*
* The dirent structure defines the format of directory entries returned by * The dirent structure defines the format of directory entries returned by
* the getdirentries(2) system call. * the getdirentries(2) system call.
* *
* A directory entry has a struct dirent at the front of it, containing its * A directory entry has a struct dirent at the front of it, containing its
* inode number, the length of the entry, and the length of the name * inode number, the length of the entry, and the length of the name
* contained in the entry. These are followed by the name padded to a 4 * contained in the entry. These are followed by the name padded to an 8
* byte boundary with null bytes. All names are guaranteed null terminated. * byte boundary with null bytes. All names are guaranteed null terminated.
* The maximum length of a name in a directory is MAXNAMLEN. * The maximum length of a name in a directory is MAXNAMLEN.
*
* Explicit padding between the last member of the header (d_namelen) and
* d_name avoids ABI padding at the end of dirent on LP64 architectures.
* There is code depending on d_name being last.
*/ */
struct dirent { struct dirent {
__uint32_t d_fileno; /* file number of entry */ ino_t d_fileno; /* file number of entry */
off_t d_off; /* directory offset of entry */
__uint16_t d_reclen; /* length of this record */ __uint16_t d_reclen; /* length of this record */
__uint8_t d_type; /* file type, see below */ __uint8_t d_type; /* file type, see below */
__uint8_t d_namlen; /* length of string in d_name */ __uint8_t d_pad0;
__uint16_t d_namlen; /* length of string in d_name */
__uint16_t d_pad1;
#if __BSD_VISIBLE #if __BSD_VISIBLE
#define MAXNAMLEN 255 #define MAXNAMLEN 255
char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */ char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
@ -60,7 +77,18 @@ struct dirent {
#endif #endif
}; };
#if defined(_WANT_FREEBSD11_DIRENT) || defined(_KERNEL)
struct freebsd11_dirent {
__uint32_t d_fileno; /* file number of entry */
__uint16_t d_reclen; /* length of this record */
__uint8_t d_type; /* file type, see below */
__uint8_t d_namlen; /* length of string in d_name */
char d_name[255 + 1]; /* name must be no longer than this */
};
#endif /* _WANT_FREEBSD11_DIRENT || _KERNEL */
#if __BSD_VISIBLE #if __BSD_VISIBLE
/* /*
* File types * File types
*/ */
@ -84,13 +112,14 @@ struct dirent {
* The _GENERIC_DIRSIZ macro gives the minimum record length which will hold * The _GENERIC_DIRSIZ macro gives the minimum record length which will hold
* the directory entry. This returns the amount of space in struct direct * the directory entry. This returns the amount of space in struct direct
* without the d_name field, plus enough space for the name with a terminating * without the d_name field, plus enough space for the name with a terminating
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. * null byte (dp->d_namlen+1), rounded up to a 8 byte boundary.
* *
* XXX although this macro is in the implementation namespace, it requires * XXX although this macro is in the implementation namespace, it requires
* a manifest constant that is not. * a manifest constant that is not.
*/ */
#define _GENERIC_DIRSIZ(dp) \ #define _GENERIC_DIRLEN(namlen) \
((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) ((__offsetof(struct dirent, d_name) + (namlen) + 1 + 7) & ~7)
#define _GENERIC_DIRSIZ(dp) _GENERIC_DIRLEN((dp)->d_namlen)
#endif /* __BSD_VISIBLE */ #endif /* __BSD_VISIBLE */
#ifdef _KERNEL #ifdef _KERNEL

View File

@ -65,8 +65,8 @@ struct fid {
* filesystem statistics * filesystem statistics
*/ */
#define MFSNAMELEN 16 /* length of type name including null */ #define MFSNAMELEN 16 /* length of type name including null */
#define MNAMELEN 88 /* size of on/from name bufs */ #define MNAMELEN 1024 /* size of on/from name bufs */
#define STATFS_VERSION 0x20030518 /* current version number */ #define STATFS_VERSION 0x20140518 /* current version number */
struct statfs { struct statfs {
uint32_t f_version; /* structure version number */ uint32_t f_version; /* structure version number */
uint32_t f_type; /* type of filesystem */ uint32_t f_type; /* type of filesystem */
@ -92,6 +92,34 @@ struct statfs {
char f_mntonname[MNAMELEN]; /* directory on which mounted */ char f_mntonname[MNAMELEN]; /* directory on which mounted */
}; };
#if defined(_WANT_FREEBSD11_STATFS) || defined(_KERNEL)
#define FREEBSD11_STATFS_VERSION 0x20030518 /* current version number */
struct freebsd11_statfs {
uint32_t f_version; /* structure version number */
uint32_t f_type; /* type of filesystem */
uint64_t f_flags; /* copy of mount exported flags */
uint64_t f_bsize; /* filesystem fragment size */
uint64_t f_iosize; /* optimal transfer block size */
uint64_t f_blocks; /* total data blocks in filesystem */
uint64_t f_bfree; /* free blocks in filesystem */
int64_t f_bavail; /* free blocks avail to non-superuser */
uint64_t f_files; /* total file nodes in filesystem */
int64_t f_ffree; /* free nodes avail to non-superuser */
uint64_t f_syncwrites; /* count of sync writes since mount */
uint64_t f_asyncwrites; /* count of async writes since mount */
uint64_t f_syncreads; /* count of sync reads since mount */
uint64_t f_asyncreads; /* count of async reads since mount */
uint64_t f_spare[10]; /* unused spare */
uint32_t f_namemax; /* maximum filename length */
uid_t f_owner; /* user that mounted the filesystem */
fsid_t f_fsid; /* filesystem id */
char f_charspare[80]; /* spare string space */
char f_fstypename[16]; /* filesystem type name */
char f_mntfromname[88]; /* mounted filesystem */
char f_mntonname[88]; /* directory on which mounted */
};
#endif /* _WANT_FREEBSD11_STATFS || _KERNEL */
#ifdef _KERNEL #ifdef _KERNEL
#define OMFSNAMELEN 16 /* length of fs type name, including null */ #define OMFSNAMELEN 16 /* length of fs type name, including null */
#define OMNAMELEN (88 - 2 * sizeof(long)) /* size of on/from name bufs */ #define OMNAMELEN (88 - 2 * sizeof(long)) /* size of on/from name bufs */

View File

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

View File

@ -102,9 +102,9 @@ typedef __uid_t uid_t;
#ifdef _KERNEL #ifdef _KERNEL
struct ostat { struct ostat {
__uint16_t st_dev; /* inode's device */ __uint16_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */ __uint32_t st_ino; /* inode's number */
mode_t st_mode; /* inode protection mode */ mode_t st_mode; /* inode protection mode */
nlink_t st_nlink; /* number of hard links */ __uint16_t st_nlink; /* number of hard links */
__uint16_t st_uid; /* user ID of the file's owner */ __uint16_t st_uid; /* user ID of the file's owner */
__uint16_t st_gid; /* group ID of the file's group */ __uint16_t st_gid; /* group ID of the file's group */
__uint16_t st_rdev; /* device type */ __uint16_t st_rdev; /* device type */
@ -119,14 +119,15 @@ struct ostat {
}; };
#endif #endif
struct stat { #if defined(_WANT_FREEBSD11_STAT) || defined(_KERNEL)
__dev_t st_dev; /* inode's device */ struct freebsd11_stat {
ino_t st_ino; /* inode's number */ __uint32_t st_dev; /* inode's device */
__uint32_t st_ino; /* inode's number */
mode_t st_mode; /* inode protection mode */ mode_t st_mode; /* inode protection mode */
nlink_t st_nlink; /* number of hard links */ __uint16_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */ uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */ gid_t st_gid; /* group ID of the file's group */
__dev_t st_rdev; /* device type */ __uint32_t st_rdev; /* device type */
struct timespec st_atim; /* time of last access */ struct timespec st_atim; /* time of last access */
struct timespec st_mtim; /* time of last data modification */ struct timespec st_mtim; /* time of last data modification */
struct timespec st_ctim; /* time of last file status change */ struct timespec st_ctim; /* time of last file status change */
@ -148,16 +149,55 @@ struct stat {
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
}; };
#endif /* _WANT_FREEBSD11_STAT || _KERNEL */
#if defined(__i386__)
#define __STAT_TIME_T_EXT 1
#endif
struct stat {
dev_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */
nlink_t st_nlink; /* number of hard links */
mode_t st_mode; /* inode protection mode */
__int16_t st_padding0;
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
__int32_t st_padding1;
dev_t st_rdev; /* device type */
#ifdef __STAT_TIME_T_EXT
__int32_t st_atim_ext;
#endif
struct timespec st_atim; /* time of last access */
#ifdef __STAT_TIME_T_EXT
__int32_t st_mtim_ext;
#endif
struct timespec st_mtim; /* time of last data modification */
#ifdef __STAT_TIME_T_EXT
__int32_t st_ctim_ext;
#endif
struct timespec st_ctim; /* time of last file status change */
#ifdef __STAT_TIME_T_EXT
__int32_t st_btim_ext;
#endif
struct timespec st_birthtim; /* time of file creation */
off_t st_size; /* file size, in bytes */
blkcnt_t st_blocks; /* blocks allocated for file */
blksize_t st_blksize; /* optimal blocksize for I/O */
fflags_t st_flags; /* user defined flags for file */
__uint64_t st_gen; /* file generation number */
__uint64_t st_spare[10];
};
#ifdef _KERNEL #ifdef _KERNEL
struct nstat { struct nstat {
__dev_t st_dev; /* inode's device */ __uint32_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */ __uint32_t st_ino; /* inode's number */
__uint32_t st_mode; /* inode protection mode */ __uint32_t st_mode; /* inode protection mode */
__uint32_t st_nlink; /* number of hard links */ __uint32_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */ uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */ gid_t st_gid; /* group ID of the file's group */
__dev_t st_rdev; /* device type */ __uint32_t st_rdev; /* device type */
struct timespec st_atim; /* time of last access */ struct timespec st_atim; /* time of last access */
struct timespec st_mtim; /* time of last data modification */ struct timespec st_mtim; /* time of last data modification */
struct timespec st_ctim; /* time of last file status change */ struct timespec st_ctim; /* time of last file status change */
@ -168,7 +208,8 @@ struct nstat {
__uint32_t st_gen; /* file generation number */ __uint32_t st_gen; /* file generation number */
struct timespec st_birthtim; /* time of file creation */ struct timespec st_birthtim; /* time of file creation */
/* /*
* See above about the following padding. * See comment in the definition of struct freebsd11_stat
* above about the following padding.
*/ */
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec)); unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));

View File

@ -117,8 +117,8 @@ int kern_futimes(struct thread *td, int fd, struct timeval *tptr,
enum uio_seg tptrseg); enum uio_seg tptrseg);
int kern_futimens(struct thread *td, int fd, struct timespec *tptr, int kern_futimens(struct thread *td, int fd, struct timespec *tptr,
enum uio_seg tptrseg); enum uio_seg tptrseg);
int kern_getdirentries(struct thread *td, int fd, char *buf, u_int count, int kern_getdirentries(struct thread *td, int fd, char *buf, size_t count,
long *basep, ssize_t *residp, enum uio_seg bufseg); off_t *basep, ssize_t *residp, enum uio_seg bufseg);
int kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, int kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
size_t *countp, enum uio_seg bufseg, int mode); size_t *countp, enum uio_seg bufseg, int mode);
int kern_getitimer(struct thread *, u_int, struct itimerval *); int kern_getitimer(struct thread *, u_int, struct itimerval *);
@ -158,7 +158,7 @@ int kern_mkdirat(struct thread *td, int fd, char *path,
int kern_mkfifoat(struct thread *td, int fd, char *path, int kern_mkfifoat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int mode); enum uio_seg pathseg, int mode);
int kern_mknodat(struct thread *td, int fd, char *path, int kern_mknodat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int mode, int dev); enum uio_seg pathseg, int mode, dev_t dev);
int kern_mlock(struct proc *proc, struct ucred *cred, uintptr_t addr, int kern_mlock(struct proc *proc, struct ucred *cred, uintptr_t addr,
size_t len); size_t len);
int kern_mmap(struct thread *td, uintptr_t addr, size_t size, int prot, int kern_mmap(struct thread *td, uintptr_t addr, size_t size, int prot,
@ -292,4 +292,9 @@ int kern_socketpair(struct thread *td, int domain, int type, int protocol,
#define KSA_OSIGSET 0x0001 /* uses osigact_t */ #define KSA_OSIGSET 0x0001 /* uses osigact_t */
#define KSA_FREEBSD4 0x0002 /* uses ucontext4 */ #define KSA_FREEBSD4 0x0002 /* uses ucontext4 */
struct freebsd11_dirent;
int freebsd11_kern_getdirentries(struct thread *td, int fd, char *ubuf, u_int
count, long *basep, void (*func)(struct freebsd11_dirent *));
#endif /* !_SYS_SYSCALLSUBR_H_ */ #endif /* !_SYS_SYSCALLSUBR_H_ */

View File

@ -148,7 +148,7 @@ struct xtty {
pid_t xt_pgid; /* Foreground process group. */ pid_t xt_pgid; /* Foreground process group. */
pid_t xt_sid; /* Session. */ pid_t xt_sid; /* Session. */
unsigned int xt_flags; /* Terminal option flags. */ unsigned int xt_flags; /* Terminal option flags. */
dev_t xt_dev; /* Userland device. */ uint32_t xt_dev; /* Userland device. XXXKIB truncated */
}; };
#ifdef _KERNEL #ifdef _KERNEL

View File

@ -84,7 +84,7 @@
* it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and
* function kvm_proclist in lib/libkvm/kvm_proc.c . * function kvm_proclist in lib/libkvm/kvm_proc.c .
*/ */
#define KI_NSPARE_INT 4 #define KI_NSPARE_INT 2
#define KI_NSPARE_LONG 12 #define KI_NSPARE_LONG 12
#define KI_NSPARE_PTR 6 #define KI_NSPARE_PTR 6
@ -135,7 +135,7 @@ struct kinfo_proc {
pid_t ki_tsid; /* Terminal session ID */ pid_t ki_tsid; /* Terminal session ID */
short ki_jobc; /* job control counter */ short ki_jobc; /* job control counter */
short ki_spare_short1; /* unused (just here for alignment) */ short ki_spare_short1; /* unused (just here for alignment) */
dev_t ki_tdev; /* controlling tty dev */ uint32_t ki_tdev_freebsd11; /* controlling tty dev */
sigset_t ki_siglist; /* Signals arrived but not delivered */ sigset_t ki_siglist; /* Signals arrived but not delivered */
sigset_t ki_sigmask; /* Current signal mask */ sigset_t ki_sigmask; /* Current signal mask */
sigset_t ki_sigignore; /* Signals being ignored */ sigset_t ki_sigignore; /* Signals being ignored */
@ -188,6 +188,7 @@ struct kinfo_proc {
*/ */
char ki_sparestrings[46]; /* spare string space */ char ki_sparestrings[46]; /* spare string space */
int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */ int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */
uint64_t ki_tdev; /* controlling tty dev */
int ki_oncpu; /* Which cpu we are on */ int ki_oncpu; /* Which cpu we are on */
int ki_lastcpu; /* Last cpu we were on */ int ki_lastcpu; /* Last cpu we were on */
int ki_tracer; /* Pid of tracing process */ int ki_tracer; /* Pid of tracing process */
@ -341,14 +342,19 @@ struct kinfo_file {
int kf_flags; /* Flags. */ int kf_flags; /* Flags. */
int kf_pad0; /* Round to 64 bit alignment. */ int kf_pad0; /* Round to 64 bit alignment. */
int64_t kf_offset; /* Seek location. */ int64_t kf_offset; /* Seek location. */
int kf_vnode_type; /* Vnode type. */
int kf_sock_domain; /* Socket domain. */
int kf_sock_type; /* Socket type. */
int kf_sock_protocol; /* Socket protocol. */
struct sockaddr_storage kf_sa_local; /* Socket address. */
struct sockaddr_storage kf_sa_peer; /* Peer address. */
union { union {
struct { struct {
uint32_t kf_spareint;
/* Socket domain. */
int kf_sock_domain0;
/* Socket type. */
int kf_sock_type0;
/* Socket protocol. */
int kf_sock_protocol0;
/* Socket address. */
struct sockaddr_storage kf_sa_local;
/* Peer address. */
struct sockaddr_storage kf_sa_peer;
/* Address of so_pcb. */ /* Address of so_pcb. */
uint64_t kf_sock_pcb; uint64_t kf_sock_pcb;
/* Address of inp_ppcb. */ /* Address of inp_ppcb. */
@ -363,14 +369,23 @@ struct kinfo_file {
uint32_t kf_sock_pad0; uint32_t kf_sock_pad0;
} kf_sock; } kf_sock;
struct { struct {
/* Vnode type. */
int kf_file_type;
/* Space for future use */
int kf_spareint[3];
uint64_t kf_spareint64[30];
/* Vnode filesystem id. */
uint64_t kf_file_fsid;
/* File device. */
uint64_t kf_file_rdev;
/* Global file id. */ /* Global file id. */
uint64_t kf_file_fileid; uint64_t kf_file_fileid;
/* File size. */ /* File size. */
uint64_t kf_file_size; uint64_t kf_file_size;
/* Vnode filesystem id. */ /* Vnode filesystem id, FreeBSD 11 compat. */
uint32_t kf_file_fsid; uint32_t kf_file_fsid_freebsd11;
/* File device. */ /* File device, FreeBSD 11 compat. */
uint32_t kf_file_rdev; uint32_t kf_file_rdev_freebsd11;
/* File mode. */ /* File mode. */
uint16_t kf_file_mode; uint16_t kf_file_mode;
/* Round to 64 bit alignment. */ /* Round to 64 bit alignment. */
@ -378,10 +393,14 @@ struct kinfo_file {
uint32_t kf_file_pad1; uint32_t kf_file_pad1;
} kf_file; } kf_file;
struct { struct {
uint32_t kf_spareint[4];
uint64_t kf_spareint64[32];
uint32_t kf_sem_value; uint32_t kf_sem_value;
uint16_t kf_sem_mode; uint16_t kf_sem_mode;
} kf_sem; } kf_sem;
struct { struct {
uint32_t kf_spareint[4];
uint64_t kf_spareint64[32];
uint64_t kf_pipe_addr; uint64_t kf_pipe_addr;
uint64_t kf_pipe_peer; uint64_t kf_pipe_peer;
uint32_t kf_pipe_buffer_cnt; uint32_t kf_pipe_buffer_cnt;
@ -389,11 +408,17 @@ struct kinfo_file {
uint32_t kf_pipe_pad0[3]; uint32_t kf_pipe_pad0[3];
} kf_pipe; } kf_pipe;
struct { struct {
uint32_t kf_pts_dev; uint32_t kf_spareint[4];
uint64_t kf_spareint64[32];
uint32_t kf_pts_dev_freebsd11;
uint32_t kf_pts_pad0;
uint64_t kf_pts_dev;
/* Round to 64 bit alignment. */ /* Round to 64 bit alignment. */
uint32_t kf_pts_pad0[7]; uint32_t kf_pts_pad1[4];
} kf_pts; } kf_pts;
struct { struct {
uint32_t kf_spareint[4];
uint64_t kf_spareint64[32];
pid_t kf_pid; pid_t kf_pid;
} kf_proc; } kf_proc;
} kf_un; } kf_un;
@ -405,6 +430,12 @@ struct kinfo_file {
/* Truncated before copyout in sysctl */ /* Truncated before copyout in sysctl */
char kf_path[PATH_MAX]; /* Path to file, if any. */ char kf_path[PATH_MAX]; /* Path to file, if any. */
}; };
#ifndef _KERNEL
#define kf_vnode_type kf_un.kf_file.kf_file_type
#define kf_sock_domain kf_un.kf_sock.kf_sock_domain0
#define kf_sock_type kf_un.kf_sock.kf_sock_type0
#define kf_sock_protocol kf_un.kf_sock.kf_sock_protocol0
#endif
/* /*
* The KERN_PROC_VMMAP sysctl allows a process to dump the VM layout of * The KERN_PROC_VMMAP sysctl allows a process to dump the VM layout of
@ -454,7 +485,7 @@ struct kinfo_ovmentry {
void *_kve_pspare[8]; /* Space for more stuff. */ void *_kve_pspare[8]; /* Space for more stuff. */
off_t kve_offset; /* Mapping offset in object */ off_t kve_offset; /* Mapping offset in object */
uint64_t kve_fileid; /* inode number if vnode */ uint64_t kve_fileid; /* inode number if vnode */
dev_t kve_fsid; /* dev_t of vnode location */ uint32_t kve_fsid; /* dev_t of vnode location */
int _kve_ispare[3]; /* Space for more stuff. */ int _kve_ispare[3]; /* Space for more stuff. */
}; };
@ -469,7 +500,7 @@ struct kinfo_vmentry {
uint64_t kve_end; /* Finishing address. */ uint64_t kve_end; /* Finishing address. */
uint64_t kve_offset; /* Mapping offset in object */ uint64_t kve_offset; /* Mapping offset in object */
uint64_t kve_vn_fileid; /* inode number if vnode */ uint64_t kve_vn_fileid; /* inode number if vnode */
uint32_t kve_vn_fsid; /* dev_t of vnode location */ uint32_t kve_vn_fsid_freebsd11; /* dev_t of vnode location */
int kve_flags; /* Flags on map entry. */ int kve_flags; /* Flags on map entry. */
int kve_resident; /* Number of resident pages. */ int kve_resident; /* Number of resident pages. */
int kve_private_resident; /* Number of private pages. */ int kve_private_resident; /* Number of private pages. */
@ -478,10 +509,12 @@ struct kinfo_vmentry {
int kve_shadow_count; /* VM obj shadow count. */ int kve_shadow_count; /* VM obj shadow count. */
int kve_vn_type; /* Vnode type. */ int kve_vn_type; /* Vnode type. */
uint64_t kve_vn_size; /* File size. */ uint64_t kve_vn_size; /* File size. */
uint32_t kve_vn_rdev; /* Device id if device. */ uint32_t kve_vn_rdev_freebsd11; /* Device id if device. */
uint16_t kve_vn_mode; /* File mode. */ uint16_t kve_vn_mode; /* File mode. */
uint16_t kve_status; /* Status flags. */ uint16_t kve_status; /* Status flags. */
int _kve_ispare[12]; /* Space for more stuff. */ uint64_t kve_vn_fsid; /* dev_t of vnode location */
uint64_t kve_vn_rdev; /* Device id if device. */
int _kve_ispare[8]; /* Space for more stuff. */
/* Truncated before copyout in sysctl */ /* Truncated before copyout in sysctl */
char kve_path[PATH_MAX]; /* Path to VM obj, if any. */ char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
}; };
@ -495,14 +528,15 @@ struct kinfo_vmobject {
int kvo_type; /* Object type: KVME_TYPE_*. */ int kvo_type; /* Object type: KVME_TYPE_*. */
uint64_t kvo_size; /* Object size in pages. */ uint64_t kvo_size; /* Object size in pages. */
uint64_t kvo_vn_fileid; /* inode number if vnode. */ uint64_t kvo_vn_fileid; /* inode number if vnode. */
uint32_t kvo_vn_fsid; /* dev_t of vnode location. */ uint32_t kvo_vn_fsid_freebsd11; /* dev_t of vnode location. */
int kvo_ref_count; /* Reference count. */ int kvo_ref_count; /* Reference count. */
int kvo_shadow_count; /* Shadow count. */ int kvo_shadow_count; /* Shadow count. */
int kvo_memattr; /* Memory attribute. */ int kvo_memattr; /* Memory attribute. */
uint64_t kvo_resident; /* Number of resident pages. */ uint64_t kvo_resident; /* Number of resident pages. */
uint64_t kvo_active; /* Number of active pages. */ uint64_t kvo_active; /* Number of active pages. */
uint64_t kvo_inactive; /* Number of inactive pages. */ uint64_t kvo_inactive; /* Number of inactive pages. */
uint64_t _kvo_qspare[8]; uint64_t kvo_vn_fsid;
uint64_t _kvo_qspare[7];
uint32_t _kvo_ispare[8]; uint32_t _kvo_ispare[8];
char kvo_path[PATH_MAX]; /* Pathname, if any. */ char kvo_path[PATH_MAX]; /* Pathname, if any. */
}; };

View File

@ -266,11 +266,12 @@ struct xvnode {
struct vattr { struct vattr {
enum vtype va_type; /* vnode type (for create) */ enum vtype va_type; /* vnode type (for create) */
u_short va_mode; /* files access mode and type */ u_short va_mode; /* files access mode and type */
short va_nlink; /* number of references to file */ u_short va_padding0;
uid_t va_uid; /* owner user id */ uid_t va_uid; /* owner user id */
gid_t va_gid; /* owner group id */ gid_t va_gid; /* owner group id */
nlink_t va_nlink; /* number of references to file */
dev_t va_fsid; /* filesystem id */ dev_t va_fsid; /* filesystem id */
long va_fileid; /* file id */ ino_t va_fileid; /* file id */
u_quad_t va_size; /* file size in bytes */ u_quad_t va_size; /* file size in bytes */
long va_blocksize; /* blocksize preferred for i/o */ long va_blocksize; /* blocksize preferred for i/o */
struct timespec va_atime; /* time of last access */ struct timespec va_atime; /* time of last access */
@ -585,6 +586,7 @@ struct file;
struct mount; struct mount;
struct nameidata; struct nameidata;
struct ostat; struct ostat;
struct freebsd11_stat;
struct thread; struct thread;
struct proc; struct proc;
struct stat; struct stat;
@ -613,7 +615,8 @@ void cache_purge_negative(struct vnode *vp);
void cache_purgevfs(struct mount *mp, bool force); void cache_purgevfs(struct mount *mp, bool force);
int change_dir(struct vnode *vp, struct thread *td); int change_dir(struct vnode *vp, struct thread *td);
void cvtstat(struct stat *st, struct ostat *ost); void cvtstat(struct stat *st, struct ostat *ost);
void cvtnstat(struct stat *sb, struct nstat *nsb); void freebsd11_cvtnstat(struct stat *sb, struct nstat *nsb);
void freebsd11_cvtstat(struct stat *st, struct freebsd11_stat *ost);
int getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops, int getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops,
struct vnode **vpp); struct vnode **vpp);
void getnewvnode_reserve(u_int count); void getnewvnode_reserve(u_int count);

View File

@ -69,6 +69,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include "opt_compat.h"
#include "opt_swap.h" #include "opt_swap.h"
#include "opt_vm.h" #include "opt_vm.h"
@ -2417,10 +2418,24 @@ swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len)
return (error); return (error);
} }
#if defined(COMPAT_FREEBSD11)
#define XSWDEV_VERSION_11 1
struct xswdev11 {
u_int xsw_version;
uint32_t xsw_dev;
int xsw_flags;
int xsw_nblks;
int xsw_used;
};
#endif
static int static int
sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS) sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS)
{ {
struct xswdev xs; struct xswdev xs;
#if defined(COMPAT_FREEBSD11)
struct xswdev11 xs11;
#endif
int error; int error;
if (arg2 != 1) /* name length */ if (arg2 != 1) /* name length */
@ -2428,7 +2443,17 @@ sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS)
error = swap_dev_info(*(int *)arg1, &xs, NULL, 0); error = swap_dev_info(*(int *)arg1, &xs, NULL, 0);
if (error != 0) if (error != 0)
return (error); return (error);
error = SYSCTL_OUT(req, &xs, sizeof(xs)); #if defined(COMPAT_FREEBSD11)
if (req->oldlen == sizeof(xs11)) {
xs11.xsw_version = XSWDEV_VERSION_11;
xs11.xsw_dev = xs.xsw_dev; /* truncation */
xs11.xsw_flags = xs.xsw_flags;
xs11.xsw_nblks = xs.xsw_nblks;
xs11.xsw_used = xs.xsw_used;
error = SYSCTL_OUT(req, &xs11, sizeof(xs11));
} else
#endif
error = SYSCTL_OUT(req, &xs, sizeof(xs));
return (error); return (error);
} }

View File

@ -2342,6 +2342,7 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS)
kvo.kvo_vn_fileid = 0; kvo.kvo_vn_fileid = 0;
kvo.kvo_vn_fsid = 0; kvo.kvo_vn_fsid = 0;
kvo.kvo_vn_fsid_freebsd11 = 0;
freepath = NULL; freepath = NULL;
fullpath = ""; fullpath = "";
vp = NULL; vp = NULL;
@ -2383,6 +2384,8 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS)
if (VOP_GETATTR(vp, &va, curthread->td_ucred) == 0) { if (VOP_GETATTR(vp, &va, curthread->td_ucred) == 0) {
kvo.kvo_vn_fileid = va.va_fileid; kvo.kvo_vn_fileid = va.va_fileid;
kvo.kvo_vn_fsid = va.va_fsid; kvo.kvo_vn_fsid = va.va_fsid;
kvo.kvo_vn_fsid_freebsd11 = va.va_fsid;
/* truncate */
} }
vput(vp); vput(vp);
} }

View File

@ -89,7 +89,7 @@
/* /*
* Structure for swap device statistics * Structure for swap device statistics
*/ */
#define XSWDEV_VERSION 1 #define XSWDEV_VERSION 2
struct xswdev { struct xswdev {
u_int xsw_version; u_int xsw_version;
dev_t xsw_dev; dev_t xsw_dev;

View File

@ -932,7 +932,6 @@ ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags)
ip++; ip++;
narg--; narg--;
break; break;
case SYS_mknod:
case SYS_mknodat: case SYS_mknodat:
print_number(ip, narg, c); print_number(ip, narg, c);
putchar(','); putchar(',');

View File

@ -61,9 +61,9 @@ __FBSDID("$FreeBSD$");
time_t expand(u_int); time_t expand(u_int);
char *flagbits(int); char *flagbits(int);
const char *getdev(dev_t); const char *getdev(dev_t);
int readrec_forward(FILE *f, struct acctv2 *av2); int readrec_forward(FILE *f, struct acctv3 *av3);
int readrec_backward(FILE *f, struct acctv2 *av2); int readrec_backward(FILE *f, struct acctv3 *av3);
int requested(char *[], struct acctv2 *); int requested(char *[], struct acctv3 *);
static void usage(void); static void usage(void);
#define AC_UTIME 1 /* user */ #define AC_UTIME 1 /* user */
@ -77,10 +77,10 @@ static void usage(void);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
struct acctv2 ab; struct acctv3 ab;
char *p; char *p;
FILE *fp; FILE *fp;
int (*readrec)(FILE *f, struct acctv2 *av2); int (*readrec)(FILE *f, struct acctv3 *av3);
time_t t; time_t t;
int ch, rv; int ch, rv;
const char *acctfile, *format; const char *acctfile, *format;
@ -234,7 +234,7 @@ flagbits(int f)
} }
int int
requested(char *argv[], struct acctv2 *acp) requested(char *argv[], struct acctv3 *acp)
{ {
const char *p; const char *p;

View File

@ -38,8 +38,8 @@ __FBSDID("$FreeBSD$");
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
int readrec_forward(FILE *f, struct acctv2 *av2); int readrec_forward(FILE *f, struct acctv3 *av2);
int readrec_backward(FILE *f, struct acctv2 *av2); int readrec_backward(FILE *f, struct acctv3 *av2);
/* /*
* Reverse offsetof: return the offset of field f * Reverse offsetof: return the offset of field f
@ -90,27 +90,27 @@ decode_comp(comp_t v)
* Return EOF on error or end-of-file. * Return EOF on error or end-of-file.
*/ */
static int static int
readrec_v1(FILE *f, struct acctv2 *av2) readrec_v1(FILE *f, struct acctv3 *av3)
{ {
struct acctv1 av1; struct acctv1 av1;
int rv; int rv;
if ((rv = fread_record(&av1, sizeof(av1), f)) == EOF) if ((rv = fread_record(&av1, sizeof(av1), f)) == EOF)
return (EOF); return (EOF);
av2->ac_zero = 0; av3->ac_zero = 0;
av2->ac_version = 2; av3->ac_version = 3;
av2->ac_len = av2->ac_len2 = sizeof(*av2); av3->ac_len = av3->ac_len2 = sizeof(*av3);
memcpy(av2->ac_comm, av1.ac_comm, AC_COMM_LEN); memcpy(av3->ac_comm, av1.ac_comm, AC_COMM_LEN);
av2->ac_utime = decode_comp(av1.ac_utime) * 1000000; av3->ac_utime = decode_comp(av1.ac_utime) * 1000000;
av2->ac_stime = decode_comp(av1.ac_stime) * 1000000; av3->ac_stime = decode_comp(av1.ac_stime) * 1000000;
av2->ac_etime = decode_comp(av1.ac_etime) * 1000000; av3->ac_etime = decode_comp(av1.ac_etime) * 1000000;
av2->ac_btime = av1.ac_btime; av3->ac_btime = av1.ac_btime;
av2->ac_uid = av1.ac_uid; av3->ac_uid = av1.ac_uid;
av2->ac_gid = av1.ac_gid; av3->ac_gid = av1.ac_gid;
av2->ac_mem = av1.ac_mem; av3->ac_mem = av1.ac_mem;
av2->ac_io = decode_comp(av1.ac_io); av3->ac_io = decode_comp(av1.ac_io);
av2->ac_tty = av1.ac_tty; av3->ac_tty = av1.ac_tty;
av2->ac_flagx = av1.ac_flag | ANVER; av3->ac_flagx = av1.ac_flag | ANVER;
return (0); return (0);
} }
@ -120,9 +120,40 @@ readrec_v1(FILE *f, struct acctv2 *av2)
* Return EOF on error or end-of-file. * Return EOF on error or end-of-file.
*/ */
static int static int
readrec_v2(FILE *f, struct acctv2 *av2) readrec_v2(FILE *f, struct acctv3 *av3)
{ {
return (fread_record(av2, sizeof(*av2), f)); struct acctv2 av2;
int rv;
if ((rv = fread_record(&av2, sizeof(av2), f)) == EOF)
return (EOF);
av3->ac_zero = 0;
av3->ac_version = 3;
av3->ac_len = av3->ac_len2 = sizeof(*av3);
memcpy(av3->ac_comm, av2.ac_comm, AC_COMM_LEN);
av3->ac_utime = av2.ac_utime;
av3->ac_stime = av2.ac_stime;
av3->ac_etime = av2.ac_etime;
av3->ac_btime = av2.ac_btime;
av3->ac_uid = av2.ac_uid;
av3->ac_gid = av2.ac_gid;
av3->ac_mem = av2.ac_mem;
av3->ac_io = av2.ac_io;
av3->ac_tty = av2.ac_tty;
av3->ac_flagx = av2.ac_flagx;
return (0);
}
/*
* Read an v2 accounting record stored at the current
* position of stream f.
* Return EOF on error or end-of-file.
*/
static int
readrec_v3(FILE *f, struct acctv3 *av3)
{
return (fread_record(av3, sizeof(*av3), f));
} }
/* /*
@ -132,7 +163,7 @@ readrec_v2(FILE *f, struct acctv2 *av2)
* Return EOF on error or end-of-file. * Return EOF on error or end-of-file.
*/ */
static int static int
readrec_vx(FILE *f, struct acctv2 *av2) readrec_vx(FILE *f, struct acctv3 *av3)
{ {
uint8_t magic, version; uint8_t magic, version;
@ -143,7 +174,9 @@ readrec_vx(FILE *f, struct acctv2 *av2)
return (EOF); return (EOF);
switch (version) { switch (version) {
case 2: case 2:
return (readrec_v2(f, av2)); return (readrec_v2(f, av3));
case 3:
return (readrec_v3(f, av3));
/* Add handling for more versions here. */ /* Add handling for more versions here. */
@ -162,7 +195,7 @@ readrec_vx(FILE *f, struct acctv2 *av2)
* or EOF on error. * or EOF on error.
*/ */
int int
readrec_forward(FILE *f, struct acctv2 *av2) readrec_forward(FILE *f, struct acctv3 *av3)
{ {
int magic, rv; int magic, rv;
@ -172,10 +205,10 @@ readrec_forward(FILE *f, struct acctv2 *av2)
return (EOF); return (EOF);
if (magic != 0) if (magic != 0)
/* Old record format. */ /* Old record format. */
rv = readrec_v1(f, av2); rv = readrec_v1(f, av3);
else else
/* New record formats. */ /* New record formats. */
rv = readrec_vx(f, av2); rv = readrec_vx(f, av3);
return (rv == EOF ? EOF : 1); return (rv == EOF ? EOF : 1);
} }
@ -190,7 +223,7 @@ readrec_forward(FILE *f, struct acctv2 *av2)
* or EOF on error. * or EOF on error.
*/ */
int int
readrec_backward(FILE *f, struct acctv2 *av2) readrec_backward(FILE *f, struct acctv3 *av3)
{ {
off_t pos; off_t pos;
int c; int c;
@ -200,17 +233,20 @@ readrec_backward(FILE *f, struct acctv2 *av2)
return (EOF); return (EOF);
if (pos == 0) if (pos == 0)
return (0); return (0);
if (fseek(f, -roffsetof(struct acctv2, ac_trailer), if (fseek(f, -roffsetof(struct acctv3, ac_trailer),
SEEK_CUR) == EOF || SEEK_CUR) == EOF ||
(c = getc(f)) == EOF) (c = getc(f)) == EOF)
return (EOF); return (EOF);
if (c & ANVER) { if (c & ANVER) {
/* New record formats. */ /*
* New record formats. For v2 and v3 offset from the
* end for ac_len2 should be same.
*/
if (fseeko(f, pos - roffsetof(struct acctv2, ac_len2), if (fseeko(f, pos - roffsetof(struct acctv2, ac_len2),
SEEK_SET) == EOF || SEEK_SET) == EOF ||
fread_record(&len, sizeof(len), f) == EOF || fread_record(&len, sizeof(len), f) == EOF ||
fseeko(f, pos - len, SEEK_SET) == EOF || fseeko(f, pos - len, SEEK_SET) == EOF ||
readrec_vx(f, av2) == EOF || readrec_vx(f, av3) == EOF ||
fseeko(f, pos - len, SEEK_SET) == EOF) fseeko(f, pos - len, SEEK_SET) == EOF)
return (EOF); return (EOF);
else else
@ -218,7 +254,7 @@ readrec_backward(FILE *f, struct acctv2 *av2)
} else { } else {
/* Old record format. */ /* Old record format. */
if (fseeko(f, pos - sizeof(struct acctv1), SEEK_SET) == EOF || if (fseeko(f, pos - sizeof(struct acctv1), SEEK_SET) == EOF ||
readrec_v1(f, av2) == EOF || readrec_v1(f, av3) == EOF ||
fseeko(f, pos - sizeof(struct acctv1), SEEK_SET) == EOF) fseeko(f, pos - sizeof(struct acctv1), SEEK_SET) == EOF)
return (EOF); return (EOF);
else else

View File

@ -255,7 +255,7 @@ ttymode_kvm(void)
/* xt.xt_pgid = ... */ /* xt.xt_pgid = ... */
/* xt.xt_sid = ... */ /* xt.xt_sid = ... */
xt.xt_flags = tty.t_flags; xt.xt_flags = tty.t_flags;
xt.xt_dev = NODEV; xt.xt_dev = (uint32_t)NODEV;
ttyprt(&xt); ttyprt(&xt);
tp = TAILQ_NEXT(&tty, t_list); tp = TAILQ_NEXT(&tty, t_list);
} }

View File

@ -79,7 +79,7 @@ int pacct_update(void);
void pacct_print(void); void pacct_print(void);
/* external functions in readrec.c */ /* external functions in readrec.c */
int readrec_forward(FILE *f, struct acctv2 *av2); int readrec_forward(FILE *f, struct acctv3 *av2);
/* external functions in usrdb.c */ /* external functions in usrdb.c */
int usracct_init(void); int usracct_init(void);

View File

@ -310,7 +310,7 @@ usage(void)
static FILE * static FILE *
acct_load(const char *pn, int wr) acct_load(const char *pn, int wr)
{ {
struct acctv2 ac; struct acctv3 ac;
struct cmdinfo ci; struct cmdinfo ci;
ssize_t rv; ssize_t rv;
FILE *f; FILE *f;