X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=file.c;h=52c36312f30cd270728a198e356f2a3ddb63a55c;hb=aa524c88c49814863cb7f19e5c8a8eeca6ce22fe;hp=630f973e6080b3d6a6865c643054c37ba7029b8a;hpb=fee836eb65cd9792914b0e1c038c354be6ab1170;p=strace diff --git a/file.c b/file.c index 630f973e..52c36312 100644 --- a/file.c +++ b/file.c @@ -245,7 +245,9 @@ const struct xlat openmodes[] = { # define O_LARGEFILE 0100000 # endif # endif +# ifdef O_LARGEFILE { O_LARGEFILE, "O_LARGEFILE" }, +# endif #endif #ifdef O_DIRECTORY { O_DIRECTORY, "O_DIRECTORY" }, @@ -253,6 +255,9 @@ const struct xlat openmodes[] = { #ifdef O_NOFOLLOW { O_NOFOLLOW, "O_NOFOLLOW" }, #endif +#ifdef O_NOATIME + { O_NOATIME, "O_NOATIME" }, +#endif #ifdef FNDELAY { FNDELAY, "FNDELAY" }, @@ -310,7 +315,7 @@ struct tcb *tcp; printpath(tcp, tcp->u_arg[0]); tprintf(", "); /* flags */ - printflags(openmodes, tcp->u_arg[1] + 1); + printflags(openmodes, tcp->u_arg[1] + 1, "O_???"); if (tcp->u_arg[1] & O_CREAT) { /* mode */ tprintf(", %#lo", tcp->u_arg[2]); @@ -346,7 +351,7 @@ struct tcb *tcp; printpath(tcp, tcp->u_arg[0]); tprintf(", "); /* flags */ - printflags(openmodessol, tcp->u_arg[1] + 1); + printflags(openmodessol, tcp->u_arg[1] + 1, "O_???"); if (tcp->u_arg[1] & 0x100) { /* mode */ tprintf(", %#lo", tcp->u_arg[2]); @@ -389,7 +394,7 @@ struct tcb *tcp; if (entering(tcp)) { printpath(tcp, tcp->u_arg[0]); tprintf(", "); - printflags(access_flags, tcp->u_arg[1]); + printflags(access_flags, tcp->u_arg[1], "?_OK"); } return 0; } @@ -778,10 +783,7 @@ struct tcb *tcp; if (entering(tcp)) { printpath(tcp, tcp->u_arg[0]); tprintf(", "); - if (tcp->u_arg[1]) - printflags(fileflags, tcp->u_arg[1]); - else - tprintf("0"); + printflags(fileflags, tcp->u_arg[1], "UF_???"); } return 0; } @@ -792,10 +794,7 @@ struct tcb *tcp; { if (entering(tcp)) { tprintf("%ld, ", tcp->u_arg[0]); - if (tcp->u_arg[1]) - printflags(fileflags, tcp->u_arg[1]); - else - tprintf("0"); + printflags(fileflags, tcp->u_arg[1], "UF_???"); } return 0; } @@ -848,10 +847,7 @@ struct stat *statbuf; tprintf("st_ctime=%s", sprinttime(statbuf->st_ctime)); #if HAVE_STRUCT_STAT_ST_FLAGS tprintf(", st_flags="); - if (statbuf->st_flags) { - printflags(fileflags, statbuf->st_flags); - } else - tprintf("0"); + printflags(fileflags, statbuf->st_flags, "UF_???"); #endif #if HAVE_STRUCT_STAT_ST_ACLCNT tprintf(", st_aclcnt=%d", statbuf->st_aclcnt); @@ -994,10 +990,7 @@ long addr; tprintf("st_ctime=%s", sprinttime(statbuf.st_ctime)); #if HAVE_STRUCT_STAT_ST_FLAGS tprintf(", st_flags="); - if (statbuf.st_flags) { - printflags(fileflags, statbuf.st_flags); - } else - tprintf("0"); + printflags(fileflags, statbuf.st_flags, "UF_???"); #endif #if HAVE_STRUCT_STAT_ST_ACLCNT tprintf(", st_aclcnt=%d", statbuf.st_aclcnt); @@ -2037,11 +2030,12 @@ struct tcb *tcp; } len = tcp->u_rval; if ((buf = malloc(len)) == NULL) { - tprintf("out of memory\n"); + tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); + fprintf(stderr, "out of memory\n"); return 0; } if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { - tprintf("{...}, %lu", tcp->u_arg[2]); + tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); free(buf); return 0; } @@ -2120,11 +2114,12 @@ struct tcb *tcp; } len = tcp->u_rval; if ((buf = malloc(len)) == NULL) { - tprintf("out of memory\n"); + tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); + fprintf(stderr, "out of memory\n"); return 0; } if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { - tprintf("{...}, %lu", tcp->u_arg[2]); + tprintf("%#lx, %lu", tcp->u_arg[1], tcp->u_arg[2]); free(buf); return 0; } @@ -2188,11 +2183,12 @@ struct tcb * tcp; } len = tcp->u_rval; if ((buf = malloc(len)) == NULL) { - tprintf("out of memory\n"); + tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); + fprintf(stderr, "out of memory\n"); return 0; } if (umoven(tcp, tcp->u_arg[1], len, buf) < 0) { - tprintf("{...}, %lu, %#lx", tcp->u_arg[2], tcp->u_arg[3]); + tprintf("%#lx, %lu, %#lx", tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]); free(buf); return 0; } @@ -2351,12 +2347,13 @@ print_xattr_val(tcp, failed, arg, insize, size) struct tcb *tcp; int failed; unsigned long arg; -long insize, size; +unsigned long insize, size; { if (!failed) { - unsigned char *buf = malloc(4 * size + 1); + unsigned long capacity = 4 * size + 1; + unsigned char *buf = (capacity < size) ? NULL : malloc(capacity); if (buf == NULL || /* probably a bogus size argument */ - umoven(tcp, arg, size, &buf[3 * size]) < 0) { + umoven(tcp, arg, size, (char *) &buf[3 * size]) < 0) { failed = 1; } else { @@ -2395,7 +2392,7 @@ struct tcb *tcp; printstr(tcp, tcp->u_arg[1], -1); print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); tprintf(", "); - printflags(xattrflags, tcp->u_arg[4]); + printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); } return 0; } @@ -2409,7 +2406,7 @@ struct tcb *tcp; printstr(tcp, tcp->u_arg[1], -1); print_xattr_val(tcp, 0, tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[3]); tprintf(", "); - printflags(xattrflags, tcp->u_arg[4]); + printflags(xattrflags, tcp->u_arg[4], "XATTR_???"); } return 0; }