Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103080041
D32744.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D32744.diff
View Options
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -945,3 +945,22 @@
void *_propvalue;
size_t _size;
} DEFAULT null_get_property;
+
+/**
+ * @brief Gets a child's full path to the device
+ *
+ * The get_device_path method retrieves a device's
+ * full path to the device using one of several
+ * locators present in the system.
+ *
+ * @param _bus the bus device
+ * @param _child the child device
+ * @param _locator locator name
+ * @param _sb buffer loaction string
+ */
+METHOD int get_device_path {
+ device_t _bus;
+ device_t _child;
+ const char *_locator;
+ struct sbuf *_sb;
+} DEFAULT bus_generic_get_device_path;
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -4627,6 +4627,41 @@
return (ENOENT);
}
+/**
+ * @brief Helper function to implement normal BUS_GET_DEVICE_PATH()
+ *
+ * This function knows how to (a) pass the request up the tree if there's
+ * a parent and (b) Knows how to supply a FreeBSD locator.
+ *
+ * @param bus bus in the walk up the tree
+ * @param child leaf node to print information about
+ * @param locator BUS_LOCATOR_xxx string for locator
+ * @param sb Buffer to print information into
+ */
+int
+bus_generic_get_device_path(device_t bus, device_t child, const char *locator,
+ struct sbuf *sb)
+{
+ int rv = 0;
+ device_t parent;
+
+ parent = device_get_parent(bus);
+ if (parent != NULL)
+ rv = BUS_GET_DEVICE_PATH(parent, bus, locator, sb);
+ if (strcmp(locator, BUS_LOCATOR_FREEBSD) == 0) {
+ if (rv == 0) {
+ sbuf_printf(sb, "/%s", device_get_nameunit(child));
+ }
+ return (rv);
+ }
+ /*
+ * Don't know what to do. So assume we do nothing. Not sure that's
+ * the right thing, but keeps us from having a big list here.
+ */
+ return (0);
+}
+
+
/**
* @brief Helper function for implementing BUS_RESCAN().
*
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -491,6 +491,8 @@
struct resource_map *map);
int bus_generic_write_ivar(device_t dev, device_t child, int which,
uintptr_t value);
+int bus_generic_get_device_path(device_t bus, device_t child, const char *locator,
+ struct sbuf *sb);
int bus_helper_reset_post(device_t dev, int flags);
int bus_helper_reset_prepare(device_t dev, int flags);
int bus_null_rescan(device_t dev);
@@ -734,6 +736,8 @@
#define BUS_PASS_ORDER_LATE 7
#define BUS_PASS_ORDER_LAST 9
+#define BUS_LOCATOR_FREEBSD "FreeBSD"
+
extern int bus_current_pass;
void bus_set_pass(int pass);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 4:33 PM (22 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14764095
Default Alt Text
D32744.diff (2 KB)
Attached To
Mode
D32744: bus: Introduce the bus interface get_device_path
Attached
Detach File
Event Timeline
Log In to Comment