Hi,

With the cp(1) change to use chflagsat(), systrace needs to be
taught about chflagsat syscall. databases/db/v4 port fails with
USE_SYSTRACE=Yes due to a "$(CP) -pr" use during install_docs.

Could someone look over these changes and correct any mistakes.
I am not 100% sure it is correct; specifically, I'm not sure
about the print_atflags.

The extra white-space in register.c diff is to help you eyeball
any obvious (not to me) mistakes; otherwise, the two empty lines
should be removed to maintain uniformity.

Thanks,
--patrick

p.s., I'll send a patch for systrace.filter change to ports@.


Index: register.c
===================================================================
RCS file: /cvs/obsd/src/bin/systrace/register.c,v
retrieving revision 1.25
diff -u -p -u -p -r1.25 register.c
--- register.c  16 Jan 2015 00:19:12 -0000      1.25
+++ register.c  4 Jun 2015 07:43:26 -0000
@@ -126,6 +126,13 @@ systrace_initcb(void)
        X(intercept_register_sccb("native", "chflags", trans_cb, NULL));
        intercept_register_transfn("native", "chflags", 0);
        intercept_register_translation("native", "chflags", 1, &ic_fileflags);
+
+       X(intercept_register_sccb("native", "chflagsat", trans_cb, NULL));
+       intercept_register_translation("native", "chflagsat", 0, &ic_fdt);
+       intercept_register_transfn("native", "chflagsat", 1);
+       intercept_register_translation("native", "chflagsat", 2, &ic_fileflags);
+       intercept_register_translation("native", "chflagsat", 3, &ic_atflags);
+
        X(intercept_register_sccb("native", "readlink", trans_cb, NULL));
        tl = intercept_register_translation("native", "readlink", 0,
            &ic_translate_unlinkname);
Index: systrace-translate.c
===================================================================
RCS file: /cvs/obsd/src/bin/systrace/systrace-translate.c,v
retrieving revision 1.25
diff -u -p -u -p -r1.25 systrace-translate.c
--- systrace-translate.c        16 Jan 2015 00:19:12 -0000      1.25
+++ systrace-translate.c        4 Jun 2015 07:43:26 -0000
@@ -67,6 +67,7 @@ static int print_signame(char *, size_t,
 static int print_fcntlcmd(char *, size_t, struct intercept_translate *);
 static int print_memprot(char *, size_t, struct intercept_translate *);
 static int print_fileflags(char *, size_t, struct intercept_translate *);
+static int print_atflags(char *, size_t, struct intercept_translate *);
 static int get_argv(struct intercept_translate *, int, pid_t, void *);
 static int print_argv(char *, size_t, struct intercept_translate *);
 
@@ -559,6 +560,35 @@ print_fileflags(char *buf, size_t buflen
 }
 
 static int
+print_atflags(char *buf, size_t buflen, struct intercept_translate *tl)
+{
+       int flags = (intptr_t)tl->trans_addr;
+       char lbuf[64];
+
+       *buf = '\0';
+
+       while (flags) {
+               if (*buf)
+                       strlcat(buf, "|", buflen);
+
+               if (flags & AT_SYMLINK_NOFOLLOW) {
+                       strlcat(buf, "AT_SYMLINK_NOFOLLOW", buflen);
+                       flags &= ~AT_SYMLINK_NOFOLLOW;
+                       continue;
+               }
+
+               if (flags) {
+                       snprintf(lbuf, sizeof(lbuf), "<unknown:0x%x>", flags);
+                       strlcat(buf, lbuf, buflen);
+                       flags = 0;
+                       continue;
+               }
+       }
+
+       return (0);
+}
+
+static int
 get_argv(struct intercept_translate *trans, int fd, pid_t pid, void *addr)
 {
        char *arg;
@@ -688,4 +718,9 @@ struct intercept_translate ic_linux_memp
 struct intercept_translate ic_fileflags = {
        "flags",
        NULL, print_fileflags,
+};
+
+struct intercept_translate ic_atflags = {
+       "atflags",
+       NULL, print_atflags,
 };
Index: systrace.h
===================================================================
RCS file: /cvs/obsd/src/bin/systrace/systrace.h,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 systrace.h
--- systrace.h  2 Jul 2006 12:34:15 -0000       1.27
+++ systrace.h  4 Jun 2015 07:43:26 -0000
@@ -245,6 +245,7 @@ extern struct intercept_translate ic_fcn
 extern struct intercept_translate ic_memprot;
 extern struct intercept_translate ic_linux_memprot;
 extern struct intercept_translate ic_fileflags;
+extern struct intercept_translate ic_atflags;
 
 extern struct intercept_translate ic_linux_oflags;
 

Reply via email to