ioctl BLKGETSIZE /dev/md0 produces Permission denied error for non root
From: Pascal Bourguignon (spam_at_mouse-potato.com)
Date: 10/30/05
- Next message: Kasper Dupont: "Re: ioctl BLKGETSIZE /dev/md0 produces Permission denied error for non root"
- Previous message: Kasper Dupont: "Re: difference betwen /dev/shm and /dev/mem"
- Next in thread: Kasper Dupont: "Re: ioctl BLKGETSIZE /dev/md0 produces Permission denied error for non root"
- Reply: Kasper Dupont: "Re: ioctl BLKGETSIZE /dev/md0 produces Permission denied error for non root"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Oct 2005 00:58:16 +0200
I've got a problem with ioctl BLKGETSIZE on a RAID device
(I want to pass ubd0=/dev/md0 to user-mode-linux (with a linux-2.6.8 kernel)
on a linux-2.4.20).
The problem is that ioctl BLKGETSIZE /dev/md0 fails with a Permission
denied error. But I have access rigths on /dev/md0 and its underlying
partitions:
[pjb@janus-1 user-mode-linux]$ cat blkgetsize.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mount.h>
const char* msg(const char* operation,const char* arg){
static char msg[80];
if(strlen(operation)+strlen(arg)<sizeof(msg)-2){
sprintf(msg,"%s %s",operation,arg);
}else{
sprintf(msg,"%s",operation);
}
return(msg);}
int main(int argc,char** argv){
int i;
for(i=1;i<argc;i++){
const char* fname=argv[i];
int fd=open(fname,O_RDONLY,0);
if(fd<0){
perror(msg("open",fname));}
else{
int block;
int res=ioctl(fd,BLKGETSIZE,&block);
if(res<0){
perror(msg("ioctl BLKGETSIZE",fname));}
else{
printf("ioctl BLKGETSIZE %s: block=%ld\n",fname,block);}
close(fd);}}
return(0);}
[pjb@janus-1 user-mode-linux]$ grep md0 /proc/mdstat
md0 : active raid1 hdc2[1] hda2[0]
[pjb@janus-1 user-mode-linux]$ ls -l /dev/md0 /dev/hd[ac]2
brw-rw---- 1 pjb disk 3, 2 2003-03-14 14:07 /dev/hda2
brw-rw---- 1 pjb disk 22, 2 2003-03-14 14:07 /dev/hdc2
brw-rw---- 1 pjb disk 9, 0 2003-03-14 14:07 /dev/md0
[pjb@janus-1 user-mode-linux]$ ./blkgetsize /dev/md0 /dev/hd[ac]2
ioctl BLKGETSIZE /dev/md0: Permission denied
ioctl BLKGETSIZE /dev/hda2: block=16803990
ioctl BLKGETSIZE /dev/hdc2: block=16803990
[pjb@janus-1 user-mode-linux]$ sudo ./blkgetsize /dev/md0 /dev/hd[ac]2
Password:xxxxxxxx
ioctl BLKGETSIZE /dev/md0: block=16803840
ioctl BLKGETSIZE /dev/hda2: block=16803990
ioctl BLKGETSIZE /dev/hdc2: block=16803990
[pjb@janus-1 user-mode-linux]$ uname -a
Linux janus-1 2.4.20-4GB #4 Sat May 1 08:55:53 CEST 2004 i686 unknown unknown GNU/Linux
What can I do to get it work?
I get the same error when I "hown pjb /dev/hd[ac]" too.
-- "Klingon function calls do not have "parameters" -- they have "arguments" and they ALWAYS WIN THEM."
- Next message: Kasper Dupont: "Re: ioctl BLKGETSIZE /dev/md0 produces Permission denied error for non root"
- Previous message: Kasper Dupont: "Re: difference betwen /dev/shm and /dev/mem"
- Next in thread: Kasper Dupont: "Re: ioctl BLKGETSIZE /dev/md0 produces Permission denied error for non root"
- Reply: Kasper Dupont: "Re: ioctl BLKGETSIZE /dev/md0 produces Permission denied error for non root"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]