Skip to content

Commit

Permalink
Merge branch 'development' into documentation_polish
Browse files Browse the repository at this point in the history
  • Loading branch information
petersilva committed Aug 6, 2024
2 parents c19f4fe + b3e6bf5 commit f947db9
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 11 deletions.
4 changes: 3 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ metpx-sr3c (3.24.07rc1) unstable; urgency=medium
* README revised to reflect that cpump is not resilient to failure.
* fix #133 read some non-utf8 fields (instead of erroring.)
* last tx/rx should be cumulative, reset less often.
* fix SR_DEBUG_LOGS being broken by addition of context to api signature
* tests working on RedHat 8 and 9

-- peter <[email protected]> Tue, 15 Jan 2024 08:26:22 -0500
-- Reid Sunderland <[email protected]> Mon, 29 Jul 2024 15:06:22 -0600

metpx-sr3c (3.23.11p3) unstable; urgency=medium

Expand Down
36 changes: 26 additions & 10 deletions libsr3shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <math.h>
#include <stdarg.h>
#include <errno.h>
Expand Down Expand Up @@ -925,10 +926,11 @@ int renameorlink(int olddirfd, const char *oldpath, int newdirfd,
sr_shimdebug_msg(1, " renameorlink using renameat2\n");
status = renameat2_fn_ptr(olddirfd, oldpath, newdirfd, newpath, flags);
} else if (renameat_fn_ptr && !flags) {
sr_shimdebug_msg(1, " renameorlink using renameat\n");
status = renameat_fn_ptr(olddirfd, oldpath, newdirfd, newpath);
} else if (syscall_fn_ptr) {
sr_shimdebug_msg(1, " renameorlink using renameat2 via syscall(316, ...)\n");
status = syscall_fn_ptr(316, olddirfd, oldpath, newdirfd, newpath, flags);
sr_shimdebug_msg(1, " renameorlink using renameat2 via syscall(SYS_renameat2, ...)\n");
status = syscall_fn_ptr(SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
} else {
sr_log_msg(logctxptr,LOG_ERROR,
" renameorlink could not identify real entry point for renameat\n");
Expand Down Expand Up @@ -1396,7 +1398,7 @@ void syscall_init()
long int syscall(long int __sysno, ...)
{
va_list args;
int status = -1;
long int status = -1;

int olddirfd = -1;
char *oldpath = NULL;
Expand All @@ -1407,12 +1409,11 @@ long int syscall(long int __sysno, ...)
sr_shimdebug_msg(1, "syscall %ld\n", __sysno);

if (!syscall_init_done) {
syscall_init();
syscall_init();
}

// renameat2 is 316
if (__sysno == 316) {
sr_shimdebug_msg(1, "syscall %ld\n --> renameat2, will call renameorlink", __sysno);
if (__sysno == SYS_renameat2) {
sr_shimdebug_msg(1, "syscall %ld --> renameat2, will call renameorlink\n", __sysno);

va_start(args, __sysno);
olddirfd = va_arg(args, int);
Expand All @@ -1424,12 +1425,27 @@ long int syscall(long int __sysno, ...)

sr_shimdebug_msg(1, "%d, %s, %d, %s, %d", olddirfd, oldpath, newdirfd, newpath, flags);
status = renameorlink(olddirfd, oldpath, newdirfd, newpath, flags, 0);
}
else {
} else if (__sysno == SYS_getrandom && syscall_fn_ptr) {
sr_shimdebug_msg(1, "syscall %ld --> getrandom, will pass along\n", __sysno);
va_start(args, __sysno);
void *buf = va_arg(args, void*);
size_t buflen = va_arg(args, size_t);
unsigned int flags = va_arg(args, unsigned int);
va_end(args);
status = syscall_fn_ptr(__sysno, buf, buflen, flags);
} else if (__sysno == SYS_getpid && syscall_fn_ptr) {
sr_shimdebug_msg(1, "syscall %ld --> getpid, will pass along\n", __sysno);
status = syscall_fn_ptr(__sysno);
} else if (syscall_fn_ptr) {
sr_shimdebug_msg(1, "syscall %ld NOT IMPLEMENTED\n", __sysno);
sr_log_msg(logctxptr,LOG_ERROR, "non-renameat2 syscall (%ld) not implemented\n", __sysno);
sr_log_msg(logctxptr,LOG_ERROR, "syscall (%ld) not implemented\n", __sysno);
status = -1;
} else {
sr_shimdebug_msg(1, "syscall %ld no syscall_fn_ptr!\n", __sysno);
sr_log_msg(logctxptr,LOG_ERROR, "syscall (%ld) no syscall_fn_ptr!\n", __sysno);
status = -1;
}
sr_shimdebug_msg(1, "syscall %ld return %ld\n", __sysno, status);
return status;
}
#endif
Expand Down
78 changes: 78 additions & 0 deletions shim_post_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
set -x

which bash

echo "#test 0 comment 000 shim test posting start"
echo "#test 1 sha512 010 capturing stdout"
bash -c 'echo "hoho" >> ./hoho'

echo "#test 1 sha512 020 c program run."
truncate --size=2 ./hoho

echo "#test 1 sha512 030 python program run"
/usr/bin/python3 pyiotest

grep lovely pyiotest

echo "#test 1 directory 040 make directory"
mkdir sub_dir1

echo "#test 1 rename 050 rename directory"
mv sub_dir1 sub_dir2

echo "#test 1 rmdir 060 remove directory"
rmdir sub_dir2


echo "#test 1 sha512 070 cp command"
cp libsr3shim.c ~/test/hoho_my_darling.txt

echo "#test 1 sha512 080 touch command"
touch hihi

echo "#test 1 link 090 symlink command"
ln -s hoho haha

echo "#test 1 rename 100 moving a symlink"
mv haha hihi

echo "#test 1 rename 110 hardlink to a symlink"
ln hihi hoohoo
echo "#test 1 rename 120 moving a file. "
mv ~/test/hoho_my_darling.txt ~/test/hoho2.log
echo "#test 1 remove 130 removing a file. "
rm hihi

echo "#test 1 remove 140 removing a file."
rm ~/test/hoho2.log

echo "#test 1 directory 150 make second directory ."

mkdir dirone
if [ "${KNOWN_REDIRECTION_BUG}" ]; then
echo "#test 1 sha512 160 cp to avoid stdout redirection in a subdir"
cp hoho dirone/fileone
else
echo "#test 1 sha512 160 stdout redirection in a subdir"
echo "fileone" >>dirone/fileone
fi

echo "#test 1 directory 170 make third directory."
mkdir dirone/dirtwo

if [ "${KNOWN_REDIRECTION_BUG}" ]; then
echo "#test 1 sha512 180 cp to avoid stdout redirection in a subsubdir"
cp hoho dirone/dirtwo/filetwo
else
echo "#test 1 sha512 180 stdout redirection in a subsubdir"
echo "filetwo" >>dirone/dirtwo/filetwo
fi

echo "#test 1 rename 190 renaming subdirs should cause file rename events."
mv dirone dirthree
echo "#test 4 remove 200 removing a whole tree events."
rm -rf dirthree
echo "#test 2 remove 210 removing two files"
rm hoho hoohoo
echo "#test 0 comment 220 shim test posting end"
echo "#test 0 comment 230 test to ensure previous completes"

0 comments on commit f947db9

Please sign in to comment.