The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1e9b23448a3010e8403eae08ad890fe1eb75da8b

commit 1e9b23448a3010e8403eae08ad890fe1eb75da8b
Author:     Warner Losh <i...@freebsd.org>
AuthorDate: 2022-08-11 15:08:26 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2022-08-11 16:27:17 +0000

    stand: userboot_fmtdev can be reduced to devformat
    
    devformat produces the same output as userboot_fmtdev, so just use it to
    reduce on the dependencies. In addition, we don't need to use the
    incomplete struct userboot_devdesc type, we can use struct devdesc
    instead (in fact, there's no userboot_devdesc defined anywhere).
    
    Sponsored by:           Netflix
    Reviewed by:            jhb (prior version)
    Differential Revision:  https://reviews.freebsd.org/D35925
---
 stand/userboot/userboot/bootinfo32.c  |  6 +++---
 stand/userboot/userboot/bootinfo64.c  |  4 ++--
 stand/userboot/userboot/devicename.c  | 34 ----------------------------------
 stand/userboot/userboot/libuserboot.h |  1 -
 stand/userboot/userboot/main.c        |  2 +-
 5 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/stand/userboot/userboot/bootinfo32.c 
b/stand/userboot/userboot/bootinfo32.c
index ecd4ccf2edd8..b830b767906d 100644
--- a/stand/userboot/userboot/bootinfo32.c
+++ b/stand/userboot/userboot/bootinfo32.c
@@ -139,7 +139,7 @@ int
 bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, 
vm_offset_t *modulep, vm_offset_t *kernendp)
 {
     struct preloaded_file      *xp, *kfp;
-    struct i386_devdesc                *rootdev;
+    struct devdesc             *rootdev;
     struct file_metadata       *md;
     vm_offset_t                        addr;
     vm_offset_t                        kernend;
@@ -167,12 +167,12 @@ bi_load32(char *args, int *howtop, int *bootdevp, 
vm_offset_t *bip, vm_offset_t
     }
 
     /* Try reading the /etc/fstab file to select the root device */
-    getrootmount(userboot_fmtdev((void *)rootdev));
+    getrootmount(devformat(rootdev));
 
     bootdevnr = 0;
 #if 0
     if (bootdevnr == -1) {
-       printf("root device %s invalid\n", i386_fmtdev(rootdev));
+       printf("root device %s invalid\n", devformat(rootdev));
        return (EINVAL);
     }
 #endif
diff --git a/stand/userboot/userboot/bootinfo64.c 
b/stand/userboot/userboot/bootinfo64.c
index 60887413e0ec..0086ef21b60a 100644
--- a/stand/userboot/userboot/bootinfo64.c
+++ b/stand/userboot/userboot/bootinfo64.c
@@ -182,7 +182,7 @@ int
 bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
 {
     struct preloaded_file      *xp, *kfp;
-    struct userboot_devdesc    *rootdev;
+    struct devdesc             *rootdev;
     struct file_metadata       *md;
     vm_offset_t                        addr;
     uint64_t                   kernend;
@@ -211,7 +211,7 @@ bi_load64(char *args, vm_offset_t *modulep, vm_offset_t 
*kernendp)
     }
 
     /* Try reading the /etc/fstab file to select the root device */
-    getrootmount(userboot_fmtdev((void *)rootdev));
+    getrootmount(devformat(rootdev));
 
     /* find the last module in the chain */
     addr = 0;
diff --git a/stand/userboot/userboot/devicename.c 
b/stand/userboot/userboot/devicename.c
index e770e6bf4bb1..45bf9bc6ebd8 100644
--- a/stand/userboot/userboot/devicename.c
+++ b/stand/userboot/userboot/devicename.c
@@ -176,40 +176,6 @@ fail:
 }
 
 
-char *
-userboot_fmtdev(void *vdev)
-{
-       struct devdesc *dev = (struct devdesc *)vdev;
-       static char buf[128];   /* XXX device length constant? */
-
-       switch(dev->d_dev->dv_type) {
-       case DEVT_NONE:
-               strcpy(buf, "(no device)");
-               break;
-
-       case DEVT_CD:
-               sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
-               break;
-
-       case DEVT_DISK:
-               return (disk_fmtdev(vdev));
-
-       case DEVT_NET:
-               sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
-               break;
-
-       case DEVT_ZFS:
-#if defined(USERBOOT_ZFS_SUPPORT)
-               return (zfs_fmtdev(vdev));
-#else
-               sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
-#endif
-               break;
-       }
-       return (buf);
-}
-
-
 /*
  * Set currdev to suit the value being supplied in (value)
  */
diff --git a/stand/userboot/userboot/libuserboot.h 
b/stand/userboot/userboot/libuserboot.h
index 75732c6c0e38..eb3bada097e4 100644
--- a/stand/userboot/userboot/libuserboot.h
+++ b/stand/userboot/userboot/libuserboot.h
@@ -57,7 +57,6 @@ extern ssize_t userboot_copyin(const void *, vm_offset_t, 
size_t);
 extern ssize_t userboot_copyout(vm_offset_t, void *, size_t);
 extern ssize_t userboot_readin(readin_handle_t, vm_offset_t, size_t);
 extern int userboot_getdev(void **, const char *, const char **);
-char   *userboot_fmtdev(void *vdev);
 int    userboot_setcurrdev(struct env_var *ev, int flags, const void *value);
 
 int    bi_getboothowto(char *kargs);
diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c
index d323d1f9789b..9ede0cd360e9 100644
--- a/stand/userboot/userboot/main.c
+++ b/stand/userboot/userboot/main.c
@@ -285,7 +285,7 @@ extract_currdev(void)
                dd = &dev.dd;
        }
 
-       set_currdev(userboot_fmtdev(dd));
+       set_currdev(devformat(dd));
 
 #if defined(USERBOOT_ZFS_SUPPORT)
        if (userboot_zfs_found) {

Reply via email to