* Copyright (c) 1991 Regents of the University of California.
* %sccs.include.redist.c%
* @(#)lfs_alloc.c 7.36 (Berkeley) %G%
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/lfs/lfs_extern.h>
extern u_long nextgennumber
;
/* Allocate a new inode. */
lfs_valloc(pvp
, notused
, cred
, vpp
)
/* Get the head of the freelist. */
if (new_ino
== LFS_UNUSED_INUM
) {
* Currently, no more inodes are allocated if the ifile fills
* up. The ifile should be extended instead.
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
);
printf("lfs_ialloc: allocate inode %d\n", new_ino
);
/* Read the appropriate block from the ifile. */
LFS_IENTRY(ifp
, fs
, new_ino
, bp
);
if (ifp
->if_daddr
!= LFS_UNUSED_DADDR
)
panic("lfs_ialloc: inuse inode on the free list");
/* Remove from the free list, set the access time, write it back. */
fs
->lfs_free
= ifp
->if_nextfree
;
ifp
->if_st_atime
= time
.tv_sec
;
/* Create a vnode to associate with the inode. */
if (error
= lfs_vcreate(pvp
->v_mount
, new_ino
, &vp
))
/* Set a new generation number for this inode. */
if (++nextgennumber
< (u_long
)time
.tv_sec
)
nextgennumber
= time
.tv_sec
;
ip
->i_gen
= nextgennumber
;
/* Insert into the inode hash table. */
/* Set superblock modified bit and increment file count. */
/* Create a new vnode/inode pair and initialize what fields we can. */
lfs_vcreate(mp
, ino
, vpp
)
extern struct vnodeops lfs_vnodeops
;
printf("lfs_vcreate: ino %d\n", ino
);
if (error
= getnewvnode(VT_LFS
, mp
, &lfs_vnodeops
, vpp
))
/* Get a pointer to the private mount structure. */
/* Initialize the inode. */
ip
->i_number
= ip
->i_din
.di_inum
= ino
;
ip
->i_devvp
= ump
->um_devvp
;
for (i
= 0; i
< MAXQUOTAS
; i
++)
ip
->i_dquot
[i
] = NODQUOT
;
lfs_vfree(vp
, notused1
, notused2
)
printf("lfs_vfree: free %d\n", ip
->i_number
);
/* Get the inode number and file system. */
* Read the appropriate block from the ifile. Set the inode entry to
* unused, increment its version number and link it into the free chain.
LFS_IENTRY(ifp
, fs
, ino
, bp
);
ifp
->if_daddr
= LFS_UNUSED_DADDR
;
ifp
->if_nextfree
= fs
->lfs_free
;
/* Set superblock modified bit and decrement file count. */