file.c: use umove_or_printaddr

* file.c (printstat32, printstatsol): Remove.
(printstat, printstat64, printoldstat): Use umove_or_printaddr.
This commit is contained in:
Дмитрий Левин 2015-07-20 12:09:44 +00:00
parent b5821091ee
commit b6d80ffe02

94
file.c
View File

@ -174,19 +174,6 @@ struct stat32 {
# undef HAVE_STRUCT_STAT_ST_FSTYPE # undef HAVE_STRUCT_STAT_ST_FSTYPE
# undef HAVE_STRUCT_STAT_ST_GEN # undef HAVE_STRUCT_STAT_ST_GEN
# include "printstat.h" # include "printstat.h"
static void
printstat32(struct tcb *tcp, long addr)
{
struct stat32 statbuf;
if (umove(tcp, addr, &statbuf) < 0) {
tprints("{...}");
return;
}
do_printstat32(tcp, &statbuf);
}
#endif /* STAT32_PERSONALITY */ #endif /* STAT32_PERSONALITY */
#if defined(SPARC) || defined(SPARC64) #if defined(SPARC) || defined(SPARC64)
@ -223,20 +210,6 @@ struct solstat {
# undef HAVE_STRUCT_STAT_ST_FSTYPE # undef HAVE_STRUCT_STAT_ST_FSTYPE
# undef HAVE_STRUCT_STAT_ST_GEN # undef HAVE_STRUCT_STAT_ST_GEN
# include "printstat.h" # include "printstat.h"
static void
printstatsol(struct tcb *tcp, long addr)
{
struct solstat statbuf;
if (umove(tcp, addr, &statbuf) < 0) {
tprints("{...}");
return;
}
do_printstat_sol(tcp, &statbuf);
}
#endif /* SPARC || SPARC64 */ #endif /* SPARC || SPARC64 */
static void static void
@ -244,35 +217,28 @@ printstat(struct tcb *tcp, long addr)
{ {
struct stat statbuf; struct stat statbuf;
if (!addr) {
tprints("NULL");
return;
}
if (syserror(tcp) || !verbose(tcp)) {
tprintf("%#lx", addr);
return;
}
#ifdef STAT32_PERSONALITY #ifdef STAT32_PERSONALITY
if (current_personality == STAT32_PERSONALITY) { if (current_personality == STAT32_PERSONALITY) {
printstat32(tcp, addr); struct stat32 statbuf;
if (!umove_or_printaddr(tcp, addr, &statbuf))
do_printstat32(tcp, &statbuf);
return; return;
} }
#endif #endif
#if defined(SPARC) || defined(SPARC64) #if defined(SPARC) || defined(SPARC64)
if (current_personality == 1) { if (current_personality == 1) {
printstatsol(tcp, addr); struct solstat statbuf;
if (!umove_or_printaddr(tcp, addr, &statbuf))
do_printstat_sol(tcp, &statbuf);
return; return;
} }
#endif /* SPARC || SPARC64 */ #endif /* SPARC || SPARC64 */
if (umove(tcp, addr, &statbuf) < 0) { if (!umove_or_printaddr(tcp, addr, &statbuf))
tprints("{...}"); do_printstat(tcp, &statbuf);
return;
}
do_printstat(tcp, &statbuf);
} }
SYS_FUNC(stat) SYS_FUNC(stat)
@ -359,15 +325,6 @@ printstat64(struct tcb *tcp, long addr)
(void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]); (void) sizeof(char[sizeof statbuf == STAT64_SIZE ? 1 : -1]);
# endif # endif
if (!addr) {
tprints("NULL");
return;
}
if (syserror(tcp) || !verbose(tcp)) {
tprintf("%#lx", addr);
return;
}
# ifdef STAT32_PERSONALITY # ifdef STAT32_PERSONALITY
if (current_personality != STAT32_PERSONALITY) { if (current_personality != STAT32_PERSONALITY) {
printstat(tcp, addr); printstat(tcp, addr);
@ -375,12 +332,8 @@ printstat64(struct tcb *tcp, long addr)
} }
# endif /* STAT32_PERSONALITY */ # endif /* STAT32_PERSONALITY */
if (umove(tcp, addr, &statbuf) < 0) { if (!umove_or_printaddr(tcp, addr, &statbuf))
tprints("{...}"); do_printstat64(tcp, &statbuf);
return;
}
do_printstat64(tcp, &statbuf);
} }
SYS_FUNC(stat64) SYS_FUNC(stat64)
@ -467,29 +420,20 @@ printoldstat(struct tcb *tcp, long addr)
struct __old_kernel_stat statbuf; struct __old_kernel_stat statbuf;
struct stat newstatbuf; struct stat newstatbuf;
if (!addr) {
tprints("NULL");
return;
}
if (syserror(tcp) || !verbose(tcp)) {
tprintf("%#lx", addr);
return;
}
# if defined(SPARC) || defined(SPARC64) # if defined(SPARC) || defined(SPARC64)
if (current_personality == 1) { if (current_personality == 1) {
printstatsol(tcp, addr); struct solstat statbuf;
if (!umove_or_printaddr(tcp, addr, &statbuf))
do_printstat_sol(tcp, &statbuf);
return; return;
} }
# endif # endif
if (umove(tcp, addr, &statbuf) < 0) { if (!umove_or_printaddr(tcp, addr, &statbuf)) {
tprints("{...}"); convertoldstat(&statbuf, &newstatbuf);
return; do_printstat(tcp, &newstatbuf);
} }
convertoldstat(&statbuf, &newstatbuf);
do_printstat(tcp, &newstatbuf);
} }
SYS_FUNC(oldstat) SYS_FUNC(oldstat)