Skip to content

Commit

Permalink
file.c: move utime parser to a separate file
Browse files Browse the repository at this point in the history
* utime.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c (sys_utime): Move to utime.c.
  • Loading branch information
ldv-alt committed Dec 11, 2014
1 parent b1a01b8 commit fb470f3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ strace_SOURCES = \
time.c \
umount.c \
util.c \
utime.c \
v4l2.c \
vsprintf.c \
xattr.c
Expand Down
36 changes: 0 additions & 36 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,39 +1519,3 @@ sys_utimensat(struct tcb *tcp)
}
return 0;
}

int
sys_utime(struct tcb *tcp)
{
union {
long utl[2];
int uti[2];
long paranoia_for_huge_wordsize[4];
} u;
unsigned wordsize;

if (entering(tcp)) {
printpath(tcp, tcp->u_arg[0]);
tprints(", ");

wordsize = current_wordsize;
if (!tcp->u_arg[1])
tprints("NULL");
else if (!verbose(tcp))
tprintf("%#lx", tcp->u_arg[1]);
else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
tprints("[?, ?]");
else if (wordsize == sizeof u.utl[0]) {
tprintf("[%s,", sprinttime(u.utl[0]));
tprintf(" %s]", sprinttime(u.utl[1]));
}
else if (wordsize == sizeof u.uti[0]) {
tprintf("[%s,", sprinttime(u.uti[0]));
tprintf(" %s]", sprinttime(u.uti[1]));
}
else
tprintf("<decode error: unsupported wordsize %d>",
wordsize);
}
return 0;
}
37 changes: 37 additions & 0 deletions utime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "defs.h"

int
sys_utime(struct tcb *tcp)
{
union {
long utl[2];
int uti[2];
long paranoia_for_huge_wordsize[4];
} u;
unsigned wordsize;

if (entering(tcp)) {
printpath(tcp, tcp->u_arg[0]);
tprints(", ");

wordsize = current_wordsize;
if (!tcp->u_arg[1])
tprints("NULL");
else if (!verbose(tcp))
tprintf("%#lx", tcp->u_arg[1]);
else if (umoven(tcp, tcp->u_arg[1], 2 * wordsize, (char *) &u) < 0)
tprints("[?, ?]");
else if (wordsize == sizeof u.utl[0]) {
tprintf("[%s,", sprinttime(u.utl[0]));
tprintf(" %s]", sprinttime(u.utl[1]));
}
else if (wordsize == sizeof u.uti[0]) {
tprintf("[%s,", sprinttime(u.uti[0]));
tprintf(" %s]", sprinttime(u.uti[1]));
}
else
tprintf("<decode error: unsupported wordsize %d>",
wordsize);
}
return 0;
}

0 comments on commit fb470f3

Please sign in to comment.