MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mqfs_fileno_alloc

Function mqfs_fileno_alloc

freebsd/kern/uipc_mqueue.c:318–354  ·  view source on GitHub ↗

* Allocate a file number */

Source from the content-addressed store, hash-verified

316 * Allocate a file number
317 */
318static void
319mqfs_fileno_alloc(struct mqfs_info *mi, struct mqfs_node *mn)
320{
321 /* make sure our parent has a file number */
322 if (mn->mn_parent && !mn->mn_parent->mn_fileno)
323 mqfs_fileno_alloc(mi, mn->mn_parent);
324
325 switch (mn->mn_type) {
326 case mqfstype_root:
327 case mqfstype_dir:
328 case mqfstype_file:
329 case mqfstype_symlink:
330 mn->mn_fileno = alloc_unr(mi->mi_unrhdr);
331 break;
332 case mqfstype_this:
333 KASSERT(mn->mn_parent != NULL,
334 ("mqfstype_this node has no parent"));
335 mn->mn_fileno = mn->mn_parent->mn_fileno;
336 break;
337 case mqfstype_parent:
338 KASSERT(mn->mn_parent != NULL,
339 ("mqfstype_parent node has no parent"));
340 if (mn->mn_parent == mi->mi_root) {
341 mn->mn_fileno = mn->mn_parent->mn_fileno;
342 break;
343 }
344 KASSERT(mn->mn_parent->mn_parent != NULL,
345 ("mqfstype_parent node has no grandparent"));
346 mn->mn_fileno = mn->mn_parent->mn_parent->mn_fileno;
347 break;
348 default:
349 KASSERT(0,
350 ("mqfs_fileno_alloc() called for unknown type node: %d",
351 mn->mn_type));
352 break;
353 }
354}
355
356/*
357 * Release a file number

Callers 2

mqfs_initFunction · 0.85
mqfs_readdirFunction · 0.85

Calls 1

alloc_unrFunction · 0.85

Tested by

no test coverage detected