~ubuntu-branches/debian/sid/hal/sid

« back to all changes in this revision

Viewing changes to hald/linux/probing/probe-volume.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-10-23 12:33:58 UTC
  • Revision ID: james.westby@ubuntu.com-20071023123358-xaf8mjc5n84d5gtz
Tags: upstream-0.5.10
ImportĀ upstreamĀ versionĀ 0.5.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
{
94
94
        char buf[256];
95
95
        const char *usage;
96
 
        char *volume_label;
 
96
        const char *type;
 
97
        const char *type_version;
 
98
        const char *label;
 
99
        const char *uuid;
97
100
        DBusError error;
98
101
 
99
102
        dbus_error_init (&error);
100
103
 
101
 
        switch (vid->usage_id) {
102
 
        case VOLUME_ID_FILESYSTEM:
103
 
                usage = "filesystem";
104
 
                break;
105
 
        case VOLUME_ID_OTHER:
106
 
                usage = "other";
107
 
                break;
108
 
        case VOLUME_ID_RAID:
109
 
                usage = "raid";
110
 
                break;
111
 
        case VOLUME_ID_CRYPTO:
112
 
                usage = "crypto";
113
 
                break;
114
 
        case VOLUME_ID_UNUSED:
115
 
                libhal_changeset_set_property_string (cs, "info.product", "Volume (unused)");
116
 
                usage = "unused";
117
 
                return;
118
 
        default:
 
104
        if (!volume_id_get_usage(vid, &usage))
119
105
                usage = "";
120
 
        }
121
 
 
122
106
        libhal_changeset_set_property_string (cs, "volume.fsusage", usage);
123
107
        HAL_DEBUG (("volume.fsusage = '%s'", usage));
124
108
 
125
 
        if (!libhal_changeset_set_property_string (cs, "volume.fstype", vid->type))
 
109
        if (!volume_id_get_type(vid, &type))
 
110
                type = "";
 
111
        if (!libhal_changeset_set_property_string (cs, "volume.fstype", type))
126
112
                libhal_changeset_set_property_string (cs, "volume.fstype", "");
127
 
 
128
 
        HAL_DEBUG(("volume.fstype = '%s'", vid->type));
129
 
 
130
 
        if (vid->type_version[0] != '\0') {
131
 
                libhal_changeset_set_property_string (cs, "volume.fsversion", vid->type_version);
132
 
                HAL_DEBUG(("volume.fsversion = '%s'", vid->type_version));
133
 
        }
134
 
 
135
 
        libhal_changeset_set_property_string (cs, "volume.uuid", vid->uuid);
136
 
        HAL_DEBUG(("volume.uuid = '%s'", vid->uuid));
137
 
 
138
 
        if(vid->label != NULL && vid->label[0] != '\0') {
 
113
        HAL_DEBUG(("volume.fstype = '%s'", type));
 
114
 
 
115
        if (!volume_id_get_type_version(vid, &type_version))
 
116
                type_version = "";
 
117
        libhal_changeset_set_property_string (cs, "volume.fsversion", type_version);
 
118
        HAL_DEBUG(("volume.fsversion = '%s'", type_version));
 
119
 
 
120
        if (!volume_id_get_uuid(vid, &uuid))
 
121
                uuid = "";
 
122
        libhal_changeset_set_property_string (cs, "volume.uuid", uuid);
 
123
        HAL_DEBUG(("volume.uuid = '%s'", uuid));
 
124
 
 
125
        if (!volume_id_get_label(vid, &label))
 
126
                label = "";
 
127
 
 
128
        if (label[0] != '\0') {
 
129
                char *volume_label;
 
130
 
139
131
                /* we need to be sure for a utf8 valid label, because dbus accept only utf8 valid strings */
140
 
                volume_label = strdup_valid_utf8 (vid->label);
 
132
                volume_label = strdup_valid_utf8 (label);
141
133
                if( volume_label != NULL ) {
142
134
                        libhal_changeset_set_property_string (cs, "volume.label", volume_label);
143
135
                        HAL_DEBUG(("volume.label = '%s'", volume_label));
144
 
                
145
 
                        if (strlen(volume_label) > 0) { 
 
136
 
 
137
                        if (volume_label[0] != '\0') {
146
138
                                libhal_changeset_set_property_string (cs, "info.product", volume_label);
147
139
                                g_free(volume_label);
148
140
                                return;
152
144
                }
153
145
        }
154
146
 
155
 
        if (vid->type != NULL) {
156
 
                snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
 
147
        if (type[0] != '\0') {
 
148
                snprintf (buf, sizeof (buf), "Volume (%s)", type);
157
149
        } else {
158
150
                snprintf (buf, sizeof (buf), "Volume (unknown)");
159
151
        }
160
 
 
161
152
        libhal_changeset_set_property_string (cs, "info.product", buf);
162
153
}
163
154
 
189
180
        
190
181
        /* set defaults */
191
182
        libhal_changeset_set_property_bool (cs, "volume.disc.is_videodvd", FALSE);
 
183
        libhal_changeset_set_property_bool (cs, "volume.disc.is_blurayvideo", FALSE);
192
184
        libhal_changeset_set_property_bool (cs, "volume.disc.is_vcd", FALSE);
193
185
        libhal_changeset_set_property_bool (cs, "volume.disc.is_svcd", FALSE);
194
186
        
264
256
                                HAL_DEBUG(("Disc in %s is a Video DVD", device_file));
265
257
                                break;
266
258
                        }
 
259
                        else if (!strcmp (dirname, "BDMV"))
 
260
                        {
 
261
                                libhal_changeset_set_property_bool (cs, "volume.disc.is_blurayvideo", TRUE);
 
262
                                HAL_DEBUG(("Disc in %s is a Blu-ray video disc", device_file));
 
263
                                break;
 
264
                        }
267
265
                        else if (!strcmp (dirname, "VCD"))
268
266
                        {
269
267
                                libhal_changeset_set_property_bool (cs, "volume.disc.is_vcd", TRUE);
623
621
                if (vid != NULL) {
624
622
                        int vid_ret;
625
623
                        HAL_INFO (("invoking volume_id_probe_all, offset=%d, size=%d", vol_probe_offset, vol_size));
626
 
                        vid_ret = volume_id_probe_all (vid, vol_probe_offset , vol_size);
 
624
                        vid_ret = volume_id_probe_all (vid, vol_probe_offset, vol_size);
627
625
                        HAL_INFO (("volume_id_probe_all returned %d", vid_ret));
628
626
 
629
627
                        if (vid_ret != 0 && is_disc && vol_probe_offset != 0) {
644
642
                                libhal_changeset_set_property_string (cs, "info.product", "Volume");
645
643
                        }
646
644
 
647
 
                        /* VOLUME_ID_UNUSED means vol_id didn't detect anything that it knows about
648
 
                         * if it's a disc.. look whether it's a partition table (some Apple discs
 
645
                        /* If we didn't detect anything, look whether it's a partition table (some Apple discs
649
646
                         * uses Apple Partition Map) and look at partitions
650
647
                         *
651
648
                         * (kind of a hack - ugh  - we ought to export all these as fakevolumes... but
652
649
                         *  this is good enough for now... the only discs I know of that does this
653
650
                         *  is in fact Apple's install disc.)
654
651
                         */
655
 
                        if (vid->usage_id == VOLUME_ID_UNUSED && is_disc) {
 
652
                        if (vid_ret != 0 && is_disc) {
656
653
                                PartitionTable *p;
657
654
                                p = part_table_load_from_disk (stordev_dev_file);
658
655
                                if (p != NULL) {