[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
multiple disk open/closes
From: |
Hollis R Blanchard |
Subject: |
multiple disk open/closes |
Date: |
Sun, 22 Apr 2001 13:01:13 -0400 (EDT) |
I was having a problem with python bindings last night, but this C code shows
it off as well:
-----
#include <stdio.h>
#include <parted/parted.h>
int main(void)
{
int i=2;
PedDevice *dev;
PedDisk *disk;
ped_init();
while (i--) {
printf("device... ");
if (NULL == (dev = ped_device_get("/dev/sda"))) {
goto error0;
}
printf("disk... ");
if (NULL == (disk = ped_disk_open(dev))) {
goto error1;
}
printf("success\n");
error2:
ped_disk_close(disk);
error1:
ped_device_close(dev);
error0:
printf("closed\n");
}
ped_done();
return 0;
}
-----
Here's my ouput:
device... disk... success
closed
device... disk... Error: Unable to open /dev/sda - unrecognised disk label.
closed
Apparently the problem has something to do with open_count. During the first
open:
before open, dev->fd=4 dev->open_count=0
after open, before read dev->fd=4 dev->open_count=1
During the second open:
before open, dev->fd=4 dev->open_count=-1
after open, before read dev->fd=4 dev->open_count=0
This is with kernel 2.2.19 on a ppc, gcc 2.95.3, parted 1.4.10. sda is a
DOS-partitioned disk, but I see the same thing with a Mac disk.
-Hollis
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- multiple disk open/closes,
Hollis R Blanchard <=