summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2003-12-22 02:16:17 +0800
committermarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2003-12-22 02:16:17 +0800
commit24767b2b26fadf85a895862dfe35aa3e7c618689 (patch)
tree98d4366f9ff1b937f36de8fde3c4606e25a4c355
parent19f6542445ae10a915e21b342e15ee9d551d5b29 (diff)
downloadmarcuscom-ports-24767b2b26fadf85a895862dfe35aa3e7c618689.tar
marcuscom-ports-24767b2b26fadf85a895862dfe35aa3e7c618689.tar.gz
marcuscom-ports-24767b2b26fadf85a895862dfe35aa3e7c618689.tar.bz2
marcuscom-ports-24767b2b26fadf85a895862dfe35aa3e7c618689.tar.lz
marcuscom-ports-24767b2b26fadf85a895862dfe35aa3e7c618689.tar.xz
marcuscom-ports-24767b2b26fadf85a895862dfe35aa3e7c618689.tar.zst
marcuscom-ports-24767b2b26fadf85a895862dfe35aa3e7c618689.zip
Fix DVD and SCSI drive detection as well as report correct max CD write
speed. git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@1513 df743ca5-7f9a-e211-a948-0013205c9059
-rw-r--r--sysutils/nautilus-cd-burner/Makefile1
-rw-r--r--sysutils/nautilus-cd-burner/files/patch-cd-drive.c219
2 files changed, 198 insertions, 22 deletions
diff --git a/sysutils/nautilus-cd-burner/Makefile b/sysutils/nautilus-cd-burner/Makefile
index 5bedaa7a8..30404846d 100644
--- a/sysutils/nautilus-cd-burner/Makefile
+++ b/sysutils/nautilus-cd-burner/Makefile
@@ -7,6 +7,7 @@
PORTNAME= nautilus-cd-burner
PORTVERSION= 0.6.1
+PORTREVISION= 1
CATEGORIES= sysutils gnome
MASTER_SITES= ${MASTER_SITE_GNOME}
MASTER_SITE_SUBDIR= sources/${PORTNAME}/0.6
diff --git a/sysutils/nautilus-cd-burner/files/patch-cd-drive.c b/sysutils/nautilus-cd-burner/files/patch-cd-drive.c
index 3d6e63b6f..0612f018b 100644
--- a/sysutils/nautilus-cd-burner/files/patch-cd-drive.c
+++ b/sysutils/nautilus-cd-burner/files/patch-cd-drive.c
@@ -1,14 +1,132 @@
--- cd-drive.c.orig Mon Sep 8 15:24:07 2003
-+++ cd-drive.c Thu Oct 2 13:09:02 2003
-@@ -702,6 +702,7 @@
++++ cd-drive.c Sun Dec 21 02:40:36 2003
+@@ -693,28 +693,133 @@
+ #endif /* __linux__ */
+
+ #ifdef __FreeBSD__
++static void
++get_cd_properties (char *id, int *max_rd_speed, int *max_wr_speed,
++ CDDriveType *type)
++{
++ int i;
++ const char *argv[20];
++ char *dev_str, *stdout_data, *rd_speed, *wr_speed, *drive_cap;
++
++ *max_rd_speed = -1;
++ *max_wr_speed = -1;
++ *type = 0;
++
++ i = 0;
++ argv[i++] = "cdrecord";
++ argv[i++] = "-prcap";
++ dev_str = g_strdup_printf ("dev=%s", id);
++ argv[i++] = dev_str;
++ argv[i++] = NULL;
++
++ if (g_spawn_sync (NULL,
++ (char **)argv,
++ NULL,
++ G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL,
++ NULL, NULL,
++ &stdout_data,
++ NULL,
++ NULL,
++ NULL)) {
++ rd_speed = strstr (stdout_data, "Maximum read speed:");
++ if (rd_speed != NULL) {
++ char *tok;
++ rd_speed += strlen ("Maximum read speed:");
++ for (tok = strtok (rd_speed, " (),\t\n");
++ tok && strcmp (tok, "CD");
++ tok = strtok (NULL, " (),\t\n")) {}
++ tok = strtok (NULL, " (),\t\n"); /* Get the CD speed. */
++ *max_rd_speed = atol (tok);
++ }
++ else {
++ rd_speed = strstr (stdout_data, "Maximum read speed in kB/s:");
++ if (rd_speed != NULL) {
++ char *tok;
++ rd_speed += strlen ("Maximum read speed in kB/s:");
++ for (tok = strtok (rd_speed, " (),\t\n");
++ tok && strcmp (tok, "CD");
++ tok = strtok (NULL, " (),\t\n")) {}
++ tok = strtok (NULL, " (),\t\n"); /* Get the CD speed. */
++ *max_rd_speed = atol (tok);
++ }
++ }
++
++ wr_speed = strstr (stdout_data, "Maximum write speed:");
++ if (wr_speed != NULL) {
++ char *tok;
++ wr_speed += strlen ("Maximum write speed:");
++ for (tok = strtok (rd_speed, " (),\t\n");
++ tok && strcmp (tok, "CD");
++ tok = strtok (NULL, " (),\t\n")) {}
++ tok = strtok (NULL, " (),\t\n"); /* Get the CD speed. */
++ *max_wr_speed = atol (tok);
++ }
++ else {
++ wr_speed = strstr (stdout_data, "Maximum write speed in kB/s:");
++ if (wr_speed != NULL) {
++ char *tok;
++ wr_speed += strlen ("Maximum write speed in kB/s:");
++ for (tok = strtok (rd_speed, " (),\t\n");
++ tok && strcmp (tok, "CD");
++ tok = strtok (NULL, " (),\t\n")) {}
++ tok = strtok (NULL, " (),\t\n"); /* Get the CD speed. */
++ *max_wr_speed = atol (tok);
++ }
++ }
++ drive_cap = strstr (stdout_data, "Does write DVD-RAM media");
++ if (drive_cap != NULL) {
++ *type |= CDDRIVE_TYPE_DVD_RAM_RECORDER;
++ }
++ drive_cap = strstr (stdout_data, "Does read DVD-R media");
++ if (drive_cap != NULL) {
++ *type |= CDDRIVE_TYPE_DVD_RW_RECORDER;
++ }
++ drive_cap = strstr (stdout_data, "Does read DVD-ROM media");
++ if (drive_cap != NULL) {
++ *type |= CDDRIVE_TYPE_DVD_DRIVE;
++ }
++ drive_cap = strstr (stdout_data, "Does write CD-RW media");
++ if (drive_cap != NULL) {
++ *type |= CDDRIVE_TYPE_CDRW_RECORDER;
++ }
++ drive_cap = strstr (stdout_data, "Does write CD-R media");
++ if (drive_cap != NULL) {
++ *type |= CDDRIVE_TYPE_CD_RECORDER;
++ }
++ drive_cap = strstr (stdout_data, "Does read CD-R media");
++ if (drive_cap != NULL) {
++ *type |= CDDRIVE_TYPE_CD_DRIVE;
++ }
++ g_free (stdout_data);
++ }
++
++ g_free (dev_str);
++}
++
+ static GList *
+ freebsd_scan (gboolean recorder_only)
+ {
+ GList *cdroms_list = NULL;
+ const char *dev_type = "cd";
+- int fd;
int speed = 16; /* XXX Hardcode the write speed for now. */
- int max_speed = CDR_MAX_SPEED;
+- int max_speed = CDR_MAX_SPEED;
int i = 0;
+ int cnode = 1; /* Use the CD device's 'c' node. */
while (1) {
- CDDriveType type;
-@@ -714,7 +715,12 @@
+- CDDriveType type;
+ CDDrive *cdrom;
+- gchar *cam_path, *dev;
++ gchar *cam_path;
+ struct cam_device *cam_dev;
+
+- type = 0;
+ cam_path = g_strdup_printf ("/dev/%s%dc", dev_type, i);
if (!g_file_test (cam_path, G_FILE_TEST_EXISTS)) {
g_free (cam_path);
@@ -22,25 +140,82 @@
}
if ((cam_dev = cam_open_spec_device (dev_type, i, O_RDWR, NULL)) == NULL) {
-@@ -725,7 +731,11 @@
+@@ -723,47 +828,41 @@
+ continue;
+ }
- /* XXX Other controllers might need to be added. */
- if ((strncmp (cam_dev->sim_name, "ata", 3)) == 0) {
+- /* XXX Other controllers might need to be added. */
+- if ((strncmp (cam_dev->sim_name, "ata", 3)) == 0) {
- dev = g_strdup_printf ("/dev/a%s%dc", dev_type, i);
-+ if (cnode) {
-+ dev = g_strdup_printf ("/dev/a%s%dc", dev_type, i);
-+ } else {
-+ dev = g_strdup_printf ("/dev/a%s%d", dev_type, i);
-+ }
- } else {
- dev = g_strdup (cam_path);
- }
-@@ -742,7 +752,7 @@
- type |= CDDRIVE_TYPE_CD_DRIVE;
- if (ioctl (fd, CDRIOCWRITESPEED, &max_speed) >= 0) {
- /* XXX is it CD-R or CD-RW ? */
+- } else {
+- dev = g_strdup (cam_path);
+- }
+-
+- g_free (cam_path);
+-
+- if ((fd = open (dev, O_RDWR, 0)) < 0) {
+- g_free (dev);
+- free (cam_dev);
+- i++;
+- continue;
+- }
+-
+- type |= CDDRIVE_TYPE_CD_DRIVE;
+- if (ioctl (fd, CDRIOCWRITESPEED, &max_speed) >= 0) {
+- /* XXX is it CD-R or CD-RW ? */
- type |= CDDRIVE_TYPE_CD_RECORDER;
-+ type |= CDDRIVE_TYPE_CDRW_RECORDER;
+- }
+-
+- close (fd);
+-
+- if (type & CDDRIVE_TYPE_CD_RECORDER
+- || type & CDDRIVE_TYPE_CDRW_RECORDER
+- || recorder_only == FALSE) {
+- cdrom = g_new0 (CDDrive, 1);
+- cdrom->display_name = g_strdup_printf ("%s %s", cam_dev->inq_data.vendor, cam_dev->inq_data.revision);
+- cdrom->device = g_strdup (dev);
+- cdrom->max_speed_read = speed;
+- cdrom->max_speed_write = speed;
+- cdrom->cdrecord_id = g_strdup_printf ("%d,%d,%d", cam_dev->path_id, cam_dev->target_id, cam_dev->target_lun);
+- cdrom->type = type;
+-
+- add_dvd_plus (cdrom);
++ cdrom = g_new0 (CDDrive, 1);
++ cdrom->display_name = g_strdup_printf ("%s %s", cam_dev->inq_data.vendor, cam_dev->inq_data.revision);
++ cdrom->device = g_strdup (cam_path);
++ cdrom->cdrecord_id = g_strdup_printf ("%d,%d,%d", cam_dev->path_id, cam_dev->target_id, cam_dev->target_lun);
++ /* Attempt to get more specific information from
++ * this drive by using cdrecord.
++ */
++ get_cd_properties (cdrom->cdrecord_id,
++ &(cdrom->max_speed_read),
++ &(cdrom->max_speed_write),
++ &(cdrom->type));
++ if (cdrom->type & CDDRIVE_TYPE_CD_RECORDER
++ || cdrom->type & CDDRIVE_TYPE_CDRW_RECORDER
++ || cdrom->type & CDDRIVE_TYPE_DVD_RAM_RECORDER
++ || cdrom->type & CDDRIVE_TYPE_DVD_RW_RECORDER
++ || !recorder_only) {
++
++ if (cdrom->max_speed_read == -1) {
++ cdrom->max_speed_read = speed;
++ }
++ if (cdrom->max_speed_write == -1) {
++ cdrom->max_speed_write = speed;
++ }
++
++ if (cdrom->type & CDDRIVE_TYPE_DVD_DRIVE) {
++ add_dvd_plus (cdrom);
++ }
+
+ cdroms_list = g_list_append (cdroms_list, cdrom);
}
++ else {
++ cd_drive_free (cdrom);
++ }
+
+- g_free (dev);
++ g_free (cam_path);
+ free (cam_dev);
- close (fd);
+ i++;