file.c File Reference

Implementation of the file operations. More...

#include "file.h"
#include "storage.h"
#include "mountdata.h"
#include <linux/list.h>
#include <linux/rwsem.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
Include dependency graph for file.c:

Go to the source code of this file.

Functions

int mumufs_file_open (struct inode *inode, struct file *file)
 File open operation.
int mumufs_file_release (struct inode *inode, struct file *file)
 File close operation.
ssize_t mumufs_file_read (struct file *file, char *buffer, size_t size, loff_t *offset)
 File read operation.
ssize_t mumufs_file_write (struct file *file, const char *buffer, size_t size, loff_t *offset)
 File write operation.
unsigned int mumufs_file_poll (struct file *file, struct poll_table_struct *poll_table)
 Checks whether there is activity on a file and goes to sleep until something happens on it.

Detailed Description

Implementation of the file operations.

Author:
Sergey Satskiy Copyright (C) 2007 - 2009 Sergey Satskiy.

This file is released under the GPL.

Definition in file file.c.


Function Documentation

int mumufs_file_open ( struct inode *  inode,
struct file *  file 
)

File open operation.

Parameters:
inode the opening file inode pointer
file the opening file kernel "file" structure pointer
Returns:
0 - success, otherwise the inverted errno value

Definition at line 29 of file file.c.

unsigned int mumufs_file_poll ( struct file *  file,
struct poll_table_struct *  poll_table 
)

Checks whether there is activity on a file and goes to sleep until something happens on it.

Parameters:
file the opened file kernel "file" structure pointer
poll_table supports kernel poll mechanism
Returns:
A bit mask describing the operations that could be immediately performed without blocking

Definition at line 235 of file file.c.

References mumufs_storage::blocked_readers, mumufs_storage::buffer_lock, and mumufs_storage::buffer_version.

ssize_t mumufs_file_read ( struct file *  file,
char *  buffer,
size_t  size,
loff_t *  offset 
)

File read operation.

Parameters:
file the opened file kernel "file" structure pointer
buffer Userspace reading buffer
size Userspace reading buffer size
offset File reading position. It must be 0, otherwise read fails.
Returns:
Positive: number of bytes read. Negative: inverted errno value

Blocking and non-blocking IO is supported

Definition at line 82 of file file.c.

References mumufs_storage::blocked_readers, mumufs_storage::buffer, mumufs_storage::buffer_lock, mumufs_storage::buffer_size, and mumufs_storage::buffer_version.

int mumufs_file_release ( struct inode *  inode,
struct file *  file 
)

File close operation.

Parameters:
inode the closing file inode pointer
file the closing file kernel "file" structure pointer
Returns:
0 - success, otherwise the inverted errno value

The storage for the file is freed at the inode putting so there is nothing to do here

Definition at line 55 of file file.c.

ssize_t mumufs_file_write ( struct file *  file,
const char *  buffer,
size_t  size,
loff_t *  offset 
)

File write operation.

Parameters:
file the opened file kernel "file" structure pointer
buffer Userspace writing buffer
size Userspace writing buffer size
offset File writing position. It must be 0, otherwise write fails.
Returns:
Positive: number of bytes written. Negative: inverted errno value

Definition at line 166 of file file.c.

References mumufs_storage::blocked_readers, mumufs_storage::buffer, mumufs_storage::buffer_lock, mumufs_storage::buffer_size, mumufs_storage::buffer_version, and mumu_mount_data::max_block_size.