On 11/11/2016 08:51 μμ, Paul Rogers wrote:
Does 'mount -l [...]' give you accurate info?
No, it does not. Inserted in mountkernfs even before proc is mounted:
/dev/hda9 / (rw)
Mount seems to think, "the root is always rw". Anyway, not usable.
As my first message said, interestingly, at that point "cat
/proc/1/mounts" has two mounts obviously referring to the root, one rw,
one
ro. Again, as I said there, I think that should remain "off limits".
There should be a better way.
Or, you might just try a write, to see if the fs is read-only or
read-write:
if touch /fsrwtestfile 2>/dev/null; then
That blasts a console message that it's a read-only filesystem,
exactly the message I'm trying to silence. As I said before it
seems to be a direct console write from the kernel, not stderr.
That's why I tried dropping the log-level. But it seems dangerous
to go too low.
I don't understand what you are trying to do. If you want to check
if a filesystem is mounted ro or rw you may want to test this trivial
C program that utilizes the statvfs(3) glibc function. It needs
a mountpoint as argument and prints ro or rw respectively.
Build with
gcc check_ro_fs.c -o check_ro_fs
and use it on bash like that:
if test `./check_ro_fs </path/to/mountpoint/>` == rw; then <write to
it>; else echo "readonly filesystem"; fi
--
Thanos
#include <stdio.h>
#include <sys/statvfs.h>
int main(int argc, char *argv[])
{
struct statvfs fs_stat;
if ( argc != 2 || statvfs(argv[1], &fs_stat) == -1 )
return 1;
if ( fs_stat.f_flag == 0 )
puts("no flags");
else
printf("%s\n", fs_stat.f_flag & ST_RDONLY != 0 ? "ro" : "rw");
return 0;
}
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
Do not top post on this list.
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
http://en.wikipedia.org/wiki/Posting_style