diff -urN qtparted-0.4.5.orig/src/qp_devlist.cpp qtparted-0.4.5/src/qp_devlist.cpp --- qtparted-0.4.5.orig/src/qp_devlist.cpp 2005-08-10 14:05:37 +0300 +++ qtparted-0.4.5/src/qp_devlist.cpp 2007-08-15 02:14:16 +0300 @@ -239,6 +239,28 @@ devlist.clear(); } +inline bool is_floppy(const char* d) { + return (d == NULL) ? FALSE : !strncmp(d, "/dev/fd", sizeof("/dev/fd")-1); +} + +inline bool is_cdrom(const char* d) { + char s[]="/sys/block/hd_/device/media"; + FILE* F; + + if (d != NULL) { + if (!(strncmp(d, "/dev/sr", sizeof("/dev/sr")-1) && strncmp(d, "/dev/scd", sizeof("/dev/scd")-1))) + return TRUE; + if (!strncmp(d, "/dev/hd", sizeof("/dev/hd")-1)) { + s[13]=d[7]; + if (F=fopen(s, "r")) { + if (!strcmp(fgets(s, sizeof("cdrom"), F), "cdrom")) return TRUE; + fclose(F); + } + } + } + return FALSE; +} + void QP_DevList::getDevices() { /*---get all the device (ie /dev/sda, /dev/hda /etc /etc)---*/ PedDevice *dev = NULL; @@ -247,9 +269,7 @@ while ((dev = ped_device_get_next(dev))) { // Workaround for parted detecting CD-ROMs as harddisks // FIXME remove if/when parted gets fixed - QString p(dev->path); - if(!p.startsWith("/dev/sd") && (p.contains("/dev/scd") || p.contains("/dev/sr") || access("/proc/ide/" + p.section('/', 2, 2) + "/cache", R_OK))) - continue; + if (is_floppy(dev->path) || is_cdrom(dev->path)) continue; QP_Device *device = new QP_Device(_settings);