[sound-juicer] Fix device names on Solaris (#540857)



commit 3ecf057ab04d63c8eb80aa8f66848d52a605bd27
Author: Brian Cameron <brian cameron oracle com>
Date:   Mon Oct 10 15:17:06 2011 +0100

    Fix device names on Solaris (#540857)
    
    Solaris is unique that it separates /dev/dsk and /dev/rdsk where /dev/dsk is
    the logical name for the drive and /dev/rdsk is the raw device name.  You need
    to use the raw device name to acutally access the device.  For example, you can
    refer here for more information:
    
      http://docs.sun.com/app/docs/doc/801-7038/6i1cfovsu?a=view
    
    Note that the sound-juicer code already has some code to manage this in the
    function sj_metadata_getter_set_cdrom() in libjuicer/sj-metadata-getter.c.
    
    The attached patch adds 3 more places in the code where "/dev/rdsk" is needed
    for sound-juicer to work well on Solaris.  It also fixes the one place in
    libjuicer/sj-metadata-getter.c which already references "/dev/rdsk" so the
     #ifdef matches the others.  THere is no need to also check for "__SVR4".
    
    Signed-off-by: Ross Burton <ross linux intel com>

 libjuicer/sj-metadata-getter.c |    2 +-
 libjuicer/sj-metadata-gvfs.c   |    4 ++++
 src/sj-main.c                  |   12 +++++++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/libjuicer/sj-metadata-getter.c b/libjuicer/sj-metadata-getter.c
index 2d3ec88..0ae49b3 100644
--- a/libjuicer/sj-metadata-getter.c
+++ b/libjuicer/sj-metadata-getter.c
@@ -119,7 +119,7 @@ sj_metadata_getter_set_cdrom (SjMetadataGetter *mdg, const char* device)
 
   g_free (priv->cdrom);
 
-#if defined (sun) && defined (__SVR4)
+#ifdef __sun
   if (g_str_has_prefix (device, "/dev/dsk/")) {
     priv->cdrom = g_strdup_printf ("/dev/rdsk/%s", device + strlen ("/dev/dsk/"));
     return;
diff --git a/libjuicer/sj-metadata-gvfs.c b/libjuicer/sj-metadata-gvfs.c
index 5d31b10..f9fb95a 100644
--- a/libjuicer/sj-metadata-gvfs.c
+++ b/libjuicer/sj-metadata-gvfs.c
@@ -63,7 +63,11 @@ device_to_cdda_uri (const char *device)
 {
   if (g_str_has_prefix (device, "/dev/") == FALSE)
     return NULL;
+#ifdef __sun    
+  return g_strdup_printf ("cdda://%s", device + strlen ("/dev/rdsk/"));
+#else  
   return g_strdup_printf ("cdda://%s", device + strlen ("/dev/"));
+#endif   
 }
 
 static GList *
diff --git a/src/sj-main.c b/src/sj-main.c
index 1a1e5f5..0133c77 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -1843,15 +1843,25 @@ int main (int argc, char **argv)
   if (device == NULL && uris == NULL) {
     device_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_DEVICE, NULL, TRUE, NULL), GINT_TO_POINTER (TRUE));
   } else {
-    if (device)
+    if (device) {
+#ifdef __sun
+      if (strstr(device, "/dev/dsk/") != NULL ) {
+        device = g_strdup_printf("/dev/rdsk/%s", device + strlen("/dev/dsk/"));
+      }
+#endif
       set_device (device, TRUE);
+    }
     else {
       char *d;
 
       /* Mash up the CDDA URIs into a device path */
       if (g_str_has_prefix (uris[0], "cdda://")) {
       	gint len;
+#ifdef __sun
+        d = g_strdup_printf ("/dev/rdsk/%s", uris[0] + strlen ("cdda://"));
+#else
         d = g_strdup_printf ("/dev/%s%c", uris[0] + strlen ("cdda://"), '\0');
+#endif
         /* Take last '/' out of path, or set_device thinks it is part of the device name */
 		len = strlen (d);
 		if (d[len - 1] == '/')



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]