Re: Failing to mount an SMB file system produces unexpected behavior

From: Khimenko Victor (khim@sch57.msk.ru)
Date: Tue May 09 2000 - 14:09:07 EST


In <852568DA.00609562.00@d54mta08.raleigh.ibm.com> peloquin@us.ibm.com (peloquin@us.ibm.com) wrote:

> Am seeing a problem in mount when mounting smb file systems. There is
> special code in mount for either smb or ncp where it forks to create a
> child which then execs the appropriate function. The parent waits for the
> child process to end. In the case of a failed smbmount, smbmount returns a
> status code of 1, but the value returned to the wait is apparantly shifted
> left by 8 actually returning a status code of 256 to mount.

Status code 256 <=> exit code 1. From wait(2) :
-- cut --
       If status is not NULL, wait or waitpid store status infor-
       mation in the location pointed to by status.

       This status can be evaluated with the following macros
       (these macros take the stat buffer (an int) as an argument
       -- not a pointer to the buffer!):

       WIFEXITED(status)
               is non-zero if the child exited normally.

       WEXITSTATUS(status)
               evaluates to the least significant eight bits of
               the return code of the child which terminated,
               which may have been set as the argument to a call
               to exit() or as the argument for a return state-
               ment in the main program. This macro can only be
               evaluated if WIFEXITED returned non-zero.
-- cut --
and WEXITSTATUS is defined as
-- /usr/include/bits/waitstatus.h --
/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
-- cut --

> Mount interprets the 256 as EX_BG (retry in background).

Huh ? Since there are NO easy way to get exit codes > 255 it was REALLY bad
choice...

> When mount retries in the background, it sends a 0 status code to the caller,
> which is tricked into thinking the mount occurred successfully. This seems
> like a bug, in 'mount' (my bet) or in the 'wait' function. Can anyone give me
> an opinion or insight into the behavior of shifting the status code by 8?

If you want description of function it's good to start from man. Really.

> This behavior has been tested on kernels 2.2.12 and 2.3.99-pre3.

Since kernel does EXACTLY what it should do it's not such a big wonder that
functions work correctly in both 2.2.12 and 2.399-pre3 :-)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:14 EST