ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The mount command without any argument list all the mounted devices and their mount points, along with other information. You can grep the output from mount to look for a line containing that particular mount point: if it does not exist, nothing is mounted on that location.
EDIT: sorry, posted before viewing the reply from unSpawn. Nice solution!
The mount command without any argument list all the mounted devices and their mount points, along with other information. You can grep the output from mount to look for a line containing that particular mount point: if it does not exist, nothing is mounted on that location.
EDIT: sorry, posted before viewing the reply from unSpawn. Nice solution!
In my experience, /proc/mounts is more useful than the output of mount since mount will just read /etc/mtab, but if / is r/o then new mounts won't be written to it. Also, mount can be called so it doesn't write to /etc/mtab and there is a mount system call which allows programs other than the command proper to mount file systems, which aren't required to update /etc/mtab. Yes, it certainly is a PITA to maintain a system with a r/o root partition, which is why I've stopped doing it, but the point is the kernel itself is a better source of what's mounted.
ta0kira
PS The mount command would be the portable way to check, though. Is there a standard output format across Unixes?
...but the point is the kernel itself is a better source of what's mounted.
PS The mount command would be the portable way to check, though. Is there a standard output format across Unixes?
Thank you for the further explanation! Indeed, my use of mount command comes from Unix (SGI and SunOS) where /proc/mount does not exist. By the way, I'm afraid there is not a standard format. Here is an example from SunOS
Code:
/ on /dev/md/dsk/d0 read/write/setuid/intr/largefiles/logging/onerror=panic/dev=1540000 on Tue Jun 26 16:38:06 2007
/proc on /proc read/write/setuid/dev=4a00000 on Tue Jun 26 16:38:03 2007
On a side note, this problem is an excellent example of why user-mountable devices are by default noexec, nosuid, etc., and why external devices should be mounted with those options, anyway.
What is it you are attempting to prevent/detect? Is this a security or archiving issue, by any chance?
ta0kira
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.