Skip to contentSkip to conversation

xfsdump: fix system() error reporting

PATCH In review Christoph Hellwig 2 participants 4 messages Feb 16, 2009 – Feb 18, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsdump: fix system() error reporting

Positive returns from system need the WEXITSTATUS macro applies to get the real exit code of the executed command.

Based on analysis in oss BZ #804.

dump/content.c +2 -1
Index: xfsdump-dev/dump/content.c
===================================================================
@@ -6735,7 +6735,8 @@ save_quotas( char *mntpnt, quota_info_t 
         sts = system( buf );
         if( sts != 0 ) {
             mlog( MLOG_ERROR, _(
-                  "%s failed with exit status: %d\n"), REPQUOTA, sts);
+                  "%s failed with exit status: %d\n"), REPQUOTA,
+		  sts == -1 ? -1 : WEXITSTATUS(sts));
             return BOOL_FALSE;
         }
         if((fd = open( quotainfo->quotapath, O_RDONLY|O_DSYNC)) < 0) {

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

Hi Christoph,

Looks reasonable.
Though, in the case of returning -1, it might be more interesting to know the value of errno ? (I presume errno would be set in that case).

--Tim

Quoted 23 lines · Christoph Hellwig

Positive returns from system need the WEXITSTATUS macro applies to get the real exit code of the executed command.

Based on analysis in oss BZ #804.

Index: xfsdump-dev/dump/content.c
===================================================================

dump/content.c 2009-02-16 11:23:47.629070808 +0100 renamed from dump/content.c 2009-02-16 11:23:10.361944048 +0100 +2 -1
@@ -6735,7 +6735,8 @@ save_quotas( char *mntpnt, quota_info_t
        sts = system( buf );
        if( sts != 0 ) {
            mlog( MLOG_ERROR, _(
-                  "%s failed with exit status: %d\n"), REPQUOTA, sts);
+                  "%s failed with exit status: %d\n"), REPQUOTA,
+                 sts == -1 ? -1 : WEXITSTATUS(sts));
            return BOOL_FALSE;
        }
        if((fd = open( quotainfo->quotapath, O_RDONLY|O_DSYNC)) < 0) {
Quoted 5 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 7 lines · Timothy Shimmin

Hi Christoph,

Looks reasonable.
Though, in the case of returning -1, it might be more interesting to know the value of errno ? (I presume errno would be set in that case).

From looking at the manpage and the glibc implementation it seem like

system does not actually set errno.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Timothy Shimmin

Hi Christoph,

Looks reasonable.
Though, in the case of returning -1, it might be more interesting to know the value of errno ? (I presume errno would be set in that case).

From looking at the manpage and the glibc implementation it seem like system does not actually set errno.

Fair enough.

Yeah, it didn't seem clear in the man page and
I thought it might make a call to fork, waitpid etc which might set an errno.

Cheers,
Tim.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs