Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F97495252
D37560.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
D37560.diff
View Options
diff --git a/stand/libofw/devicename.c b/stand/libofw/devicename.c
--- a/stand/libofw/devicename.c
+++ b/stand/libofw/devicename.c
@@ -105,3 +105,26 @@
return (mount_currdev(ev, flags, value));
}
+
+int
+ofw_common_parsedev(struct devdesc **dev, const char *devspec, const char **path,
+ const char *ofwtype)
+{
+ const char *rem_path;
+ struct ofw_devdesc *idev;
+
+ if (ofw_path_to_handle(devspec, ofwtype, &rem_path) == -1)
+ return (ENOENT);
+ idev = malloc(sizeof(struct ofw_devdesc));
+ if (idev == NULL) {
+ printf("ofw_parsedev: malloc failed\n");
+ return ENOMEM;
+ };
+ strlcpy(idev->d_path, devspec, min(rem_path - devspec + 1,
+ sizeof(idev->d_path)));
+ if (dev != NULL)
+ *dev = &idev->dd;
+ if (path != NULL)
+ *path = rem_path;
+ return 0;
+}
diff --git a/stand/libofw/libofw.h b/stand/libofw/libofw.h
--- a/stand/libofw/libofw.h
+++ b/stand/libofw/libofw.h
@@ -63,6 +63,8 @@
void ofw_memmap(int);
phandle_t ofw_path_to_handle(const char *ofwpath, const char *want_type, const char **path);
+int ofw_common_parsedev(struct devdesc **dev, const char *devspec, const char **path,
+ const char *ofwtype);
struct preloaded_file;
struct file_format;
diff --git a/stand/libofw/ofw_disk.c b/stand/libofw/ofw_disk.c
--- a/stand/libofw/ofw_disk.c
+++ b/stand/libofw/ofw_disk.c
@@ -234,21 +234,5 @@
static int
ofwd_parsedev(struct devdesc **dev, const char *devspec, const char **path)
{
- const char *rem_path;
- struct ofw_devdesc *idev;
-
- if (ofw_path_to_handle(devspec, ofwdisk.dv_name, &rem_path) == -1)
- return (ENOENT);
- idev = malloc(sizeof(struct ofw_devdesc));
- if (idev == NULL) {
- printf("ofw_parsedev: malloc failed\n");
- return ENOMEM;
- };
- strlcpy(idev->d_path, devspec, min(rem_path - devspec + 1,
- sizeof(idev->d_path)));
- if (dev != NULL)
- *dev = &idev->dd;
- if (path != NULL)
- *path = rem_path;
- return 0;
+ return (ofw_common_parsedev(dev, devspec, path, ofwdisk.dv_name));
}
diff --git a/stand/libofw/ofw_net.c b/stand/libofw/ofw_net.c
--- a/stand/libofw/ofw_net.c
+++ b/stand/libofw/ofw_net.c
@@ -308,23 +308,7 @@
static int
ofwnd_parsedev(struct devdesc **dev, const char *devspec, const char **path)
{
- const char *rem_path;
- struct ofw_devdesc *idev;
-
- if (ofw_path_to_handle(devspec, ofw_netdev.dv_name, &rem_path) == -1)
- return (ENOENT);
- idev = malloc(sizeof(struct ofw_devdesc));
- if (idev == NULL) {
- printf("ofw_parsedev: malloc failed\n");
- return ENOMEM;
- };
- strlcpy(idev->d_path, devspec, min(rem_path - devspec + 1,
- sizeof(idev->d_path)));
- if (dev != NULL)
- *dev = &idev->dd;
- if (path != NULL)
- *path = rem_path;
- return 0;
+ return (ofw_common_parsedev(dev, devspec, path, ofw_netdev.dv_name));
}
static bool
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 30, 5:29 PM (21 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13090256
Default Alt Text
D37560.diff (2 KB)
Attached To
Mode
D37560: stand/ofw: Refactor ofw parsedev
Attached
Detach File
Event Timeline
Log In to Comment