FreeBSD/sbin/quotacheck/quotacheck.c
/*
 * Add a new file usage id if it does not already exist.
 */
Add a new file usage id if it does not already exist.
Add a new file usage id if it does not already exist .
struct fileusage *
addid(u_long id, int type, char *name, const char *fsname)
{
	struct fileusage *fup, **fhp;
	int len;
	if ((fup = lookup(id, type)) != NULL)
		return (fup);
	if (name)
		len = strlen(name);
	else
		len = 0;
	if ((fup = calloc(1, sizeof(*fup) + len)) == NULL)
		errx(1, "calloc failed");
	fhp = &fuhead[type][id & (FUHASH - 1)];
	fup->fu_next = *fhp;
	*fhp = fup;
	fup->fu_id = id;
	if (name)
		bcopy(name, fup->fu_name, len + 1);
	else {
		(void)sprintf(fup->fu_name, "%lu", id);
		if (vflag) {
			if (aflag && fsname != NULL)
				(void)printf("%s: ", fsname);
			printf("unknown %cid: %lu\n",
			    type == USRQUOTA ? 'u' : 'g', id);
		}
	}
	return (fup);
}
struct fileusage * addid ( u_long id , int type , char * name , const char * fsname ) { struct fileusage * fup , * * fhp ; int len ; if ( ( fup = lookup ( id , type ) ) != NULL ) return ( fup ) ; if ( name ) len = strlen ( name ) ; else len = 0 ; if ( ( fup = calloc ( 1 , sizeof ( * fup ) + len ) ) == NULL ) errx ( 1 , " " ) ; fhp = & fuhead [ type ] [ id & ( FUHASH - 1 ) ] ; fup -> fu_next = * fhp ; * fhp = fup ; fup -> fu_id = id ; if ( name ) bcopy ( name , fup -> fu_name , len + 1 ) ; else { ( void ) sprintf ( fup -> fu_name , " " , id ) ; if ( vflag ) { if ( aflag && fsname != NULL ) ( void ) printf ( " " , fsname ) ; printf ( " \n " , type == USRQUOTA ? ' ' : ' ' , id ) ; } } return ( fup ) ; }
Add a new file usage id if it does not already exist.
Add a new file usage id if it does not already exist .