Date: Tue, 23 May 2017 09:29:05 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318736 - in head: cddl/lib/libzfs contrib/compiler-rt/lib/sanitizer_common contrib/openbsm/libbsm include lib/libarchive lib/libc/gen lib/libc/include lib/libc/sys lib/libkvm lib/libmi... Message-ID: <201705230929.v4N9T5g1028124@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue May 23 09:29:05 2017 New Revision: 318736 URL: https://svnweb.freebsd.org/changeset/base/318736 Log: 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 Added: head/lib/libc/gen/devname-compat11.c (contents, props changed) head/lib/libc/gen/fts-compat11.c - copied, changed from r318735, head/lib/libc/gen/fts.c head/lib/libc/gen/fts-compat11.h - copied, changed from r318735, head/include/fts.h head/lib/libc/gen/ftw-compat11.c - copied, changed from r318735, head/lib/libc/gen/ftw.c head/lib/libc/gen/gen-compat.h (contents, props changed) head/lib/libc/gen/getmntinfo-compat11.c - copied, changed from r318735, head/lib/libc/gen/getmntinfo.c head/lib/libc/gen/glob-compat11.c - copied, changed from r318735, head/lib/libc/gen/glob.c head/lib/libc/gen/glob-compat11.h - copied, changed from r318735, head/include/glob.h head/lib/libc/gen/nftw-compat11.c - copied, changed from r318735, head/lib/libc/gen/nftw.c head/lib/libc/gen/readdir-compat11.c - copied, changed from r318735, head/lib/libc/gen/readdir.c head/lib/libc/gen/scandir-compat11.c - copied, changed from r318735, head/lib/libc/gen/scandir.c head/lib/libc/sys/getdents.c (contents, props changed) head/lib/libc/sys/lstat.c (contents, props changed) head/lib/libc/sys/mknod.c (contents, props changed) head/lib/libc/sys/stat.c (contents, props changed) head/lib/libprocstat/libprocstat_compat.c (contents, props changed) Modified: head/cddl/lib/libzfs/Makefile head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h head/contrib/openbsm/libbsm/bsm_wrappers.c head/include/dirent.h head/lib/libarchive/Makefile head/lib/libc/gen/Makefile.inc head/lib/libc/gen/Symbol.map head/lib/libc/gen/closedir.c head/lib/libc/gen/fts-compat.c head/lib/libc/gen/fts-compat.h head/lib/libc/gen/gen-private.h head/lib/libc/gen/opendir.c head/lib/libc/gen/readdir.c head/lib/libc/gen/scandir.c head/lib/libc/gen/telldir.h head/lib/libc/include/compat.h head/lib/libc/include/libc_private.h head/lib/libc/sys/Makefile.inc head/lib/libc/sys/Symbol.map head/lib/libc/sys/getdirentries.2 head/lib/libc/sys/statfs.2 head/lib/libkvm/kvm_proc.c head/lib/libmilter/Makefile head/lib/libprocstat/Makefile head/lib/libprocstat/Symbol.map head/lib/libprocstat/libprocstat.c head/lib/libprocstat/libprocstat.h head/lib/libufs/libufs.h head/sbin/badsect/badsect.c head/sbin/fsck_ffs/suj.c head/share/man/man5/acct.5 head/share/man/man5/dir.5 head/sys/bsm/audit.h head/sys/cddl/compat/opensolaris/sys/dirent.h head/sys/compat/freebsd32/capabilities.conf head/sys/compat/freebsd32/freebsd32.h head/sys/compat/freebsd32/freebsd32_misc.c head/sys/compat/freebsd32/syscalls.master head/sys/compat/linux/linux_file.c head/sys/dev/snp/snp.c head/sys/fs/devfs/devfs_devs.c head/sys/fs/devfs/devfs_vnops.c head/sys/fs/fdescfs/fdesc_vnops.c head/sys/fs/nandfs/nandfs_fs.h head/sys/fs/nfs/nfsport.h head/sys/fs/nfsclient/nfs_clrpcops.c head/sys/fs/nfsclient/nfs_clvnops.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/kern/capabilities.conf head/sys/kern/kern_acct.c head/sys/kern/kern_descrip.c head/sys/kern/kern_proc.c head/sys/kern/makesyscalls.sh head/sys/kern/sys_socket.c head/sys/kern/syscalls.master head/sys/kern/tty.c head/sys/kern/tty_pts.c head/sys/kern/vfs_syscalls.c head/sys/kern/vfs_vnops.c head/sys/nlm/nlm_advlock.c head/sys/security/audit/audit_private.h head/sys/sys/_types.h head/sys/sys/acct.h head/sys/sys/dirent.h head/sys/sys/mount.h head/sys/sys/param.h head/sys/sys/stat.h head/sys/sys/syscallsubr.h head/sys/sys/tty.h head/sys/sys/user.h head/sys/sys/vnode.h head/sys/vm/swap_pager.c head/sys/vm/vm_object.c head/sys/vm/vm_param.h head/usr.bin/kdump/kdump.c head/usr.bin/lastcomm/lastcomm.c head/usr.bin/lastcomm/readrec.c head/usr.sbin/pstat/pstat.c head/usr.sbin/sa/extern.h head/usr.sbin/sa/main.c Modified: head/cddl/lib/libzfs/Makefile ============================================================================== --- head/cddl/lib/libzfs/Makefile Tue May 23 09:20:31 2017 (r318735) +++ head/cddl/lib/libzfs/Makefile Tue May 23 09:29:05 2017 (r318736) @@ -37,6 +37,7 @@ SRCS+= libzfs_changelist.c \ zprop_common.c \ WARNS?= 0 +SHLIB_MAJOR= 3 CSTD= c99 CFLAGS+= -DZFS_NO_ACL CFLAGS+= -I${SRCTOP}/sbin/mount Modified: head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc ============================================================================== --- head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc Tue May 23 09:20:31 2017 (r318735) +++ head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc Tue May 23 09:29:05 2017 (r318736) @@ -223,7 +223,8 @@ static void kernel_stat_to_stat(struct k uptr internal_stat(const char *path, void *buf) { #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 return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (uptr)buf, 0); @@ -247,7 +248,8 @@ uptr internal_stat(const char *path, voi uptr internal_lstat(const char *path, void *buf) { #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 return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path, (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) { -#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); #else return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count); Modified: head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h ============================================================================== --- head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h Tue May 23 09:20:31 2017 (r318735) +++ head/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h Tue May 23 09:29:05 2017 (r318736) @@ -489,7 +489,8 @@ namespace __sanitizer { }; #elif SANITIZER_FREEBSD struct __sanitizer_dirent { - unsigned int d_fileno; + unsigned long long d_fileno; + unsigned long long d_off; unsigned short d_reclen; // more fields that we don't care about }; Modified: head/contrib/openbsm/libbsm/bsm_wrappers.c ============================================================================== --- head/contrib/openbsm/libbsm/bsm_wrappers.c Tue May 23 09:20:31 2017 (r318735) +++ head/contrib/openbsm/libbsm/bsm_wrappers.c Tue May 23 09:29:05 2017 (r318736) @@ -264,12 +264,14 @@ audit_set_terminal_host(uint32_t *m) int audit_set_terminal_id(au_tid_t *tid) { + dev_t port; int ret; if (tid == NULL) return (kAUBadParamErr); - if ((ret = audit_set_terminal_port(&tid->port)) != kAUNoErr) + if ((ret = audit_set_terminal_port(&port)) != kAUNoErr) return (ret); + tid->port = port; return (audit_set_terminal_host(&tid->machine)); } Modified: head/include/dirent.h ============================================================================== --- head/include/dirent.h Tue May 23 09:20:31 2017 (r318735) +++ head/include/dirent.h Tue May 23 09:29:05 2017 (r318736) @@ -41,6 +41,25 @@ #include <sys/_types.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 #ifndef _INO_T_DECLARED @@ -89,8 +108,8 @@ int dirfd(DIR *); #if __BSD_VISIBLE DIR *__opendir2(const char *, int); int fdclosedir(DIR *); -int getdents(int, char *, int); -int getdirentries(int, char *, int, long *); +ssize_t getdents(int, char *, size_t); +ssize_t getdirentries(int, char *, size_t, off_t *); #endif DIR *opendir(const char *); DIR *fdopendir(int); Modified: head/lib/libarchive/Makefile ============================================================================== --- head/lib/libarchive/Makefile Tue May 23 09:20:31 2017 (r318735) +++ head/lib/libarchive/Makefile Tue May 23 09:29:05 2017 (r318736) @@ -11,7 +11,7 @@ CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA # FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system. # 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+= -I${.OBJDIR} Modified: head/lib/libc/gen/Makefile.inc ============================================================================== --- head/lib/libc/gen/Makefile.inc Tue May 23 09:20:31 2017 (r318735) +++ head/lib/libc/gen/Makefile.inc Tue May 23 09:29:05 2017 (r318736) @@ -148,7 +148,15 @@ SRCS+= __getosreldate.c \ waitid.c \ wordexp.c .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 .endif Modified: head/lib/libc/gen/Symbol.map ============================================================================== --- head/lib/libc/gen/Symbol.map Tue May 23 09:20:31 2017 (r318735) +++ head/lib/libc/gen/Symbol.map Tue May 23 09:29:05 2017 (r318736) @@ -75,8 +75,6 @@ FBSD_1.0 { ctermid; ctermid_r; daemon; - devname; - devname_r; getdiskbyname; dladdr; dlclose; @@ -128,9 +126,6 @@ FBSD_1.0 { setfsent; endfsent; ftok; - ftw; - glob; - globfree; getbootfile; getbsize; cgetset; @@ -163,7 +158,6 @@ FBSD_1.0 { getloadavg; getlogin; getlogin_r; - getmntinfo; setnetgrent; getnetgrent; endnetgrent; @@ -209,7 +203,6 @@ FBSD_1.0 { lrand48; modf; mrand48; - nftw; nice; nlist; nrand48; @@ -220,13 +213,9 @@ FBSD_1.0 { pclose; psignal; raise; - readdir; - readdir_r; readpassphrase; getpass; rewinddir; - scandir; - alphasort; seed48; seekdir; user_from_uid; @@ -314,14 +303,6 @@ FBSD_1.1 { fdevname_r; fdopendir; 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_file_actions_addclose; posix_spawn_file_actions_adddup2; @@ -408,13 +389,32 @@ FBSD_1.4 { pthread_mutex_consistent; pthread_mutexattr_getrobust; pthread_mutexattr_setrobust; - scandir_b; stravis; }; FBSD_1.5 { + alphasort; basename; + devname; + devname_r; 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; }; Modified: head/lib/libc/gen/closedir.c ============================================================================== --- head/lib/libc/gen/closedir.c Tue May 23 09:20:31 2017 (r318735) +++ head/lib/libc/gen/closedir.c Tue May 23 09:29:05 2017 (r318736) @@ -59,6 +59,7 @@ fdclosedir(DIR *dirp) dirp->dd_fd = -1; dirp->dd_loc = 0; free((void *)dirp->dd_buf); + free(dirp->dd_compat_de); _reclaim_telldir(dirp); if (__isthreaded) { _pthread_mutex_unlock(&dirp->dd_lock); Added: head/lib/libc/gen/devname-compat11.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/gen/devname-compat11.c Tue May 23 09:29:05 2017 (r318736) @@ -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); Modified: head/lib/libc/gen/fts-compat.c ============================================================================== --- head/lib/libc/gen/fts-compat.c Tue May 23 09:20:31 2017 (r318735) +++ head/lib/libc/gen/fts-compat.c Tue May 23 09:29:05 2017 (r318736) @@ -40,15 +40,19 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <sys/param.h> +#define _WANT_FREEBSD11_STATFS #include <sys/mount.h> +#define _WANT_FREEBSD11_STAT #include <sys/stat.h> +#define _WANT_FREEBSD11_DIRENT #include <dirent.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "gen-compat.h" #include "fts-compat.h" #include "un-namespace.h" @@ -96,8 +100,8 @@ static int fts_ufslinks(FTS *, const FT */ struct _fts_private { FTS ftsp_fts; - struct statfs ftsp_statfs; - dev_t ftsp_dev; + struct freebsd11_statfs ftsp_statfs; + uint32_t ftsp_dev; int ftsp_linksreliable; }; @@ -626,7 +630,7 @@ __fts_set_clientptr_44bsd(FTS *sp, void static FTSENT * fts_build(FTS *sp, int type) { - struct dirent *dp; + struct freebsd11_dirent *dp; FTSENT *p, *head; int nitems; FTSENT *cur, *tail; @@ -738,7 +742,8 @@ fts_build(FTS *sp, int type) /* Read the directory, attaching each entry to the `link' pointer. */ 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; if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) continue; @@ -891,9 +896,9 @@ static u_short fts_stat(FTS *sp, FTSENT *p, int follow) { FTSENT *t; - dev_t dev; - ino_t ino; - struct stat *sbp, sb; + uint32_t dev; + uint32_t ino; + struct freebsd11_stat *sbp, sb; int saved_errno; /* 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. */ if (ISSET(FTS_LOGICAL) || follow) { - if (stat(p->fts_accpath, sbp)) { + if (freebsd11_stat(p->fts_accpath, sbp)) { saved_errno = errno; - if (!lstat(p->fts_accpath, sbp)) { + if (!freebsd11_lstat(p->fts_accpath, sbp)) { errno = 0; return (FTS_SLNONE); } p->fts_errno = saved_errno; goto err; } - } else if (lstat(p->fts_accpath, sbp)) { + } else if (freebsd11_lstat(p->fts_accpath, sbp)) { p->fts_errno = errno; err: memset(sbp, 0, sizeof(struct stat)); return (FTS_NS); @@ -1019,7 +1024,7 @@ fts_alloc(FTS *sp, char *name, int namel struct ftsent_withstat { 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) { int ret, oerrno, newfd; - struct stat sb; + struct freebsd11_stat sb; newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); if (fd < 0 && (newfd = _open(path, O_RDONLY | O_CLOEXEC, 0)) < 0) return (-1); - if (_fstat(newfd, &sb)) { + if (freebsd11_fstat(newfd, &sb)) { ret = -1; goto bail; } @@ -1187,7 +1192,7 @@ fts_ufslinks(FTS *sp, const FTSENT *ent) * avoidance. */ 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_linksreliable = 0; for (cpp = ufslike_filesystems; *cpp; cpp++) { Modified: head/lib/libc/gen/fts-compat.h ============================================================================== --- head/lib/libc/gen/fts-compat.h Tue May 23 09:20:31 2017 (r318735) +++ head/lib/libc/gen/fts-compat.h Tue May 23 09:29:05 2017 (r318736) @@ -37,7 +37,7 @@ typedef struct { struct _ftsent *fts_cur; /* current node */ struct _ftsent *fts_child; /* linked list of children */ 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 */ int fts_rfd; /* fd for root */ int fts_pathlen; /* sizeof(path) */ @@ -82,9 +82,9 @@ typedef struct _ftsent { u_short fts_pathlen; /* strlen(fts_path) */ u_short fts_namelen; /* strlen(fts_name) */ - ino_t fts_ino; /* inode */ - dev_t fts_dev; /* device */ - nlink_t fts_nlink; /* link count */ + uint32_t fts_ino; /* inode */ + uint32_t fts_dev; /* device */ + uint16_t fts_nlink; /* link count */ #define FTS_ROOTPARENTLEVEL -1 #define FTS_ROOTLEVEL 0 @@ -117,7 +117,7 @@ typedef struct _ftsent { #define FTS_SKIP 4 /* discard node */ 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 */ FTS *fts_fts; /* back pointer to main FTS */ } FTSENT; Copied and modified: head/lib/libc/gen/fts-compat11.c (from r318735, head/lib/libc/gen/fts.c) ============================================================================== --- head/lib/libc/gen/fts.c Tue May 23 09:20:31 2017 (r318735, copy source) +++ head/lib/libc/gen/fts-compat11.c Tue May 23 09:29:05 2017 (r318736) @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ + * from: $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $ */ #if 0 @@ -40,9 +40,12 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <sys/param.h> +#define _WANT_FREEBSD11_STATFS #include <sys/mount.h> +#define _WANT_FREEBSD11_STAT #include <sys/stat.h> +#define _WANT_FREEBSD11_DIRENT #include <dirent.h> #include <errno.h> #include <fcntl.h> @@ -50,21 +53,23 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "gen-compat.h" +#include "fts-compat11.h" #include "un-namespace.h" #include "gen-private.h" -static FTSENT *fts_alloc(FTS *, char *, size_t); -static FTSENT *fts_build(FTS *, int); -static void fts_lfree(FTSENT *); -static void fts_load(FTS *, FTSENT *); +static FTSENT11 *fts_alloc(FTS11 *, char *, size_t); +static FTSENT11 *fts_build(FTS11 *, int); +static void fts_lfree(FTSENT11 *); +static void fts_load(FTS11 *, FTSENT11 *); static size_t fts_maxarglen(char * const *); -static void fts_padjust(FTS *, FTSENT *); -static int fts_palloc(FTS *, size_t); -static FTSENT *fts_sort(FTS *, FTSENT *, size_t); -static int fts_stat(FTS *, FTSENT *, int, int); -static int fts_safe_changedir(FTS *, FTSENT *, int, char *); -static int fts_ufslinks(FTS *, const FTSENT *); +static void fts_padjust(FTS11 *, FTSENT11 *); +static int fts_palloc(FTS11 *, size_t); +static FTSENT11 *fts_sort(FTS11 *, FTSENT11 *, size_t); +static int fts_stat(FTS11 *, FTSENT11 *, int, int); +static int fts_safe_changedir(FTS11 *, FTSENT11 *, int, char *); +static int fts_ufslinks(FTS11 *, const FTSENT11 *); #define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) @@ -84,10 +89,10 @@ static int fts_ufslinks(FTS *, const FT * details. The FTS returned from fts_open points to this structure's * ftsp_fts member (and can be cast to an _fts_private as required) */ -struct _fts_private { - FTS ftsp_fts; - struct statfs ftsp_statfs; - dev_t ftsp_dev; +struct _fts_private11 { + FTS11 ftsp_fts; + struct freebsd11_statfs ftsp_statfs; + uint32_t ftsp_dev; int ftsp_linksreliable; }; @@ -108,14 +113,14 @@ static const char *ufslike_filesystems[] 0 }; -FTS * -fts_open(char * const *argv, int options, - int (*compar)(const FTSENT * const *, const FTSENT * const *)) +FTS11 * +freebsd11_fts_open(char * const *argv, int options, + int (*compar)(const FTSENT11 * const *, const FTSENT11 * const *)) { - struct _fts_private *priv; - FTS *sp; - FTSENT *p, *root; - FTSENT *parent, *tmp; + struct _fts_private11 *priv; + FTS11 *sp; + FTSENT11 *p, *root; + FTSENT11 *parent, *tmp; size_t len, nitems; /* Options check. */ @@ -221,7 +226,7 @@ mem1: free(sp); } static void -fts_load(FTS *sp, FTSENT *p) +fts_load(FTS11 *sp, FTSENT11 *p) { size_t len; char *cp; @@ -245,9 +250,9 @@ fts_load(FTS *sp, FTSENT *p) } int -fts_close(FTS *sp) +freebsd11_fts_close(FTS11 *sp) { - FTSENT *freep, *p; + FTSENT11 *freep, *p; int saved_errno; /* @@ -298,10 +303,10 @@ fts_close(FTS *sp) (p->fts_path[p->fts_pathlen - 1] == '/' \ ? p->fts_pathlen - 1 : p->fts_pathlen) -FTSENT * -fts_read(FTS *sp) +FTSENT11 * +freebsd11_fts_read(FTS11 *sp) { - FTSENT *p, *tmp; + FTSENT11 *p, *tmp; int instr; char *t; int saved_errno; @@ -497,7 +502,7 @@ name: t = sp->fts_path + NAPPEND(p->fts */ /* ARGSUSED */ int -fts_set(FTS *sp, FTSENT *p, int instr) +freebsd11_fts_set(FTS11 *sp, FTSENT11 *p, int instr) { if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW && instr != FTS_NOINSTR && instr != FTS_SKIP) { @@ -508,10 +513,10 @@ fts_set(FTS *sp, FTSENT *p, int instr) return (0); } -FTSENT * -fts_children(FTS *sp, int instr) +FTSENT11 * +freebsd11_fts_children(FTS11 *sp, int instr) { - FTSENT *p; + FTSENT11 *p; int fd, rc, serrno; if (instr != 0 && instr != FTS_NAMEONLY) { @@ -579,29 +584,29 @@ fts_children(FTS *sp, int instr) return (sp->fts_child); } -#ifndef fts_get_clientptr -#error "fts_get_clientptr not defined" +#ifndef freebsd11_fts_get_clientptr +#error "freebsd11_fts_get_clientptr not defined" #endif void * -(fts_get_clientptr)(FTS *sp) +(freebsd11_fts_get_clientptr)(FTS11 *sp) { - return (fts_get_clientptr(sp)); + return (freebsd11_fts_get_clientptr(sp)); } -#ifndef fts_get_stream -#error "fts_get_stream not defined" +#ifndef freebsd11_fts_get_stream +#error "freebsd11_fts_get_stream not defined" #endif -FTS * -(fts_get_stream)(FTSENT *p) +FTS11 * +(freebsd11_fts_get_stream)(FTSENT11 *p) { - return (fts_get_stream(p)); + return (freebsd11_fts_get_stream(p)); } void -fts_set_clientptr(FTS *sp, void *clientptr) +freebsd11_fts_set_clientptr(FTS11 *sp, void *clientptr) { sp->fts_clientptr = clientptr; @@ -621,12 +626,12 @@ fts_set_clientptr(FTS *sp, void *clientp * directories and for any files after the subdirectories in the directory have * been found, cutting the stat calls by about 2/3. */ -static FTSENT * -fts_build(FTS *sp, int type) +static FTSENT11 * +fts_build(FTS11 *sp, int type) { - struct dirent *dp; - FTSENT *p, *head; - FTSENT *cur, *tail; + struct freebsd11_dirent *dp; + FTSENT11 *p, *head; + FTSENT11 *cur, *tail; DIR *dirp; void *oldaddr; char *cp; @@ -736,7 +741,8 @@ fts_build(FTS *sp, int type) /* Read the directory, attaching each entry to the `link' pointer. */ 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; if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) continue; @@ -870,12 +876,12 @@ mem1: saved_errno = errno; } static int -fts_stat(FTS *sp, FTSENT *p, int follow, int dfd) +fts_stat(FTS11 *sp, FTSENT11 *p, int follow, int dfd) { - FTSENT *t; - dev_t dev; - ino_t ino; - struct stat *sbp, sb; + FTSENT11 *t; + uint32_t dev; + uint32_t ino; + struct freebsd11_stat *sbp, sb; int saved_errno; const char *path; @@ -904,9 +910,10 @@ fts_stat(FTS *sp, FTSENT *p, int follow, * fail, set the errno from the stat call. */ if (ISSET(FTS_LOGICAL) || follow) { - if (fstatat(dfd, path, sbp, 0)) { + if (freebsd11_fstatat(dfd, path, sbp, 0)) { saved_errno = errno; - if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) { + if (freebsd11_fstatat(dfd, path, sbp, + AT_SYMLINK_NOFOLLOW)) { p->fts_errno = saved_errno; goto err; } @@ -914,9 +921,9 @@ fts_stat(FTS *sp, FTSENT *p, int follow, if (S_ISLNK(sbp->st_mode)) return (FTS_SLNONE); } - } else if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) { + } else if (freebsd11_fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) { p->fts_errno = errno; -err: memset(sbp, 0, sizeof(struct stat)); +err: memset(sbp, 0, sizeof(*sbp)); return (FTS_NS); } @@ -965,16 +972,16 @@ err: memset(sbp, 0, sizeof(struct stat) static int fts_compar(const void *a, const void *b) { - FTS *parent; + FTS11 *parent; - parent = (*(const FTSENT * const *)a)->fts_fts; + parent = (*(const FTSENT11 * const *)a)->fts_fts; return (*parent->fts_compar)(a, b); } -static FTSENT * -fts_sort(FTS *sp, FTSENT *head, size_t nitems) +static FTSENT11 * +fts_sort(FTS11 *sp, FTSENT11 *head, size_t nitems) { - FTSENT **ap, *p; + FTSENT11 **ap, *p; /* * Construct an array of pointers to the structures and call qsort(3). @@ -986,29 +993,29 @@ fts_sort(FTS *sp, FTSENT *head, size_t n if (nitems > sp->fts_nitems) { sp->fts_nitems = nitems + 40; if ((sp->fts_array = reallocf(sp->fts_array, - sp->fts_nitems * sizeof(FTSENT *))) == NULL) { + sp->fts_nitems * sizeof(FTSENT11 *))) == NULL) { sp->fts_nitems = 0; return (head); } } for (ap = sp->fts_array, p = head; p; p = p->fts_link) *ap++ = p; - qsort(sp->fts_array, nitems, sizeof(FTSENT *), fts_compar); + qsort(sp->fts_array, nitems, sizeof(FTSENT11 *), fts_compar); for (head = *(ap = sp->fts_array); --nitems; ++ap) ap[0]->fts_link = ap[1]; ap[0]->fts_link = NULL; return (head); } -static FTSENT * -fts_alloc(FTS *sp, char *name, size_t namelen) +static FTSENT11 * +fts_alloc(FTS11 *sp, char *name, size_t namelen) { - FTSENT *p; + FTSENT11 *p; size_t len; - struct ftsent_withstat { - FTSENT ent; - struct stat statbuf; + struct ftsent11_withstat { + FTSENT11 ent; + struct freebsd11_stat statbuf; }; /* @@ -1018,9 +1025,9 @@ fts_alloc(FTS *sp, char *name, size_t na * be careful that the stat structure is reasonably aligned. */ if (ISSET(FTS_NOSTAT)) - len = sizeof(FTSENT) + namelen + 1; + len = sizeof(FTSENT11) + namelen + 1; else - len = sizeof(struct ftsent_withstat) + namelen + 1; + len = sizeof(struct ftsent11_withstat) + namelen + 1; if ((p = malloc(len)) == NULL) return (NULL); @@ -1029,8 +1036,8 @@ fts_alloc(FTS *sp, char *name, size_t na p->fts_name = (char *)(p + 1); p->fts_statp = NULL; } else { - p->fts_name = (char *)((struct ftsent_withstat *)p + 1); - p->fts_statp = &((struct ftsent_withstat *)p)->statbuf; + p->fts_name = (char *)((struct ftsent11_withstat *)p + 1); + p->fts_statp = &((struct ftsent11_withstat *)p)->statbuf; } /* Copy the name and guarantee NUL termination. */ @@ -1048,9 +1055,9 @@ fts_alloc(FTS *sp, char *name, size_t na } static void -fts_lfree(FTSENT *head) +fts_lfree(FTSENT11 *head) { - FTSENT *p; + FTSENT11 *p; /* Free a linked list of structures. */ while ((p = head)) { @@ -1066,7 +1073,7 @@ fts_lfree(FTSENT *head) * plus 256 bytes so don't realloc the path 2 bytes at a time. */ static int -fts_palloc(FTS *sp, size_t more) +fts_palloc(FTS11 *sp, size_t more) { sp->fts_pathlen += more + 256; @@ -1079,9 +1086,9 @@ fts_palloc(FTS *sp, size_t more) * already returned. */ static void -fts_padjust(FTS *sp, FTSENT *head) +fts_padjust(FTS11 *sp, FTSENT11 *head) { - FTSENT *p; + FTSENT11 *p; char *addr = sp->fts_path; #define ADJUST(p) do { \ @@ -1119,10 +1126,10 @@ fts_maxarglen(char * const *argv) * Assumes p->fts_dev and p->fts_ino are filled in. */ static int -fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path) +fts_safe_changedir(FTS11 *sp, FTSENT11 *p, int fd, char *path) { int ret, oerrno, newfd; - struct stat sb; + struct freebsd11_stat sb; newfd = fd; if (ISSET(FTS_NOCHDIR)) @@ -1130,7 +1137,7 @@ fts_safe_changedir(FTS *sp, FTSENT *p, i if (fd < 0 && (newfd = _open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC, 0)) < 0) return (-1); - if (_fstat(newfd, &sb)) { + if (freebsd11_fstat(newfd, &sb)) { ret = -1; goto bail; } @@ -1152,12 +1159,12 @@ bail: * Check if the filesystem for "ent" has UFS-style links. */ static int -fts_ufslinks(FTS *sp, const FTSENT *ent) +fts_ufslinks(FTS11 *sp, const FTSENT11 *ent) { - struct _fts_private *priv; + struct _fts_private11 *priv; const char **cpp; - priv = (struct _fts_private *)sp; + priv = (struct _fts_private11 *)sp; /* * If this node's device is different from the previous, grab * the filesystem information, and decide on the reliability @@ -1165,7 +1172,7 @@ fts_ufslinks(FTS *sp, const FTSENT *ent) * avoidance. */ 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_linksreliable = 0; for (cpp = ufslike_filesystems; *cpp; cpp++) { @@ -1181,3 +1188,12 @@ fts_ufslinks(FTS *sp, const FTSENT *ent) } return (priv->ftsp_linksreliable); } + +__sym_compat(fts_open, freebsd11_fts_open, FBSD_1.1); +__sym_compat(fts_close, freebsd11_fts_close, FBSD_1.1); +__sym_compat(fts_read, freebsd11_fts_read, FBSD_1.1); +__sym_compat(fts_set, freebsd11_fts_set, FBSD_1.1); +__sym_compat(fts_children, freebsd11_fts_children, FBSD_1.1); +__sym_compat(fts_get_clientptr, freebsd11_fts_get_clientptr, FBSD_1.1); +__sym_compat(fts_get_stream, freebsd11_fts_get_stream, FBSD_1.1); +__sym_compat(fts_set_clientptr, freebsd11_fts_set_clientptr, FBSD_1.1); Copied and modified: head/lib/libc/gen/fts-compat11.h (from r318735, head/include/fts.h) ============================================================================== --- head/include/fts.h Tue May 23 09:20:31 2017 (r318735, copy source) +++ head/lib/libc/gen/fts-compat11.h Tue May 23 09:29:05 2017 (r318736) @@ -30,45 +30,30 @@ * $FreeBSD$ */ -#ifndef _FTS_H_ -#define _FTS_H_ - -#include <sys/_types.h> +#ifndef _FTS_COPMAT11_H_ +#define _FTS_COPMAT11_H_ typedef struct { - struct _ftsent *fts_cur; /* current node */ - struct _ftsent *fts_child; /* linked list of children */ - struct _ftsent **fts_array; /* sort array */ - __dev_t fts_dev; /* starting device # */ + 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 _ftsent * const *, const struct _ftsent * const *); - -#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ -#define FTS_LOGICAL 0x002 /* logical walk */ -#define FTS_NOCHDIR 0x004 /* don't change directories */ -#define FTS_NOSTAT 0x008 /* don't get stat info */ -#define FTS_PHYSICAL 0x010 /* physical walk */ -#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ -#define FTS_XDEV 0x040 /* don't cross devices */ -#define FTS_WHITEOUT 0x080 /* return whiteout information */ -#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ - -#define FTS_NAMEONLY 0x100 /* (private) child names only */ -#define FTS_STOP 0x200 /* (private) unrecoverable error */ + (const struct _ftsent11 * const *, + const struct _ftsent11 * const *); int fts_options; /* fts_open options, global flags */ void *fts_clientptr; /* thunk for sort function */ -} FTS; +} FTS11; -typedef struct _ftsent { - struct _ftsent *fts_cycle; /* cycle node */ - struct _ftsent *fts_parent; /* parent directory */ - struct _ftsent *fts_link; /* next file in directory */ +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 */ -#define fts_bignum fts_number /* XXX non-std, should go away */ void *fts_pointer; /* local address value */ char *fts_accpath; /* access path */ char *fts_path; /* root path */ @@ -77,60 +62,34 @@ typedef struct _ftsent { __size_t fts_pathlen; /* strlen(fts_path) */ __size_t fts_namelen; /* strlen(fts_name) */ - __ino_t fts_ino; /* inode */ - __dev_t fts_dev; /* device */ - __nlink_t fts_nlink; /* link count */ + uint32_t fts_ino; /* inode */ + uint32_t fts_dev; /* device */ + uint16_t fts_nlink; /* link count */ -#define FTS_ROOTPARENTLEVEL -1 -#define FTS_ROOTLEVEL 0 long fts_level; /* depth (-1 to N) */ -#define FTS_D 1 /* preorder directory */ -#define FTS_DC 2 /* directory that causes cycles */ -#define FTS_DEFAULT 3 /* none of the above */ -#define FTS_DNR 4 /* unreadable directory */ -#define FTS_DOT 5 /* dot or dot-dot */ -#define FTS_DP 6 /* postorder directory */ -#define FTS_ERR 7 /* error; errno is set */ -#define FTS_F 8 /* regular file */ -#define FTS_INIT 9 /* initialized only */ -#define FTS_NS 10 /* stat(2) failed */ -#define FTS_NSOK 11 /* no stat(2) requested */ -#define FTS_SL 12 /* symbolic link */ -#define FTS_SLNONE 13 /* symbolic link without target */ -#define FTS_W 14 /* whiteout object */ int fts_info; /* user status for FTSENT structure */ -#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ -#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ -#define FTS_ISW 0x04 /* this is a whiteout object */ unsigned fts_flags; /* private flags for FTSENT structure */ -#define FTS_AGAIN 1 /* read node again */ -#define FTS_FOLLOW 2 /* follow symbolic link */ -#define FTS_NOINSTR 3 /* no instructions */ -#define FTS_SKIP 4 /* discard node */ int fts_instr; /* fts_set() instructions */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705230929.v4N9T5g1028124>