Export devfs inode number allocator for the kernel consumers.

Reviewed by:	jhb
MFC after:	2 weeks
This commit is contained in:
Konstantin Belousov 2011-10-05 16:50:15 +00:00
parent 6c6aa80c9d
commit 084e62e91b
2 changed files with 20 additions and 3 deletions

View File

@ -171,8 +171,7 @@ devfs_free(struct cdev *cdev)
cdp = cdev2priv(cdev);
if (cdev->si_cred != NULL)
crfree(cdev->si_cred);
if (cdp->cdp_inode > 0)
free_unr(devfs_inos, cdp->cdp_inode);
devfs_free_cdp_inode(cdp->cdp_inode);
if (cdp->cdp_maxdirent > 0)
free(cdp->cdp_dirents, M_DEVFS2);
free(cdp, M_CDEVP);
@ -394,7 +393,7 @@ devfs_delete(struct devfs_mount *dm, struct devfs_dirent *de, int flags)
mac_devfs_destroy(de);
#endif
if (de->de_inode > DEVFS_ROOTINO) {
free_unr(devfs_inos, de->de_inode);
devfs_free_cdp_inode(de->de_inode);
de->de_inode = 0;
}
if (DEVFS_DE_DROP(de))
@ -685,6 +684,21 @@ devfs_destroy(struct cdev *dev)
devfs_generation++;
}
ino_t
devfs_alloc_cdp_inode(void)
{
return (alloc_unr(devfs_inos));
}
void
devfs_free_cdp_inode(ino_t ino)
{
if (ino > 0)
free_unr(devfs_inos, ino);
}
static void
devfs_devs_init(void *junk __unused)
{

View File

@ -301,6 +301,9 @@ int devfs_set_cdevpriv(void *priv, cdevpriv_dtr_t dtr);
void devfs_clear_cdevpriv(void);
void devfs_fpdrop(struct file *fp); /* XXX This is not public KPI */
ino_t devfs_alloc_cdp_inode(void);
void devfs_free_cdp_inode(ino_t ino);
#define UID_ROOT 0
#define UID_BIN 3
#define UID_UUCP 66