On Thu 30-07-15 13:48:04, Dongsheng Yang wrote: > This commit introduce a file of fs/dev.c at first. This is > a internal file shared by block_dev and char_dev. There is > only one function in it __lookup_dev which will be wrapped > to be lookup_bdev and loopup_cdev. > > We will put more code in this file which is shared by > block_dev and char_dev. > > Signed-off-by: Dongsheng Yang <yangds.fnst@xxxxxxxxxxxxxx> > --- > fs/Makefile | 2 +- > fs/block_dev.c | 26 ++------------------ > fs/dev.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > fs/internal.h | 14 +++++++++++ > 4 files changed, 94 insertions(+), 25 deletions(-) > create mode 100644 fs/dev.c > ... > +/** > + * __lookup_dev - lookup a block_device or cdev by name > + * @pathname: special file representing the device > + * @cdevp: cdev would be returned by cdevp > + * @bdevp: block_device would be returned by bdevp > + * > + * Get a reference to the block_deivce or cdev at @pathname in > + * the current namespace if possible and return it. > + */ > +int __lookup_dev(const char *pathname, struct cdev **cdevp, > + struct block_device **bdevp) > +{ > + struct inode *inode; > + struct path path; > + int error = 0; > + > + if (!pathname || !*pathname) > + return -EINVAL; > + > + error = kern_path(pathname, LOOKUP_FOLLOW, &path); > + if (error) > + return error; > + > + inode = d_backing_inode(path.dentry); > + > + /** > + * We need at least one of bdevp and cdevp to be NULL, > + * but cdevp and bdevp can not be both NULL. > + */ > + error = -EINVAL; > + if (!(cdevp || bdevp) || (cdevp && bdevp)) > + goto out; Why don't you allow both cdevp and bdevp to be set and in that case accept both block & character device and just set appropriate pointer and the other one to NULL? Then quota code wouldn't have to search twice... Honza -- Jan Kara <jack@xxxxxxxx> SUSE Labs, CR -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html