From 64fa40e2e2c953ed8344c19dba2391c90cfd0237 Mon Sep 17 00:00:00 2001 From: QiaoChong Date: Tue, 16 Jul 2019 17:16:19 +0800 Subject: [PATCH] devfs: devfs add missing get_device, loopdev need this. Change-Id: I45253566af1bcdd61ab3c54dbc5152d5a1fc4766 Signed-off-by: QiaoChong --- pmon/fs/devfs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pmon/fs/devfs.c b/pmon/fs/devfs.c index c83bed66..3532bc61 100755 --- a/pmon/fs/devfs.c +++ b/pmon/fs/devfs.c @@ -637,6 +637,34 @@ find_device(name) return NULL; } +struct device *get_device(dev_t dev) +{ + extern struct devsw devswitch[]; + struct cfdata *cf; + struct cfdriver *cd; + struct device *dv; + int i; + int major,minor; + struct devsw *devsw; + + major = dev>>8; + minor =dev & 0xff; + devsw = &devswitch[major]; + + for(cf = cfdata; (cd = cf->cf_driver); cf++) { + if(cd->cd_devs == NULL) + continue; + + if(strcmp(devsw->name,cd->cd_name)) + continue; + + if((dv = cd->cd_devs[minor]) == NULL) + continue; + + return dv; + } + return NULL; +} /* * File system registration info.