* Copyright (c) 1982, 1986, 1989 Regents of the University of California.
* %sccs.include.redist.c%
* @(#)lfs_alloc.c 7.29 (Berkeley) %G%
#include "../ufs/quota.h"
#include "../ufs/inode.h"
#include "../ufs/ufsmount.h"
#define LFS_IENTRY(I, F, IN, BP) \
if (bread((F)->lfs_ivnode, (IN) / IFPB(F) + (F)->lfs_segtabsz, \
(F)->lfs_bsize, NOCRED, &BP)) \
(I) = (IFILE *)BP->b_un.b_addr + IN % IFPB(F);
lfs_ialloc(fs
, pip
, ipp
, cred
)
printf("lfs_ialloc: next free %d\n", new_ino
);
if (new_ino
== LFS_UNUSED_INUM
) { /* XXX -- allocate more */
uprintf("\n%s: no inodes left\n", fs
->lfs_fsmnt
);
log(LOG_ERR
, "uid %d on %s: out of inodes\n",
cred
->cr_uid
, fs
->lfs_fsmnt
);
/* Read the appropriate block from the ifile */
LFS_IENTRY(ifp
, fs
, new_ino
, bp
);
if (ifp
->if_daddr
!= LFS_UNUSED_DADDR
)
panic("lfs_ialloc: corrupt free list");
/* Remove from free list, set the access time. */
fs
->lfs_free
= ifp
->if_nextfree
;
ifp
->if_st_atime
= time
.tv_sec
;
error
= lfs_vcreate(ITOV(pip
)->v_mount
, new_ino
, &vp
);
* Set up a new generation number for this inode.
if (++nextgennumber
< (u_long
)time
.tv_sec
)
nextgennumber
= time
.tv_sec
;
ip
->i_gen
= nextgennumber
;
printf("lfs_ifree: free %d\n", ip
->i_number
);
LFS_IENTRY(ifp
, fs
, ino
, bp
);
ifp
->if_daddr
= LFS_UNUSED_DADDR
;
ifp
->if_nextfree
= fs
->lfs_free
;
printf("itod: ino %d\n", ino
);
LFS_IENTRY(ifp
, fs
, ino
, bp
);
if (ifp
->if_daddr
== LFS_UNUSED_DADDR
)
panic("itod: unused daddr");
printf("lfs_ifind: inode %d\n", ino
);
for (cnt
= INOPB(fs
); cnt
--; ++dip
)
(void)printf("lfs_ifind: dinode %u not found", ino
);
panic("lfs_ifind: inode not found");
* Create a new vnode/inode and initialize the fields we can.
lfs_vcreate(mp
, ino
, vpp
)
printf("lfs_vcreate: ino %d\n", ino
);
error
= getnewvnode(VT_LFS
, mp
, &lfs_vnodeops
, vpp
);
/* Initialize the inode. */
ip
->i_devvp
= ump
->um_devvp
;
ip
->i_number
= ip
->i_din
.di_inum
= ino
;
for (i
= 0; i
< MAXQUOTAS
; i
++)
ip
->i_dquot
[i
] = NODQUOT
;
* Return the current version number for a specific inode.
printf("lfs_getversion: %d\n", ino
);
LFS_IENTRY(ifp
, fs
, ino
, bp
);
version
= ifp
->if_version
;