BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / blob / master / vfs / tmpfs / super.c

// Related

Nucleus

Barry SuperBlock Inode list fdbcccf (3 years, 3 months ago)
#include <sys/stat.h>
#include <nucleus/vfs.h>

extern InodeOps tmpfsInodeOps;
extern FileOps tmpfsFileOps;

Inode *tmpfs_alloc_inode(SuperBlock *sb);

SuperOps tmpfsSuperOps = {
	.alloc_inode = tmpfs_alloc_inode,
};

/* Mount a tmpfs instance */
Inode *
tmpfs_mount(FSType *type, int flags, const char *dev, void *data)
{
	SuperBlock *super = new(&superBlockType);

	super->type = get(type);
	super->ops = &tmpfsSuperOps;

	Inode *inode = super_alloc_inode(super);
	inode->mode = S_IFDIR | 0755;
	super->root = inode;

	return inode;
}

/* Allocate an inode */
Inode *
tmpfs_alloc_inode(SuperBlock *sb)
{
	Inode *inode = new(&inodeType);
	inode->ops = &tmpfsInodeOps;
	inode->fileOps = &tmpfsFileOps;
	inode->nlink = 1;
	return inode;
}