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?