Skip to content

Commit

Permalink
Commit the 64-bit inode project.
Browse files Browse the repository at this point in the history
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


git-svn-id: svn+ssh://svn.freebsd.org/base/head@318736 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
  • Loading branch information
kib committed May 23, 2017
1 parent 085a446 commit f713b08
Show file tree
Hide file tree
Showing 97 changed files with 4,966 additions and 644 deletions.
1 change: 1 addition & 0 deletions cddl/lib/libzfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
#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);
Expand All @@ -247,7 +248,8 @@ uptr internal_stat(const char *path, void *buf) {

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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
4 changes: 3 additions & 1 deletion contrib/openbsm/libbsm/bsm_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
23 changes: 21 additions & 2 deletions include/dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/libarchive/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
# 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}
Expand Down
10 changes: 9 additions & 1 deletion lib/libc/gen/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
40 changes: 20 additions & 20 deletions lib/libc/gen/Symbol.map
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ FBSD_1.0 {
ctermid;
ctermid_r;
daemon;
devname;
devname_r;
getdiskbyname;
dladdr;
dlclose;
Expand Down Expand Up @@ -128,9 +126,6 @@ FBSD_1.0 {
setfsent;
endfsent;
ftok;
ftw;
glob;
globfree;
getbootfile;
getbsize;
cgetset;
Expand Down Expand Up @@ -163,7 +158,6 @@ FBSD_1.0 {
getloadavg;
getlogin;
getlogin_r;
getmntinfo;
setnetgrent;
getnetgrent;
endnetgrent;
Expand Down Expand Up @@ -209,7 +203,6 @@ FBSD_1.0 {
lrand48;
modf;
mrand48;
nftw;
nice;
nlist;
nrand48;
Expand All @@ -220,13 +213,9 @@ FBSD_1.0 {
pclose;
psignal;
raise;
readdir;
readdir_r;
readpassphrase;
getpass;
rewinddir;
scandir;
alphasort;
seed48;
seekdir;
user_from_uid;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};

Expand Down
1 change: 1 addition & 0 deletions lib/libc/gen/closedir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
50 changes: 50 additions & 0 deletions lib/libc/gen/devname-compat11.c
Original file line number Diff line number Diff line change
@@ -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);
Loading

0 comments on commit f713b08

Please sign in to comment.