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.
This commit is contained in:
Paul Floyd
2023-01-24 20:38:26 +01:00
parent 5a6f1c1322
commit 7886c072e1
5 changed files with 24 additions and 13 deletions

View File

@@ -136,7 +136,7 @@ A different and possibly easier way is as follows:
(2) In a different shell, do "gdb /proc/<pid>/exe <pid>", where
<pid> 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

View File

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

View File

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

View File

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

View File

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