mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-01 05:45:45 +00:00
Add two additional properties to disc media so that applications can
determine when media is available and that media's capacity. Reported by: Alexander Logvinov <freebsd@akavia.ru>
This commit is contained in:
parent
136e55f9dd
commit
3c841de8eb
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=226234
@ -8,7 +8,7 @@
|
||||
|
||||
PORTNAME= hal
|
||||
DISTVERSION= 0.5.11
|
||||
PORTREVISION= 10
|
||||
PORTREVISION= 11
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= http://hal.freedesktop.org/releases/
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
--- hald/freebsd/probing/probe-storage.c.orig 2009-01-12 16:07:59.000000000 -0500
|
||||
+++ hald/freebsd/probing/probe-storage.c 2009-01-12 16:20:20.000000000 -0500
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
+#include <sys/ioctl.h>
|
||||
+#include <sys/disk.h>
|
||||
#include <netinet/in.h>
|
||||
#include <glib.h>
|
||||
#include <libvolume_id.h>
|
||||
@@ -211,7 +213,26 @@ main (int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
if (hfp_cdrom_test_unit_ready(cdrom))
|
||||
- ret = 2; /* has media */
|
||||
+ {
|
||||
+ int fd;
|
||||
+ off_t size;
|
||||
+
|
||||
+ libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", TRUE, &hfp_error);
|
||||
+ fd = open(device_file, O_RDONLY | O_NONBLOCK);
|
||||
+ if (fd > -1)
|
||||
+ {
|
||||
+ if (ioctl (fd, DIOCGMEDIASIZE, &size) == 0)
|
||||
+ {
|
||||
+ libhal_device_set_property_uint64(hfp_ctx, hfp_udi, "storage.removable.media_size", size, &hfp_error);
|
||||
+ }
|
||||
+ close(fd);
|
||||
+ }
|
||||
+ ret = 2; /* has media */
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ libhal_device_set_property_bool(hfp_ctx, hfp_udi, "storage.removable.media_available", FALSE, &hfp_error);
|
||||
+ }
|
||||
|
||||
hfp_cdrom_free(cdrom);
|
||||
}
|
Loading…
Reference in New Issue
Block a user