1 --- libdiscid-0.6.1/src/disc_solaris.c 2013-10-03 22:01:15.000000000 +0400
2 +++ disc_solaris.c 2016-02-01 12:27:13.037093987 +0300
10 +#include <sys/dkio.h>
13 #include "discid/discid.h"
14 #include "discid/discid_private.h"
17 -#define NUM_CANDIDATES 2
18 +#define MAX_CANDIDATES 255
19 +#define REMOVABLE_MEDIA_DIR "/dev/removable-media/rdsk"
21 -static char *device_candidates[NUM_CANDIDATES] = {"/vol/dev/aliases/cdrom0",
22 - "/volumes/dev/aliases/cdrom0"};
23 +char *device_candidates[MAX_CANDIDATES] = {};
25 +int get_candidates_devices() {
29 + devdir = opendir(REMOVABLE_MEDIA_DIR);
32 + struct dirent *entry;
34 + while(entry = readdir(devdir)){
37 + len=strlen(entry->d_name);
39 + /* We are looking for /dev/removable-media/rdsk/*p0 devices */
40 + if (len>2 && entry->d_name[len-1] == '0' && entry->d_name[len-2] == 'p') {
41 + char dev[PATH_MAX+1];
44 + snprintf(dev, PATH_MAX+1, "%s/%s", REMOVABLE_MEDIA_DIR, entry->d_name);
45 + fl=open(dev,O_RDONLY);
47 + struct dk_cinfo dkci;
49 + if(ioctl(fl, DKIOCINFO, &dkci) != -1){
50 + if (dkci.dki_ctype & DKC_CDROM == DKC_CDROM) {
51 + if (devnum < MAX_CANDIDATES){
53 + device_candidates[devnum-1]=strdup(dev);
62 + /* If no devices were found, revert to old behavior */
64 + device_candidates[0]=strdup("/vol/dev/aliases/cdrom0");
65 + device_candidates[1]=strdup("/volumes/dev/aliases/cdrom0");
71 int mb_disc_unix_read_toc_header(int fd, mb_disc_toc *toc) {
72 struct cdrom_tochdr th;
76 char *mb_disc_get_default_device_unportable(void) {
77 - return mb_disc_unix_find_device(device_candidates, NUM_CANDIDATES);
81 + nc=get_candidates_devices();
82 + ret=mb_disc_unix_find_device(device_candidates, nc);
84 + free(device_candidates[i]);
89 int mb_disc_has_feature_unportable(enum discid_feature feature) {