Ejemplo n.º 1
0
// reiserfs_access
static status_t
reiserfs_access(fs_volume *fs, fs_vnode *_node, int mode)
{
	TOUCH(fs);
//	FUNCTION_START();
//	Volume *volume = (Volume*)fs->private_volume;
	VNode *node = (VNode*)_node->private_node;
FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(),
		  node->GetObjectID()));
	// write access requested?
	if (mode & W_OK)
		return B_READ_ONLY_DEVICE;
	// get node permissions
	StatData *statData = node->GetStatData();
	int userPermissions = (statData->GetMode() & S_IRWXU) >> 6;
	int groupPermissions = (statData->GetMode() & S_IRWXG) >> 3;
	int otherPermissions = statData->GetMode() & S_IRWXO;
	// get the permissions for this uid/gid
	int permissions = 0;
	uid_t uid = geteuid();
	// user is root
	if (uid == 0) {
		// root has always read/write permission, but at least one of the
		// X bits must be set for execute permission
		permissions = userPermissions | groupPermissions | otherPermissions
			| S_IROTH | S_IWOTH;
	// user is node owner
	} else if (uid == statData->GetUID())
		permissions = userPermissions;
	// user is in owning group
	else if (is_user_in_group(statData->GetGID()))
		permissions = groupPermissions;
	// user is one of the others
	else
		permissions = otherPermissions;
	// do the check
	if (mode & ~permissions)
		return B_NOT_ALLOWED;
	return B_OK;
}
Ejemplo n.º 2
0
// reiserfs_read_stat
static status_t
reiserfs_read_stat(fs_volume *fs, fs_vnode *_node, struct stat *st)
{
//	FUNCTION_START();
	Volume *volume = (Volume*)fs->private_volume;
	VNode *node = (VNode*)_node->private_node;
FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(),
		  node->GetObjectID()));
	status_t error = B_OK;
	StatData *statData = node->GetStatData();
	st->st_dev = volume->GetID();
	st->st_ino = node->GetID();
	st->st_mode = statData->GetMode();
	st->st_nlink = statData->GetNLink();
	st->st_uid = statData->GetUID();
	st->st_gid = statData->GetGID();
	st->st_size = statData->GetSize();
	st->st_blksize = kOptimalIOSize;
	st->st_atime = statData->GetATime();
	st->st_mtime = st->st_ctime = statData->GetMTime();
	st->st_crtime = statData->GetCTime();
	RETURN_ERROR(error);
}
Ejemplo n.º 3
0
// reiserfs_read_vnode
static status_t
reiserfs_read_vnode(fs_volume *fs, ino_t vnid, fs_vnode *node, int *_type,
	uint32 *_flags, bool reenter)
{
	TOUCH(reenter);
//	FUNCTION_START();
	FUNCTION(("(%Ld: %lu, %ld)\n", vnid, VNode::GetDirIDFor(vnid),
			  VNode::GetObjectIDFor(vnid)));
	Volume *volume = (Volume*)fs->private_volume;
	status_t error = B_OK;
	VNode *foundNode = new(nothrow) VNode;
	if (foundNode) {
		error = volume->FindVNode(vnid, foundNode);
		if (error == B_OK) {
			node->private_node = foundNode;
			node->ops = &gReiserFSVnodeOps;
			*_type = foundNode->GetStatData()->GetMode() & S_IFMT;
			*_flags = 0;
		} else
			delete foundNode;
	} else
		error = B_NO_MEMORY;
	RETURN_ERROR(error);
}