[d-i-commits] r32224 - in trunk/packages/partman/partman-base: .
debian
Colin Watson
cjwatson at costa.debian.org
Thu Nov 17 20:05:33 UTC 2005
Author: cjwatson
Date: 2005-11-17 20:05:31 +0000 (Thu, 17 Nov 2005)
New Revision: 32224
Modified:
trunk/packages/partman/partman-base/debian/changelog
trunk/packages/partman/partman-base/parted_devices.c
Log:
* Exclude CD/DVD drives from the output of parted_devices.
Modified: trunk/packages/partman/partman-base/debian/changelog
===================================================================
--- trunk/packages/partman/partman-base/debian/changelog 2005-11-17 19:59:49 UTC (rev 32223)
+++ trunk/packages/partman/partman-base/debian/changelog 2005-11-17 20:05:31 UTC (rev 32224)
@@ -3,6 +3,7 @@
[ Colin Watson ]
* Clarify partman/confirm to indicate that if you say no you can make
further changes manually (closes: #329405).
+ * Exclude CD/DVD drives from the output of parted_devices.
[ Sven Luther ]
* Adapted to chrp_rs6k -> chrp_ibm transition.
Modified: trunk/packages/partman/partman-base/parted_devices.c
===================================================================
--- trunk/packages/partman/partman-base/parted_devices.c 2005-11-17 19:59:49 UTC (rev 32223)
+++ trunk/packages/partman/partman-base/parted_devices.c 2005-11-17 20:05:31 UTC (rev 32224)
@@ -1,6 +1,37 @@
+#ifdef __linux__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+/* from <linux/cdrom.h> */
+#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
+#endif /* __linux__ */
+
#include <parted/parted.h>
+#ifdef __linux__
int
+is_cdrom(const char *path)
+{
+ int fd;
+ int ret;
+
+ fd = open(path, O_RDONLY | O_NONBLOCK);
+ ret = ioctl(fd, CDROM_GET_CAPABILITY, NULL);
+ close(fd);
+
+ if (ret >= 0)
+ return 1;
+ else
+ return 0;
+}
+#else /* !__linux__ */
+#define is_cdrom(path) 0
+#endif /* __linux__ */
+
+int
main(int argc, char *argv[])
{
PedDevice *dev;
@@ -9,6 +40,8 @@
for (dev = NULL; NULL != (dev = ped_device_get_next(dev));) {
if (dev->read_only)
continue;
+ if (is_cdrom(dev->path))
+ continue;
printf("%s\t%lli\t%s\n",
dev->path,
dev->length * PED_SECTOR_SIZE,
More information about the d-i-commits
mailing list