FreeBSD/sbin/fsck_ffs/dir.c
/*
 * make an entry in a directory
 */
make an entry in a directory
make an entry in a directory
int
makeentry(ino_t parent, ino_t ino, const char *name)
{
	union dinode *dp;
	struct inodesc idesc;
	char pathbuf[MAXPATHLEN + 1];
	if (parent < ROOTINO || parent >= maxino ||
	    ino < ROOTINO || ino >= maxino)
		return (0);
	memset(&idesc, 0, sizeof(struct inodesc));
	idesc.id_type = DATA;
	idesc.id_func = mkentry;
	idesc.id_number = parent;
	idesc.id_parent = ino;	
	idesc.id_fix = DONTKNOW;
	idesc.id_name = strdup(name);
	dp = ginode(parent);
	if (DIP(dp, di_size) % DIRBLKSIZ) {
		DIP_SET(dp, di_size, roundup(DIP(dp, di_size), DIRBLKSIZ));
		inodirty();
	}
	if ((ckinode(dp, &idesc) & ALTERED) != 0)
		return (1);
	getpathname(pathbuf, parent, parent);
	dp = ginode(parent);
	if (expanddir(dp, pathbuf) == 0)
		return (0);
	return (ckinode(dp, &idesc) & ALTERED);
}
int makeentry ( ino_t parent , ino_t ino , const char * name ) { union dinode * dp ; struct inodesc idesc ; char pathbuf [ MAXPATHLEN + 1 ] ; if ( parent < ROOTINO || parent >= maxino || ino < ROOTINO || ino >= maxino ) return ( 0 ) ; memset ( & idesc , 0 , sizeof ( struct inodesc ) ) ; idesc . id_type = DATA ; idesc . id_func = mkentry ; idesc . id_number = parent ; idesc . id_parent = ino ; idesc . id_fix = DONTKNOW ; idesc . id_name = strdup ( name ) ; dp = ginode ( parent ) ; if ( DIP ( dp , di_size ) % DIRBLKSIZ ) { DIP_SET ( dp , di_size , roundup ( DIP ( dp , di_size ) , DIRBLKSIZ ) ) ; inodirty ( ) ; } if ( ( ckinode ( dp , & idesc ) & ALTERED ) != 0 ) return ( 1 ) ; getpathname ( pathbuf , parent , parent ) ; dp = ginode ( parent ) ; if ( expanddir ( dp , pathbuf ) == 0 ) return ( 0 ) ; return ( ckinode ( dp , & idesc ) & ALTERED ) ; }
make an entry in a directory
make an entry in a directory
/* this is the inode to enter */