From: Paul Floyd Date: Tue, 24 Jan 2023 19:38:26 +0000 (+0100) Subject: FreeBSD: switch to FreeBSD 12 versions of syscalls for fstat etc X-Git-Tag: VALGRIND_3_21_0~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7886c072e1bc7939c22ab445ac0a9a0625737a78;p=thirdparty%2Fvalgrind.git FreeBSD: switch to FreeBSD 12 versions of syscalls for fstat etc This was a change that enabled 64bit inodes (ino64). Also a couple of typos in READMEs. --- diff --git a/README_DEVELOPERS b/README_DEVELOPERS index 86f539bb6f..6f7d1a9eee 100644 --- a/README_DEVELOPERS +++ b/README_DEVELOPERS @@ -136,7 +136,7 @@ A different and possibly easier way is as follows: (2) In a different shell, do "gdb /proc//exe ", where you read from the output printed by (1). This attaches - GDB to the tool executable, which should be in the abovementioned + GDB to the tool executable, which should be in the above mentioned wait loop. (3) Do "cont" to continue. After the loop finishes spinning, startup diff --git a/README_MISSING_SYSCALL_OR_IOCTL b/README_MISSING_SYSCALL_OR_IOCTL index 0019951e75..8ddced5c99 100644 --- a/README_MISSING_SYSCALL_OR_IOCTL +++ b/README_MISSING_SYSCALL_OR_IOCTL @@ -19,7 +19,7 @@ What are syscall/ioctl wrappers? What do they do? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Valgrind does what it does, in part, by keeping track of everything your program does. When a system call happens, for example a request to read -part of a file, control passes to the Linux kernel, which fulfills the +part of a file, control passes to the Linux kernel, which fulfils the request, and returns control to your program. The problem is that the kernel will often change the status of some part of your program's memory as a result, and tools (instrumentation plug-ins) may need to know about @@ -29,7 +29,7 @@ Syscall and ioctl wrappers have two jobs: 1. Tell a tool what's about to happen, before the syscall takes place. A tool could perform checks beforehand, eg. if memory about to be written - is actually writeable. This part is useful, but not strictly + is actually writable. This part is useful, but not strictly essential. 2. Tell a tool what just happened, after a syscall takes place. This is diff --git a/coregrind/m_aspacemgr/aspacemgr-common.c b/coregrind/m_aspacemgr/aspacemgr-common.c index 282cc50d70..816d2274f4 100644 --- a/coregrind/m_aspacemgr/aspacemgr-common.c +++ b/coregrind/m_aspacemgr/aspacemgr-common.c @@ -386,10 +386,11 @@ Bool ML_(am_get_fd_d_i_m)( Int fd, } return False; # elif defined(VGO_freebsd) +#if (FREEBSD_VERS < FREEBSD_12) struct vki_freebsd11_stat buf; -#if (FREEBSD_VERS >= FREEBSD_12) - SysRes res = VG_(do_syscall2)(__NR_freebsd11_fstat, fd, (UWord)&buf); + SysRes res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf); #else + struct vki_stat buf; SysRes res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf); #endif if (!sr_isError(res)) { diff --git a/coregrind/m_libcfile.c b/coregrind/m_libcfile.c index 84de11a5c8..aad0cb199c 100644 --- a/coregrind/m_libcfile.c +++ b/coregrind/m_libcfile.c @@ -260,8 +260,13 @@ SysRes VG_(mknod) ( const HChar* pathname, Int mode, UWord dev ) SysRes res = VG_(do_syscall3)(__NR_mknod, (UWord)pathname, mode, dev); # elif defined(VGO_freebsd) +#if (FREEBSD_VERS < FREEBSD_12) SysRes res = VG_(do_syscall3)(__NR_freebsd11_mknod, (UWord)pathname, mode, dev); +#else + SysRes res = VG_(do_syscall4)(__NR_mknodat, VKI_AT_FDCWD, + (UWord)pathname, mode, dev); +#endif # elif defined(VGO_solaris) SysRes res = VG_(do_syscall4)(__NR_mknodat, VKI_AT_FDCWD, (UWord)pathname, mode, dev); @@ -556,11 +561,12 @@ SysRes VG_(stat) ( const HChar* file_name, struct vg_stat* vgbuf ) } # elif defined(VGO_freebsd) { +#if (FREEBSD_VERS < FREEBSD_12) struct vki_freebsd11_stat buf; -#if (FREEBSD_VERS >= FREEBSD_12) - res = VG_(do_syscall2)(__NR_freebsd11_stat, (UWord)file_name, (UWord)&buf); -#else res = VG_(do_syscall2)(__NR_stat, (UWord)file_name, (UWord)&buf); +#else + struct vki_stat buf; + res = VG_(do_syscall4)(__NR_fstatat, VKI_AT_FDCWD, (UWord)file_name, (UWord)&buf, 0); #endif if (!sr_isError(res)) { TRANSLATE_TO_vg_stat(vgbuf, &buf); @@ -632,10 +638,11 @@ Int VG_(fstat) ( Int fd, struct vg_stat* vgbuf ) } # elif defined(VGO_freebsd) { +#if (FREEBSD_VERS < FREEBSD_12) struct vki_freebsd11_stat buf; -#if (FREEBSD_VERS >= FREEBSD_12) - res = VG_(do_syscall2)(__NR_freebsd11_fstat, (RegWord)fd, (RegWord)(Addr)&buf); + res = VG_(do_syscall2)(__NR_fstat, (RegWord)fd, (RegWord)(Addr)&buf); #else + struct vki_stat buf; res = VG_(do_syscall2)(__NR_fstat, (RegWord)fd, (RegWord)(Addr)&buf); #endif if (!sr_isError(res)) { @@ -655,11 +662,12 @@ SysRes VG_(lstat) ( const HChar* file_name, struct vg_stat* vgbuf ) SysRes res; VG_(memset)(vgbuf, 0, sizeof(*vgbuf)); +#if (FREEBSD_VERS < FREEBSD_12) struct vki_freebsd11_stat buf; -#if (FREEBSD_VERS >= FREEBSD_12) - res = VG_(do_syscall2)(__NR_freebsd11_lstat, (UWord)file_name, (UWord)&buf); -#else res = VG_(do_syscall2)(__NR_lstat, (UWord)file_name, (UWord)&buf); +#else + struct vki_stat buf; + res = VG_(do_syscall4)(__NR_fstatat, VKI_AT_FDCWD, (UWord)file_name, (UWord)&buf, VKI_AT_SYMLINK_NOFOLLOW); #endif if (!sr_isError(res)) { TRANSLATE_TO_vg_stat(vgbuf, &buf); diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h index a7344242e9..2bbaa44188 100644 --- a/include/vki/vki-freebsd.h +++ b/include/vki/vki-freebsd.h @@ -1558,6 +1558,8 @@ struct vki_dirent { #define VKI_O_SEARCH O_EXEC #define VKI_AT_FDCWD AT_FDCWD +#define VKI_AT_SYMLINK_NOFOLLOW 0x0200 + #define VKI_F_DUPFD 0 /* dup */ #define VKI_F_GETFD 1 /* get close_on_exec */