Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the return code values of linux `umount`?

Tags:

python

linux

So I've been handed a python project in which there are a lot Linux system calls to mount/unmout/format/etc backup drives for a customized NAS.

Right now I'd like to handle the output of the umount command and handle the case of an umounted path:

print subprocess.check_output(['umount', '/storage/backup'])

Which may return:

umount: /storage/backup: not mounted
Command '['umount', '/storage/backup']' returned non-zero exit status 32

Now, I could just parse the output string and search for not mounted, but I'd prefer to process the exit status values (32 in this case). I've tried to find a list of exit codes for the umount command but have been unlucky so far.
Also, I've tried finding the source code for umount but haven't been able to find it (google keeps pointing me to manual pages for the umount command or the source code for mount.c)

Edit

The man pages for umount have a list of Errors (non numeric) like:

  • EBUSY - target could not be unmounted because it is busy.
  • EFAULT - target points outside the user address space.

And then: The error values given below result from file-system type independent errors. Each file system type may have its own special errors and its own special behavior. See the Linux kernel source code for details.

Any pointers?

like image 298
Emanuel Ey Avatar asked Sep 14 '25 15:09

Emanuel Ey


1 Answers

From man mount:

RETURN CODES
   mount has the following return codes (the bits can be ORed):

   0      success

   1      incorrect invocation or permissions

   2      system error (out of memory, cannot fork, no more loop devices)

   4      internal mount bug

   8      user interrupt

   16     problems writing or locking /etc/mtab

   32     mount failure

   64     some mount succeeded

   The command mount -a returns 0 (all succeeded), 32 (all failed), or  64
   (some failed, some succeeded).
like image 195
LaPriWa Avatar answered Sep 17 '25 06:09

LaPriWa