/none/tests/linux/mremap6
/none/tests/linux/open_client
/none/tests/linux/pthread-stack
+/none/tests/linux/readlinkat_self
/none/tests/linux/stack-overflow
/none/tests/linux/getdents_filter
&& (VG_STREQ(arg1s, name) || VG_STREQ(arg1s, SELF_EXEPATH))) {
HChar* out_name = (HChar*)ARG2;
SizeT res = VG_(strlen)(VG_(resolved_exename));
+ res = VG_MIN(res, ARG3);
VG_(strncpy)(out_name, VG_(resolved_exename), res);
SET_STATUS_Success(res);
fuse_may_block = False;
ML_(fd_at_check_allowed)(SARG1, (const HChar*)ARG2, "readlinkat", tid, status);
PRE_MEM_RASCIIZ( "readlinkat(path)", ARG2 );
PRE_MEM_WRITE( "readlinkat(buf)", ARG3,ARG4 );
-}
-POST(sys_readlinkat)
-{
+ Bool fuse_may_block = True;
HChar name[30]; // large enough
- Word saved = SYSNO;
- // @todo PJF why is this done in POST and not in PRE?
/*
* Handle the case where readlinkat is looking at /proc/self/exe or
* /proc/<pid>/exe.
if (ML_(safe_to_deref)((void*)(Addr)ARG2, 1)
&& (VG_(strcmp)((HChar *)(Addr)ARG2, name) == 0
|| VG_(strcmp)((HChar *)(Addr)ARG2, "/proc/self/exe") == 0)) {
- VG_(sprintf)(name, "/proc/self/fd/%d", VG_(cl_exec_fd));
- SET_STATUS_from_SysRes( VG_(do_syscall4)(saved, ARG1, (UWord)name,
- ARG3, ARG4));
+ HChar* out_name = (HChar*)ARG3;
+ SizeT res = VG_(strlen)(VG_(resolved_exename));
+ res = VG_MIN(res, ARG4);
+ VG_(strncpy)(out_name, VG_(resolved_exename), res);
+ SET_STATUS_Success(res);
+ fuse_may_block = False;
}
- if (SUCCESS && RES > 0)
- POST_MEM_WRITE( ARG3, RES );
+ if (fuse_may_block)
+ FUSE_COMPATIBLE_MAY_BLOCK();
+}
+
+POST(sys_readlinkat)
+{
+ POST_MEM_WRITE( ARG3, RES );
}
PRE(sys_fchmodat)
char resolved[PATH_MAX];
realpath(argv[0], resolved);
assert(strcmp(resolved, buf) == 0);
+
+ const size_t small_buf_size = 11;
+ char small_buf[11];
+ memset(small_buf, '#', 11);
+#if defined(VGO_solaris)
+ ret = readlink("/proc/self/path/a.out", small_buf, 10);
+#else
+ ret = readlink("/proc/self/exe", small_buf, 10);
+#endif
+ assert(strncmp(resolved, small_buf, 10) == 0);
+ assert(small_buf[10] == '#');
+
}
mremap6.stderr.exp mremap6.vgtest \
open_client.stderr.exp open_client.vgtest \
pthread-stack.stderr.exp pthread-stack.vgtest \
+ readlinkat_self.stderr.exp readlinkat_self.vgtest \
stack-overflow.stderr.exp stack-overflow.vgtest
check_PROGRAMS = \
mremap5 \
mremap6 \
pthread-stack \
+ readlinkat_self \
stack-overflow
if HAVE_OPENAT2