Deleted Added
full compact
devfs_devs.c (224743) devfs_devs.c (226041)
1/*-
2 * Copyright (c) 2000,2004
3 * Poul-Henning Kamp. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vfsops.c 1.36
27 *
1/*-
2 * Copyright (c) 2000,2004
3 * Poul-Henning Kamp. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vfsops.c 1.36
27 *
28 * $FreeBSD: head/sys/fs/devfs/devfs_devs.c 224743 2011-08-09 20:53:33Z kib $
28 * $FreeBSD: head/sys/fs/devfs/devfs_devs.c 226041 2011-10-05 16:50:15Z kib $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/conf.h>
34#include <sys/dirent.h>
35#include <sys/kernel.h>
36#include <sys/limits.h>

--- 129 unchanged lines hidden (view full) ---

166void
167devfs_free(struct cdev *cdev)
168{
169 struct cdev_priv *cdp;
170
171 cdp = cdev2priv(cdev);
172 if (cdev->si_cred != NULL)
173 crfree(cdev->si_cred);
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/conf.h>
34#include <sys/dirent.h>
35#include <sys/kernel.h>
36#include <sys/limits.h>

--- 129 unchanged lines hidden (view full) ---

166void
167devfs_free(struct cdev *cdev)
168{
169 struct cdev_priv *cdp;
170
171 cdp = cdev2priv(cdev);
172 if (cdev->si_cred != NULL)
173 crfree(cdev->si_cred);
174 if (cdp->cdp_inode > 0)
175 free_unr(devfs_inos, cdp->cdp_inode);
174 devfs_free_cdp_inode(cdp->cdp_inode);
176 if (cdp->cdp_maxdirent > 0)
177 free(cdp->cdp_dirents, M_DEVFS2);
178 free(cdp, M_CDEVP);
179}
180
181struct devfs_dirent *
182devfs_find(struct devfs_dirent *dd, const char *name, int namelen, int type)
183{

--- 205 unchanged lines hidden (view full) ---

389 if (de->de_symlink) {
390 free(de->de_symlink, M_DEVFS);
391 de->de_symlink = NULL;
392 }
393#ifdef MAC
394 mac_devfs_destroy(de);
395#endif
396 if (de->de_inode > DEVFS_ROOTINO) {
175 if (cdp->cdp_maxdirent > 0)
176 free(cdp->cdp_dirents, M_DEVFS2);
177 free(cdp, M_CDEVP);
178}
179
180struct devfs_dirent *
181devfs_find(struct devfs_dirent *dd, const char *name, int namelen, int type)
182{

--- 205 unchanged lines hidden (view full) ---

388 if (de->de_symlink) {
389 free(de->de_symlink, M_DEVFS);
390 de->de_symlink = NULL;
391 }
392#ifdef MAC
393 mac_devfs_destroy(de);
394#endif
395 if (de->de_inode > DEVFS_ROOTINO) {
397 free_unr(devfs_inos, de->de_inode);
396 devfs_free_cdp_inode(de->de_inode);
398 de->de_inode = 0;
399 }
400 if (DEVFS_DE_DROP(de))
401 devfs_dirent_free(de);
402
403 if (dd != NULL) {
404 if (DEVFS_DE_DROP(dd))
405 devfs_dirent_free(dd);

--- 274 unchanged lines hidden (view full) ---

680 struct cdev_priv *cdp;
681
682 mtx_assert(&devmtx, MA_OWNED);
683 cdp = cdev2priv(dev);
684 cdp->cdp_flags &= ~CDP_ACTIVE;
685 devfs_generation++;
686}
687
397 de->de_inode = 0;
398 }
399 if (DEVFS_DE_DROP(de))
400 devfs_dirent_free(de);
401
402 if (dd != NULL) {
403 if (DEVFS_DE_DROP(dd))
404 devfs_dirent_free(dd);

--- 274 unchanged lines hidden (view full) ---

679 struct cdev_priv *cdp;
680
681 mtx_assert(&devmtx, MA_OWNED);
682 cdp = cdev2priv(dev);
683 cdp->cdp_flags &= ~CDP_ACTIVE;
684 devfs_generation++;
685}
686
687ino_t
688devfs_alloc_cdp_inode(void)
689{
690
691 return (alloc_unr(devfs_inos));
692}
693
694void
695devfs_free_cdp_inode(ino_t ino)
696{
697
698 if (ino > 0)
699 free_unr(devfs_inos, ino);
700}
701
688static void
689devfs_devs_init(void *junk __unused)
690{
691
692 devfs_inos = new_unrhdr(DEVFS_ROOTINO + 1, INT_MAX, &devmtx);
693}
694
695SYSINIT(devfs_devs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_devs_init, NULL);
702static void
703devfs_devs_init(void *junk __unused)
704{
705
706 devfs_inos = new_unrhdr(DEVFS_ROOTINO + 1, INT_MAX, &devmtx);
707}
708
709SYSINIT(devfs_devs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_devs_init, NULL);