C Open /dev/raid/r0 for writing

Hi again,

is there please any way to allow opening /dev/raid/r0 for writing even in multi-user mode and when root filesystem is on that device in FreeBSD 10.1?

I know I can allow writing to rank 1 GEOM providers by setting kern.geom.debugflags to 0x10 (16), but it doesn't help with raid/r0:

Code:
[root@ ~]# cat test-write.c
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char* argv[]) {
    char* dev;
    int fd;
    dev = argv[1];

    if (argc != 2) {
        printf("Usage: %s file\n", argv[0]);
        return 1;
    }

    if ((fd = open(dev, O_WRONLY)) < 0) {
        perror(dev);
        return 1;
    } else {
        printf("%s: OK\n", dev);
    }
    if (close(fd)) {
        perror(dev);
        return 1;
    }

    return 0;
}

[root@ ~]# cc -o test-write test-write.c
[root@ ~]# ./test-write /dev/ada0
/dev/ada0: Operation not permitted
[root@ ~]# ./test-write /dev/raid/r0
/dev/raid/r0: Operation not permitted
[root@ ~]# sysctl kern.geom.debugflags=16
kern.geom.debugflags: 0 -> 16
[root@ ~]# ./test-write /dev/ada0
/dev/ada0: OK
[root@ ~]# ./test-write /dev/raid/r0
/dev/raid/r0: Operation not permitted

Thanks in advance for any help.
 
The kernel won't let you open a mounted file system for writing, because every write would risk recoverable data corruption. The kernel may cache and modify the content of a mounted device asynchronously. Why do you want to shoot yourself in the foot?

I would also recommend against using the GEOM RAID class. You're better of with the GEOM mirror class for simple RAID 1.
 
Thanks for reply.

The kernel won't let you open a mounted file system for writing, because every write would risk recoverable data corruption. The kernel may cache and modify the content of a mounted device asynchronously. Why do you want to shoot yourself in the foot?

We want to rewrite labels of slices in boot manager. For example:

Code:
F1 Win
F2 FreeBSD

Default: F2

We have an own program that does that (but works only for rank 1 providers).

I would also recommend against using the GEOM RAID class. You're better of with the GEOM mirror class for simple RAID 1.

In this case, /dev/raid/r0 is an Intel RAID card on motherboard.
 
Back
Top