From: Paul Floyd Date: Wed, 16 Apr 2025 18:31:38 +0000 (+0200) Subject: Illumos: changes for --modify-fds X-Git-Tag: VALGRIND_3_25_0~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99787e6488f9368c380a4586911d22e9750a5546;p=thirdparty%2Fvalgrind.git Illumos: changes for --modify-fds This is the minumum just to get the new testcase to build and pass. Need to go through the other fd related syscalls later. --- diff --git a/.gitignore b/.gitignore index 43b5d9b6b..fa0fa0d34 100644 --- a/.gitignore +++ b/.gitignore @@ -1670,6 +1670,7 @@ /none/tests/timestamp /none/tests/tls /none/tests/track-fds-exec-children +/none/tests/track_new /none/tests/unit_debuglog /none/tests/use_after_close /none/tests/valgrind_cpp_test diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c index dc0068d90..6b61a0e0d 100644 --- a/coregrind/m_syswrap/syswrap-solaris.c +++ b/coregrind/m_syswrap/syswrap-solaris.c @@ -1775,6 +1775,8 @@ PRE(sys_open) POST(sys_open) { + POST_newFd_RES; + if (!ML_(fd_allowed)(RES, "open", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index c2b36e33c..227540773 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -269,7 +269,7 @@ EXTRA_DIST = \ fdbaduse.stderr.exp fdbaduse.vgtest \ use_after_close.stderr.exp use_after_close.vgtest \ track_new.stderr.exp track_new.stdout.exp \ - track_new.stderr.exp.debian32 track_new.vgtest + track_new.stderr.exp.debian32 track_new.vgtest track_new.stderr.exp-illumos check_PROGRAMS = \ diff --git a/none/tests/cmdline1.stdout.exp-non-linux b/none/tests/cmdline1.stdout.exp-non-linux index f0534f824..d36db3976 100644 --- a/none/tests/cmdline1.stdout.exp-non-linux +++ b/none/tests/cmdline1.stdout.exp-non-linux @@ -30,6 +30,7 @@ usage: valgrind [options] prog-and-args startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] all includes reporting inherited file descriptors + --modify-fds=no|high modify newly open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd= log messages to file descriptor [2=stderr] --log-file= log messages to diff --git a/none/tests/cmdline2.stdout.exp-non-linux b/none/tests/cmdline2.stdout.exp-non-linux index e518644ab..5a44b3bfa 100644 --- a/none/tests/cmdline2.stdout.exp-non-linux +++ b/none/tests/cmdline2.stdout.exp-non-linux @@ -30,6 +30,7 @@ usage: valgrind [options] prog-and-args startup exit abexit valgrindabexit all none --track-fds=no|yes|all track open file descriptors? [no] all includes reporting inherited file descriptors + --modify-fds=no|high modify newly open file descriptors? [no] --time-stamp=no|yes add timestamps to log messages? [no] --log-fd= log messages to file descriptor [2=stderr] --log-file= log messages to diff --git a/none/tests/track_new.c b/none/tests/track_new.c index 544ccacb3..e4bb546fb 100644 --- a/none/tests/track_new.c +++ b/none/tests/track_new.c @@ -1,9 +1,12 @@ +#define _XOPEN_SOURCE 700 + #include #include #include +#include int -main () +main (void) { int oldfd = open ("foobar.txt", O_RDWR|O_CREAT, S_IRUSR | S_IWUSR); /*... do something with oldfd ...*/ diff --git a/none/tests/track_new.stderr.exp-illumos b/none/tests/track_new.stderr.exp-illumos new file mode 100644 index 000000000..670530b60 --- /dev/null +++ b/none/tests/track_new.stderr.exp-illumos @@ -0,0 +1,10 @@ +File descriptor was closed already + at 0x........: fdopen (in /...libc...) + by 0x........: vdprintf (in /...libc...) + by 0x........: dprintf (in /...libc...) + by 0x........: main + Previously closed + at 0x........: close (in /...libc...) + by 0x........: main + Originally opened + at 0x........: main (track_new.c:11) diff --git a/none/tests/track_new.vgtest b/none/tests/track_new.vgtest index f6f72d880..cad64c5ea 100644 --- a/none/tests/track_new.vgtest +++ b/none/tests/track_new.vgtest @@ -2,3 +2,5 @@ prog: track_new prereq: test -x track_new vgopts: -q --track-fds=yes --modify-fds=high stderr_filter: filter_fdleak +cleanup: rm -f foobad.txt foobar.txt +