On 13/11/2016 03:02 πμ, Paul Rogers wrote:
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
check_ro_fs.c
#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;
}
I installed it. On the target system with linux-2.6.17 & glibc-2.3.4, I
get "no flags". It works on the host system, linux-2.6.32 &
glibc-2.11.1, but I was only able to test there after booting was
complete. I ran diff on both sys/statvfs.h and they were the same.
Other than that, well, I'm not a Linux/GNU developer.
I'm not a developer either. I was curious and learned few things.
The problem is rather your old glibc and kernel versions. There have
been changes over the years in statvfs() implementation.
In statvfs(3) man page says:
In glibc versions before 2.13, statvfs() populated the bits of the
f_flag field by scanning the mount options shown in /proc/mounts.
However, starting with Linux 2.6.36, the underlying statfs(2) system
call provides the necessary information via the f_flags field, and
since glibc version 2.13, the statvfs() function will use information
from that field rather than scanning /proc/mounts.
Why were you able to test on host only after booting was complete?
What was the problem?
--
Thanos
--
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