1

Update: The specification provided in the answer below negates the actual question, that is it applies to a broader scope of specifications, thereby eliminating the need for this question (see answer).

I'm struggling to find cohesive documentation on this one. Basically, I would like to know, with references where possible, what the standards are for an executable mounting a volume. To clarify: I'm looking for a specification. Below are some examples:

*. The executable *may* mount a volume at a subdirectory of the path provided by the caller (say it's not an empty directory), eg $ARGX/$NEWPLACE
*. The executable *cannot* create directories ever.
*. The executable *cannot* create directories unless specified by the caller.
*. The executable *may* create directories specified by the caller if they do not exist.
*. The executable *must* mount a volume at /mnt/$OTHERPATH if the mount point passed by the caller is unavailable.
*. The executable *cannot* mount a volume at $BADPATH, $WORSEPATH, and the like, even if specified by the caller.
*. The caller *expects* the volume mounted at $ARGX
*. The caller *expects* to be alerted if the mount point is not empty
*. The caller *expects* the executable to abort on all errors.

The reason is, just looking at various distros, not only have they changed over the years, but they each have their own opinion of where things go (slight tangent here: Wouldn't /mnt/$USER/$VOLUME be a better global solution to the hierarchy since /mnt was originally for mounting things and having a separate directory for each user would function the way /home/$USER/ does?). Back on topic, I want to remain as distribution-agnostic as possible (which I realise is like asking to make all of the people happy all of the time) so any "Specification" would be appreciated. Thanks.

  • 1
    What standards? Which ones do you care about? (If there are any...) The kernel will let a process with sufficient privileges mount almost anything almost anywhere, the program does not need to e.g. ask for any input from the user. – ilkkachu Oct 14 '16 at 11:31
  • Put another way: If I write a piece of software and it mounts a volume, where should I mount it? Is there no spec on that? I've seen many rogue programs/scripts just mounting things in /home/$USER/$VOLUME, which is safe, but it jars me. What can/can't my program do? How must it interact with the caller? – nonzyro Oct 14 '16 at 13:05
  • I really suspect the only answer must be that the program should do whatever it is you want. Or, "whatever it is your users want". Note that this may include different things for different distributions, they might have ideas of their own. I think e.g. Ubuntu mounts stuff like USB sticks at /media. But in the end also depends on what you're mounting. – ilkkachu Oct 15 '16 at 17:32
0

I couldn't find a specification specifically referencing mounting, but Chapter 19. Additional Recommendations - Linux Standard Base Core Specification, Generic Part seems applicable.

19.1.1. Directory Write Permissions

The application should not depend on having directory write permission in any directory except /tmp, /var/tmp, and the invoking user's home directory.

| improve this answer | |
  • Thanks. No wonder I couldn't find it. I was asking the correct question, which should have been: How, overall should my program behave. That actually explains everything and provides a good argument in favour of using the home directory as a mount point by some programs. Thanks for that link. – nonzyro Oct 15 '16 at 8:17
  • You're welcome. I'm glad it was helpful. – Paul H. Oct 15 '16 at 15:07
  • What if you need to mount something that won't be writable anyway? A CD-ROM, for example? – ilkkachu Oct 15 '16 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.