devfs_devs.c (109526) | devfs_devs.c (109623) |
---|---|
1#define DEBUG 1 2/* 3 * Copyright (c) 2000 4 * Poul-Henning Kamp. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vfsops.c 1.36 28 * | 1#define DEBUG 1 2/* 3 * Copyright (c) 2000 4 * Poul-Henning Kamp. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vfsops.c 1.36 28 * |
29 * $FreeBSD: head/sys/fs/devfs/devfs_devs.c 109526 2003-01-19 11:03:07Z phk $ | 29 * $FreeBSD: head/sys/fs/devfs/devfs_devs.c 109623 2003-01-21 08:56:16Z alfred $ |
30 */ 31 32#include "opt_devfs.h" 33#include "opt_mac.h" 34#ifndef NODEVFS 35 36#include <sys/param.h> 37#include <sys/systm.h> --- 110 unchanged lines hidden (view full) --- 148 149 /* Check if somebody beat us to it */ 150 if (devfs_overflow != NULL) 151 return; 152 ot = NULL; 153 or = NULL; 154 n = devfs_noverflowwant; 155 nb = sizeof (dev_t *) * n; | 30 */ 31 32#include "opt_devfs.h" 33#include "opt_mac.h" 34#ifndef NODEVFS 35 36#include <sys/param.h> 37#include <sys/systm.h> --- 110 unchanged lines hidden (view full) --- 148 149 /* Check if somebody beat us to it */ 150 if (devfs_overflow != NULL) 151 return; 152 ot = NULL; 153 or = NULL; 154 n = devfs_noverflowwant; 155 nb = sizeof (dev_t *) * n; |
156 MALLOC(ot, dev_t **, nb, M_DEVFS, (insist ? M_WAITOK : M_NOWAIT) | M_ZERO); | 156 MALLOC(ot, dev_t **, nb, M_DEVFS, (insist ? 0 : M_NOWAIT) | M_ZERO); |
157 if (ot == NULL) 158 goto bail; 159 nb = sizeof (int) * n; | 157 if (ot == NULL) 158 goto bail; 159 nb = sizeof (int) * n; |
160 MALLOC(or, int *, nb, M_DEVFS, (insist ? M_WAITOK : M_NOWAIT) | M_ZERO); | 160 MALLOC(or, int *, nb, M_DEVFS, (insist ? 0 : M_NOWAIT) | M_ZERO); |
161 if (or == NULL) 162 goto bail; 163 if (!atomic_cmpset_ptr(&devfs_overflow, NULL, ot)) 164 goto bail; 165 devfs_refoverflow = or; 166 devfs_noverflow = n; 167 printf("DEVFS Overflow table with %d entries allocated when %d in use\n", n, devfs_numino); 168 return; --- 26 unchanged lines hidden (view full) --- 195devfs_newdirent(char *name, int namelen) 196{ 197 int i; 198 struct devfs_dirent *de; 199 struct dirent d; 200 201 d.d_namlen = namelen; 202 i = sizeof (*de) + GENERIC_DIRSIZ(&d); | 161 if (or == NULL) 162 goto bail; 163 if (!atomic_cmpset_ptr(&devfs_overflow, NULL, ot)) 164 goto bail; 165 devfs_refoverflow = or; 166 devfs_noverflow = n; 167 printf("DEVFS Overflow table with %d entries allocated when %d in use\n", n, devfs_numino); 168 return; --- 26 unchanged lines hidden (view full) --- 195devfs_newdirent(char *name, int namelen) 196{ 197 int i; 198 struct devfs_dirent *de; 199 struct dirent d; 200 201 d.d_namlen = namelen; 202 i = sizeof (*de) + GENERIC_DIRSIZ(&d); |
203 MALLOC(de, struct devfs_dirent *, i, M_DEVFS, M_WAITOK | M_ZERO); | 203 MALLOC(de, struct devfs_dirent *, i, M_DEVFS, M_ZERO); |
204 de->de_dirent = (struct dirent *)(de + 1); 205 de->de_dirent->d_namlen = namelen; 206 de->de_dirent->d_reclen = GENERIC_DIRSIZ(&d); 207 bcopy(name, de->de_dirent->d_name, namelen); 208 de->de_dirent->d_name[namelen] = '\0'; 209 vfs_timestamp(&de->de_ctime); 210 de->de_mtime = de->de_atime = de->de_ctime; 211 de->de_links = 1; --- 78 unchanged lines hidden (view full) --- 290 char *q, *s; 291 292 if (dm->dm_generation == devfs_generation) 293 return (0); 294 lockmgr(&dm->dm_lock, LK_UPGRADE, 0, curthread); 295 if (devfs_noverflow && dm->dm_overflow == NULL) { 296 i = devfs_noverflow * sizeof (struct devfs_dirent *); 297 MALLOC(dm->dm_overflow, struct devfs_dirent **, i, | 204 de->de_dirent = (struct dirent *)(de + 1); 205 de->de_dirent->d_namlen = namelen; 206 de->de_dirent->d_reclen = GENERIC_DIRSIZ(&d); 207 bcopy(name, de->de_dirent->d_name, namelen); 208 de->de_dirent->d_name[namelen] = '\0'; 209 vfs_timestamp(&de->de_ctime); 210 de->de_mtime = de->de_atime = de->de_ctime; 211 de->de_links = 1; --- 78 unchanged lines hidden (view full) --- 290 char *q, *s; 291 292 if (dm->dm_generation == devfs_generation) 293 return (0); 294 lockmgr(&dm->dm_lock, LK_UPGRADE, 0, curthread); 295 if (devfs_noverflow && dm->dm_overflow == NULL) { 296 i = devfs_noverflow * sizeof (struct devfs_dirent *); 297 MALLOC(dm->dm_overflow, struct devfs_dirent **, i, |
298 M_DEVFS, M_WAITOK | M_ZERO); | 298 M_DEVFS, M_ZERO); |
299 } 300 while (dm->dm_generation != devfs_generation) { 301 dm->dm_generation = devfs_generation; 302 for (i = 0; i <= devfs_topino; i++) { 303 dev = *devfs_itod(i); 304 dep = devfs_itode(dm, i); 305 de = *dep; 306 if (dev == NULL && de == DE_DELETED) { --- 41 unchanged lines hidden (view full) --- 348 if (dev->si_flags & SI_ALIAS) { 349 de->de_inode = dm->dm_inode++; 350 de->de_uid = 0; 351 de->de_gid = 0; 352 de->de_mode = 0755; 353 de->de_dirent->d_type = DT_LNK; 354 pdev = dev->si_parent; 355 j = strlen(pdev->si_name) + 1; | 299 } 300 while (dm->dm_generation != devfs_generation) { 301 dm->dm_generation = devfs_generation; 302 for (i = 0; i <= devfs_topino; i++) { 303 dev = *devfs_itod(i); 304 dep = devfs_itode(dm, i); 305 de = *dep; 306 if (dev == NULL && de == DE_DELETED) { --- 41 unchanged lines hidden (view full) --- 348 if (dev->si_flags & SI_ALIAS) { 349 de->de_inode = dm->dm_inode++; 350 de->de_uid = 0; 351 de->de_gid = 0; 352 de->de_mode = 0755; 353 de->de_dirent->d_type = DT_LNK; 354 pdev = dev->si_parent; 355 j = strlen(pdev->si_name) + 1; |
356 MALLOC(de->de_symlink, char *, j, M_DEVFS, M_WAITOK); | 356 MALLOC(de->de_symlink, char *, j, M_DEVFS, 0); |
357 bcopy(pdev->si_name, de->de_symlink, j); 358 } else { 359 de->de_inode = i; 360 de->de_uid = dev->si_uid; 361 de->de_gid = dev->si_gid; 362 de->de_mode = dev->si_mode; 363 de->de_dirent->d_type = DT_CHR; 364 } --- 94 unchanged lines hidden --- | 357 bcopy(pdev->si_name, de->de_symlink, j); 358 } else { 359 de->de_inode = i; 360 de->de_uid = dev->si_uid; 361 de->de_gid = dev->si_gid; 362 de->de_mode = dev->si_mode; 363 de->de_dirent->d_type = DT_CHR; 364 } --- 94 unchanged lines hidden --- |