BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / blob / e59e4fe0bbf5a3f56db0700ee49a81131b590f9c / vfs / super.c

// Related

Orion

Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)
/*
 * This file contains the wrapper functions for the Super Block Operations.  It
 * just calls the relevant internal functions for the file system, since most of
 * them need to know driver specific values, like where to find the file system
 * operations.  There usually isn't a generic way to handle the functions.
 */

#include <stdint.h>
#include "vfs.h"

/* Allocate an inode */
Inode *
super_alloc_inode(SuperBlock *sb)
{
	if (!sb->ops)
		return NULL;
	if (!sb->ops->alloc_inode)
		return NULL;
	return sb->ops->alloc_inode(sb);
}

/* Search for an Inode in a Super Block's Inode list */
Inode *
super_find_inode(SuperBlock *sb, ino_t ino)
{
	Inode *inode;
	for (inode = sb->inodes; inode; inode = inode->lnext)
		if (inode->ino == ino)
			break;
	return inode;
}

/* Write an inode to disk */
int
super_write_inode(SuperBlock *sb, Inode *inode)
{
	if (!sb->ops)
		return 0;
	if (!sb->ops->write_inode)
		return 0;
	return sb->ops->write_inode(inode);
}