FreeBSD/sys/kern/subr_devstat.c
/*
 * Allocate a devstat and initialize it
 */
Allocate a devstat and initialize it
Allocate a devstat and initialize it
struct devstat *
devstat_new_entry(const void *dev_name,
		  int unit_number, uint32_t block_size,
		  devstat_support_flags flags,
		  devstat_type_flags device_type,
		  devstat_priority priority)
{
	struct devstat *ds;
	mtx_assert(&devstat_mutex, MA_NOTOWNED);
	ds = devstat_alloc();
	mtx_lock(&devstat_mutex);
	if (unit_number == -1) {
		ds->unit_number = unit_number;
		ds->id = dev_name;
		binuptime(&ds->creation_time);
		devstat_generation++;
	} else {
		devstat_add_entry(ds, dev_name, unit_number, block_size,
				  flags, device_type, priority);
	}
	mtx_unlock(&devstat_mutex);
	return (ds);
}
struct devstat * devstat_new_entry ( const void * dev_name , int unit_number , uint32_t block_size , devstat_support_flags flags , devstat_type_flags device_type , devstat_priority priority ) { struct devstat * ds ; mtx_assert ( & devstat_mutex , MA_NOTOWNED ) ; ds = devstat_alloc ( ) ; mtx_lock ( & devstat_mutex ) ; if ( unit_number == -1 ) { ds -> unit_number = unit_number ; ds -> id = dev_name ; binuptime ( & ds -> creation_time ) ; devstat_generation ++ ; } else { devstat_add_entry ( ds , dev_name , unit_number , block_size , flags , device_type , priority ) ; } mtx_unlock ( & devstat_mutex ) ; return ( ds ) ; }
Allocate a devstat and initialize it
Allocate a devstat and initialize it