152
154
HAL_DEBUG (("Doing probe-storage for %s (bus %s) (drive_type %s) (udi=%s) (--only-check-for-fs==%d)",
153
155
device_file, bus, drive_type, udi, only_check_for_fs));
155
if (!only_check_for_fs) {
156
/* Get properties for CD-ROM drive */
157
if (strcmp (drive_type, "cdrom") == 0) {
159
int read_speed, write_speed;
162
HAL_DEBUG (("Doing open (\"%s\", O_RDONLY | O_NONBLOCK)", device_file));
163
fd = open (device_file, O_RDONLY | O_NONBLOCK);
165
HAL_ERROR (("Cannot open %s: %s", device_file, strerror (errno)));
168
HAL_DEBUG (("Returned from open(2)"));
157
/* Get properties for CD-ROM drive */
158
if (strcmp (drive_type, "cdrom") == 0) {
160
int read_speed, write_speed;
163
HAL_DEBUG (("Doing open (\"%s\", O_RDONLY | O_NONBLOCK)", device_file));
164
fd = open (device_file, O_RDONLY | O_NONBLOCK);
166
HAL_ERROR (("Cannot open %s: %s", device_file, strerror (errno)));
169
HAL_DEBUG (("Returned from open(2)"));
170
if (ioctl (fd, CDROM_SET_OPTIONS, CDO_USE_FFLAGS) < 0) {
171
HAL_ERROR (("Error: CDROM_SET_OPTIONS failed: %s\n", strerror(errno)));
171
if (ioctl (fd, CDROM_SET_OPTIONS, CDO_USE_FFLAGS) < 0) {
172
HAL_ERROR (("Error: CDROM_SET_OPTIONS failed: %s\n", strerror(errno)));
177
if (!only_check_for_fs) {
176
178
capabilities = ioctl (fd, CDROM_GET_CAPABILITY, 0);
177
179
if (capabilities < 0) {
218
220
if (profile & DRIVE_CDROM_CAPS_DVDRW)
219
221
libhal_changeset_set_property_bool (cs, "storage.cdrom.dvdrw", TRUE);
220
222
if (profile & DRIVE_CDROM_CAPS_DVDPLUSR)
221
libhal_changeset_set_property_bool(cs, "storage.cdrom.dvdplusr", TRUE);
223
libhal_changeset_set_property_bool (cs, "storage.cdrom.dvdplusr", TRUE);
222
224
if (profile & DRIVE_CDROM_CAPS_DVDPLUSRW)
223
225
libhal_changeset_set_property_bool (cs, "storage.cdrom.dvdplusrw", TRUE);
224
226
if (profile & DRIVE_CDROM_CAPS_DVDPLUSRWDL)
225
227
libhal_changeset_set_property_bool (cs, "storage.cdrom.dvdplusrwdl", TRUE);
226
228
if (profile & DRIVE_CDROM_CAPS_DVDPLUSRDL)
227
libhal_changeset_set_property_bool (cs, "storage.cdrom.dvdplusrdl", TRUE);
229
libhal_changeset_set_property_bool (cs, "storage.cdrom.dvdplusrdl", TRUE);
230
if (profile & DRIVE_CDROM_CAPS_BDROM)
231
libhal_changeset_set_property_bool (cs, "storage.cdrom.bd", TRUE);
232
if (profile & DRIVE_CDROM_CAPS_BDR)
233
libhal_changeset_set_property_bool (cs, "storage.cdrom.bdr", TRUE);
234
if (profile & DRIVE_CDROM_CAPS_BDRE)
235
libhal_changeset_set_property_bool (cs, "storage.cdrom.bdre", TRUE);
236
if (profile & DRIVE_CDROM_CAPS_HDDVDROM)
237
libhal_changeset_set_property_bool (cs, "storage.cdrom.hddvd", TRUE);
238
if (profile & DRIVE_CDROM_CAPS_HDDVDR)
239
libhal_changeset_set_property_bool (cs, "storage.cdrom.hddvdr", TRUE);
240
if (profile & DRIVE_CDROM_CAPS_HDDVDRW)
241
libhal_changeset_set_property_bool (cs, "storage.cdrom.hddvdrw", TRUE);
229
243
if (capabilities & CDC_DVD_R) {
230
244
libhal_changeset_set_property_bool (cs, "storage.cdrom.dvdr", TRUE);
254
268
libhal_changeset_set_property_bool (cs, "storage.cdrom.support_multisession", FALSE);
257
if (get_read_write_speed(fd, &read_speed, &write_speed, &write_speeds) >= 0) {
258
libhal_changeset_set_property_int (cs, "storage.cdrom.read_speed", read_speed);
259
if (write_speed > 0) {
260
libhal_changeset_set_property_int (
261
cs, "storage.cdrom.write_speed", write_speed);
263
if (write_speeds != NULL)
266
wspeeds = g_strsplit_set (write_speeds, ",", -1);
267
libhal_changeset_set_property_strlist (cs,
268
"storage.cdrom.write_speeds",
269
(const char **) wspeeds);
270
g_strfreev (wspeeds);
274
gchar *wspeeds[1] = {NULL};
275
libhal_changeset_set_property_int (cs, "storage.cdrom.write_speed", 0);
273
if (get_read_write_speed(fd, &read_speed, &write_speed, &write_speeds) >= 0) {
274
libhal_changeset_set_property_int (cs, "storage.cdrom.read_speed", read_speed);
276
if (write_speed > 0) {
277
libhal_changeset_set_property_int (cs, "storage.cdrom.write_speed", write_speed);
279
if (write_speeds != NULL)
283
wspeeds = g_strsplit_set (write_speeds, ",", -1);
276
284
libhal_changeset_set_property_strlist (cs, "storage.cdrom.write_speeds",
277
285
(const char **) wspeeds);
286
g_strfreev (wspeeds);
291
gchar *wspeeds[1] = {NULL};
292
libhal_changeset_set_property_int (cs, "storage.cdrom.write_speed", 0);
293
libhal_changeset_set_property_strlist (cs, "storage.cdrom.write_speeds",
294
(const char **) wspeeds);
284
} /* !only_check_for_fs */
288
303
/* Also return 2 if we're a cdrom and we got a disc */
455
470
vid = volume_id_open_fd (fd);
456
471
if (vid != NULL) {
457
472
if (volume_id_probe_all (vid, 0, size) == 0) {
458
474
/* signal to hald that we've found something and a fakevolume
459
475
* should be added - see hald/linux/blockdev.c:add_blockdev_probing_helper_done()
460
476
* and hald/linux/blockdev.c:block_rescan_storage_done().
462
if (vid->usage_id == VOLUME_ID_FILESYSTEM ||
463
vid->usage_id == VOLUME_ID_RAID ||
464
vid->usage_id == VOLUME_ID_OTHER ||
465
vid->usage_id == VOLUME_ID_CRYPTO)
479
if (volume_id_get_usage(vid, &usage) &&
480
( strcmp(usage, "filesystem") == 0 ||
481
strcmp(usage, "raid") == 0 ||
482
strcmp(usage, "other") == 0 ||
483
strcmp(usage, "crypto") == 0))