Header file
[MySQL FS Kernel Module]


declaration of structures used by VFS

super_operations rkfs_sops
inode_operations rkfs_iops
file_operations rkfs_fops
file_operations rkfs_dops
file_system_type rkfs
address_space_operations rkfs_aops

different variables use by MySQLFS

int result
struct_command ret_command
char out_buf [OUT_BUF_LENGTH]
int query (const char *command, int command_lenght)
 Function to send message to deamon.
void rkfs_deamon_test (void)
 Function for testing deamon.

declaration of functions defines in fs_inode.c

See also:
fs_inode.c


int rkfs_get_sb (struct file_system_type *fs_type, int flags, const char *devname, void *data, struct vfsmount *mnt)
 Function to get super block.
void rkfs_kill_sb (struct super_block *)
 Kill super block.
void rkfs_super_read_inode (struct inode *inode)
 Super read inode.
int rkfs_super_write_inode (struct inode *inode, int sync)
 Super write inode.
void rkfs_super_delete_inode (struct inode *)
 Delete inode.
dentry * rkfs_inode_lookup (struct inode *parent_inode, struct dentry *dentry, struct nameidata *)
 Inode lookup.
int rkfs_inode_create (struct inode *, struct dentry *, int mode, struct nameidata *)
 Inode create.
void rkfs_inode_truncate (struct inode *inode)
 Truncate inode.
int rkfs_inode_unlink (struct inode *, struct dentry *)
 Inode unlink.
int rkfs_inode_rename (struct inode *, struct dentry *, struct inode *, struct dentry *)
 Remame.

declaration of functions defines in fs_file.c

See also:
fs_file.c


int rkfs_file_open (struct inode *, struct file *)
 Function for open file.
int rkfs_file_readdir (struct file *file, void *dirent, filldir_t filldir)
 Read dir.
int rkfs_file_release (struct inode *, struct file *)
 Function for release file.
ssize_t rkfs_file_read (struct file *, char __user *, size_t, loff_t *)
 Function for read from file.
ssize_t rkfs_file_write (struct file *, const char __user *, size_t, loff_t *)
 Function for write to file.
loff_t rkfs_file_llseek (struct file *, loff_t, int)
 Lseek.

declaration of functions defines in fs_dir.c

See also:
fs_dir.c


int rkfs_mkdir (struct inode *, struct dentry *, int)
 Function for make new directory.
int rkfs_rmdir (struct inode *, struct dentry *)
 Function for remove directory.

declaration of functions defines in fs_lib.c

See also:
fs_lib.c


int rkfs_next_data_item (char **, char *)
 Read next data item from a answer received from a deamon.
int rkfs_atoi (char *)
 Atoi function.

File system constants

#define RKFS_MAGIC   0xabcd
#define RKFS_NAME   "rkfs"
#define RKFS_BLOCKSIZE   4096
#define RKFS_BLOCKSIZE_BITS   10
#define RKFS_DIRECTORY_BASE   10000
#define RKFS_ROOT_INODE   RKFS_DIRECTORY_BASE + 1

Macros to help debugging

#define FSPDEBUG(fmt, args...)   fprintf(stderr, fmt, ## args)
#define FSPINFO(fmt, args...)   fprintf(stdout, fmt, ## args)
#define FSPRETCMD()   fprintf (stderr, "RKFS: ret_command=(ver:'%s', cmd:'%s', prm:'%s', dta:'%s')\n", ret_command.version, ret_command.command, ret_command.param, ret_command.data)

Defines

#define RKFS_DEF_QUERY_OK   0
#define RKFS_DEF_QUERY_ERROR   -1
#define FILE_INODE_NUMBER   2
#define OUT_BUF_LENGTH   MAX_BUFFER_LENGTH
#define FS_DEBUG

Define Documentation

#define FILE_INODE_NUMBER   2

RKFS file inode number - delete it

Definition at line 45 of file rkfs.h.

#define FS_DEBUG

If defined, debugging prints will be visible.

Definition at line 52 of file rkfs.h.

#define OUT_BUF_LENGTH   MAX_BUFFER_LENGTH

length of output buffer, its same as buffer length

Definition at line 48 of file rkfs.h.

Referenced by query().

#define RKFS_DEF_QUERY_ERROR   -1

query return constant ERROR

Definition at line 41 of file rkfs.h.

Referenced by query().

#define RKFS_DEF_QUERY_OK   0

query return constant OK

Definition at line 39 of file rkfs.h.

Referenced by query(), rkfs_file_read(), rkfs_file_write(), rkfs_inode_create(), rkfs_inode_lookup(), rkfs_inode_rename(), rkfs_inode_truncate(), rkfs_inode_unlink(), rkfs_mkdir(), rkfs_rmdir(), and rkfs_super_read_inode().

#define RKFS_DIRECTORY_BASE   10000

base for directory ids The inode id's space is divided into two parts. The lower one from 1 to RKFS_DIRECTORY_BASE is used for directory inode numbers, the upper one from RKFS_DIRECTORY_BASE + 1 to max(unsigned long int) for file inode numbers.

Definition at line 33 of file rkfs.h.


Function Documentation

int query ( const char *  command,
int  command_length 
)

Function to send message to deamon.

Send message to deamon, accept answer message and parse it.

Parameters:
command command to be executed by deamon
command_length length of command without trailing zero
Returns:
RKFS_DEF_QUERY_OK on success or RKFS_DEF_QUERY_ERROR. on fail
Filesystem uses this function to send a comand (
See also:
doc/protokol/protokol.txt). When command is send, deamon sleep on this call of this function. When kernel return from this function, the result of the command is in buffer and can be parsed and used.

Definition at line 185 of file fs_main.c.

References fsc_query(), FSPDEBUG, out_buf, OUT_BUF_LENGTH, parse_message(), result, ret_command, RKFS_DEF_QUERY_ERROR, and RKFS_DEF_QUERY_OK.

Referenced by fsd_add_block(), fsd_clear_file(), fsd_create(), fsd_dir_exists(), fsd_dir_info(), fsd_dir_name_exists(), fsd_file_exists(), fsd_file_info(), fsd_file_name_exists(), fsd_get_block(), fsd_lookup(), fsd_mkdir(), fsd_move_file(), fsd_read_dir(), fsd_read_inode(), fsd_remove_dir(), fsd_remove_file(), fsd_rename_dir(), fsd_rename_file(), fsd_replace_block(), fsd_truncate_file(), rkfs_deamon_test(), rkfs_file_read(), rkfs_file_readdir(), rkfs_file_write(), rkfs_inode_create(), rkfs_inode_lookup(), rkfs_inode_rename(), rkfs_inode_truncate(), rkfs_inode_unlink(), rkfs_mkdir(), rkfs_rmdir(), and rkfs_super_read_inode().

int rkfs_atoi ( char *  str  ) 

Atoi function.

Converts string to Integer.

Parameters:
str string to be converted.
Returns:
Integer converted from str.
It has litle bit other behaviour, than usual atoi. It doesn't check any errors. When something not a number represintig char is in string, it's like it would be '0' instead.

Definition at line 307 of file fs_main.c.

References result.

Referenced by rkfs_file_readdir(), rkfs_inode_create(), rkfs_inode_lookup(), rkfs_inode_rename(), rkfs_mkdir(), and rkfs_super_read_inode().

void rkfs_deamon_test ( void   ) 

Function for testing deamon.

Send various messages to deamon. Function is used only for testing. This time is not used at any place in the project, but we still leave it here, it can be used in future when we make some changes in deamon. This function is only for debugging purposis.

Definition at line 214 of file fs_main.c.

References query().

loff_t rkfs_file_llseek ( struct file *  file,
loff_t  offset,
int  origin 
)

Lseek.

Impelementation of lseek handler of VFS call ...

Parameters:
file Pointer to a file structure representing file to be read from.
offset Where to seek.
origin Start point of seek call.
Returns:
return Value of generic lseek operation.

1 OK.

Definition at line 417 of file fs_file.c.

References FSPDEBUG.

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

Function for open file.

Open file ...

Parameters:
inode. 
file. 
Returns:
Return value of function generic_file_open.

Definition at line 309 of file fs_file.c.

References FSPDEBUG.

ssize_t rkfs_file_read ( struct file *  filp,
char __user *  buf,
size_t  count,
loff_t *  ppos 
)

Function for read from file.

Read up to count bytes from file represented by file structure pointed by filp.

Parameters:
filp Pointer to a file structure to be readen from.
buf Whereto place readen data.
count Maximum amount of readen bytes.
ppos Position in file.
Returns:
number realy readen bytes.

Definition at line 65 of file fs_file.c.

References CMD_ER_NR, struct_command::command_nr, struct_command::data, FSPDEBUG, MAX_QUERY_LENGTH, query(), ret_command, RKFS_BLOCKSIZE, and RKFS_DEF_QUERY_OK.

int rkfs_file_readdir ( struct file *  file,
void *  dirent,
filldir_t  filldir 
)

Read dir.

Impelementation of readdir handler of VFS call ...

Parameters:
file Pointer to a file structure epresenting directory to read.
dirent Dirent to filled.
filldir pointer to a Function for filling a dirent.
Returns:
0 on error.

1 OK.

Definition at line 348 of file fs_file.c.

References CMD_OK_NR, struct_command::command_nr, struct_command::data, FSPDEBUG, MAX_ID_LENGTH, MAX_NAME_LENGTH, MAX_QUERY_LENGTH, struct_command::param, query(), ret_command, rkfs_atoi(), and rkfs_next_data_item().

int rkfs_file_release ( struct inode *  ino,
struct file *  file 
)

Function for release file.

Release file, used by CFS call release file ...

Parameters:
ino Inode representing a file to be released. Omitted.
file File structure representing a file to be released. Omitted.
Returns:
always 0

Definition at line 329 of file fs_file.c.

References FSPDEBUG.

ssize_t rkfs_file_write ( struct file *  filp,
const char __user *  buf,
size_t  count,
loff_t *  ppos 
)

Function for write to file.

Write up to count bytes from buf to file repesente by file structure poited by filp.

Parameters:
filp Pointer to a to file structure.
buf Buffer for incoming data.
count Maximum amount of bytes to written to the file.
ppos Position in the file.
Returns:
Number realy readen bytes.

Definition at line 147 of file fs_file.c.

References CMD_ER_NR, struct_command::command_nr, struct_command::data, FSPDEBUG, MAX_QUERY_LENGTH, struct_command::param, query(), ret_command, RKFS_BLOCKSIZE, RKFS_DEF_QUERY_OK, and rkfs_inode_truncate().

int rkfs_get_sb ( struct file_system_type *  fs_type,
int  flags,
const char *  devname,
void *  data,
struct vfsmount *  mnt 
)

Function to get super block.

Get super block

Parameters:
fs_type Type of fs to ne mounted.
flags Flags.
devname Name of device to be mounted.
data Ignored.
mnt 
Returns:
Result of function get_sb_single.

Definition at line 165 of file fs_inode.c.

References FSPDEBUG, and result.

int rkfs_inode_create ( struct inode *  dir,
struct dentry *  dirdentry,
int  mode,
struct nameidata *  nd 
)

Inode create.

Creates an inode.

Parameters:
dir Where to create an inode.
dirdentry Information about newly created item.
mode Mode of inode.
nd Ignored.
Returns:
PTR_ERR(inode) on error, 0on success.

Definition at line 400 of file fs_inode.c.

References CMD_ER_NR, struct_command::command_nr, FSPDEBUG, MAX_QUERY_LENGTH, struct_command::param, query(), ret_command, rkfs_atoi(), RKFS_DEF_QUERY_OK, rkfs_fops, and rkfs_iops.

struct dentry* rkfs_inode_lookup ( struct inode *  parent_inode,
struct dentry *  dentry,
struct nameidata *  nameidata 
)

Inode lookup.

Inode lookup.

Parameters:
parent_inode Inode of parent Inode, where we try to find entry.
dentry Dentry to look for.
nameidata Ignored.
Returns:
NULL on success, or ERR_PTR(-EACCES) on fail.

Error.

Definition at line 350 of file fs_inode.c.

References CMD_ER_NR, struct_command::command_nr, struct_command::data, FSPDEBUG, MAX_ID_LENGTH, MAX_QUERY_LENGTH, query(), ret_command, rkfs_atoi(), RKFS_DEF_QUERY_OK, and rkfs_next_data_item().

int rkfs_inode_rename ( struct inode *  old_dir,
struct dentry *  old_dentry,
struct inode *  new_dir,
struct dentry *  new_dentry 
)

Remame.

Remanes directory.

Parameters:
old_dir Old directory, where the renamed file is placed.
old_dentry Name of item to be renamed.
new_dir Inode to truncated.
new_dentry Inode to truncated.
Returns:

Definition at line 537 of file fs_inode.c.

References CMD_ER_NR, struct_command::command_nr, struct_command::data, FSPDEBUG, MAX_QUERY_LENGTH, MAX_SIZE_LENGTH, struct_command::param, query(), ret_command, rkfs_atoi(), RKFS_DEF_QUERY_OK, and rkfs_next_data_item().

void rkfs_inode_truncate ( struct inode *  inode  ) 

Truncate inode.

Truncates an inode.

Parameters:
inode Inode to truncated.
Returns:
PTR_ERR(inode) on error, 0 on success.

Definition at line 486 of file fs_inode.c.

References CMD_ER_NR, struct_command::command_nr, FSPDEBUG, MAX_QUERY_LENGTH, query(), ret_command, and RKFS_DEF_QUERY_OK.

Referenced by rkfs_file_write().

int rkfs_inode_unlink ( struct inode *  dir,
struct dentry *  dentry 
)

Inode unlink.

Unlink the inode. Superblock operation.

Parameters:
dir Where to find unlinked file.
dentry Directory entry to be unlinked.
Returns:
-EACCES on access denied, -EFAULT on general error, 0 on success .

Definition at line 298 of file fs_inode.c.

References CMD_ER_NR, struct_command::command_nr, FSPDEBUG, MAX_QUERY_LENGTH, query(), ret_command, and RKFS_DEF_QUERY_OK.

void rkfs_kill_sb ( struct super_block *  super  ) 

Kill super block.

Kill super the superblock.

Parameters:
super Super block to be killed.

Definition at line 194 of file fs_inode.c.

References FSPDEBUG.

int rkfs_mkdir ( struct inode *  dir,
struct dentry *  dentry,
int  mode 
)

Function for make new directory.

Create new directory in parent directory specified by dir parametr

Parameters:
dir Directory, where new dir should be created.
dentry Dentry representing name of directory, which should be created.
mode Mode of new directory.
Returns:
0 OK, or -EMLINK on DB error or PTR_ERR(inode) on inode creation error.

Definition at line 64 of file fs_dir.c.

References CMD_ER_NR, struct_command::command_nr, MAX_QUERY_LENGTH, struct_command::param, query(), ret_command, rkfs_atoi(), RKFS_DEF_QUERY_OK, rkfs_dops, and rkfs_iops.

int rkfs_next_data_item ( char **  com_data_pos,
char *  ret_buf 
)

Read next data item from a answer received from a deamon.

Message used for parsing data from message.

Parameters:
com_data_pos Position where we stop parcing last time.
ret_buf buffer for returned item
Returns:
Length of read data.
When a answer came, it can seems like /xx/2/4/ddd/5/5/... this function is used to parce messages like this. It litle bit poiter juggling

Definition at line 281 of file fs_main.c.

Referenced by rkfs_file_readdir(), rkfs_inode_lookup(), rkfs_inode_rename(), and rkfs_super_read_inode().

int rkfs_rmdir ( struct inode *  dir,
struct dentry *  dentry 
)

Function for remove directory.

Remove directory specified in dentry

Parameters:
dir Dir from which should be dir removed.
dentry Dentry representing name of directory, which should be removed.
Returns:
OK on succes or -ENOTEMPTY when directory not empty, -EFAULT on other errors.

Definition at line 124 of file fs_dir.c.

References CMD_ER_NR, struct_command::command_nr, FSPDEBUG, MAX_QUERY_LENGTH, query(), ret_command, and RKFS_DEF_QUERY_OK.

void rkfs_super_delete_inode ( struct inode *  inode  ) 

Delete inode.

Deletes an inode.

Parameters:
inode Pointer to inode structure to be deleted.
Returns:
Value of generic_delete_inode.

Definition at line 332 of file fs_inode.c.

References FSPDEBUG.

void rkfs_super_read_inode ( struct inode *  inode  ) 

Super read inode.

Reads inode inode. Super block operation.

Parameters:
inode Pointer to inode structure to be readen to.

Definition at line 208 of file fs_inode.c.

References CMD_ER_NR, struct_command::command_nr, struct_command::data, FSPDEBUG, FSPRETCMD, MAX_QUERY_LENGTH, MAX_SIZE_LENGTH, struct_command::param, query(), ret_command, rkfs_atoi(), RKFS_DEF_QUERY_OK, rkfs_dops, rkfs_fops, rkfs_iops, and rkfs_next_data_item().

int rkfs_super_write_inode ( struct inode *  inode,
int  wait 
)

Super write inode.

Super write inode, fuction is not used.

Parameters:
inode Inode to be written.
wait Ignored.
Returns:
0 OK.

Definition at line 281 of file fs_inode.c.

References FSPDEBUG.


Variable Documentation

char out_buf[OUT_BUF_LENGTH]

buffer for output messages

Definition at line 167 of file fs_main.c.

Referenced by query().

int result

variable for storing result form function query

Definition at line 161 of file fs_main.c.

Referenced by __fsc_query__(), fsc_query(), fsd_chardevice_read(), fsd_chardevice_write(), main(), query(), rkfs_atoi(), and rkfs_get_sb().

struct_command ret_command

structure for storing parsed command

Definition at line 164 of file fs_main.c.

Referenced by query(), rkfs_file_read(), rkfs_file_readdir(), rkfs_file_write(), rkfs_inode_create(), rkfs_inode_lookup(), rkfs_inode_rename(), rkfs_inode_truncate(), rkfs_inode_unlink(), rkfs_mkdir(), rkfs_rmdir(), and rkfs_super_read_inode().

struct file_system_type rkfs

structure for registration modul as filesystem

Definition at line 260 of file fs_main.c.

struct file_operations rkfs_dops

dir operations structure

Definition at line 46 of file fs_dir.c.

Referenced by rkfs_mkdir(), and rkfs_super_read_inode().

struct file_operations rkfs_fops

file operations structure

Definition at line 42 of file fs_file.c.

Referenced by rkfs_inode_create(), and rkfs_super_read_inode().

struct inode_operations rkfs_iops

inode operations structure

Definition at line 56 of file fs_inode.c.

Referenced by rkfs_inode_create(), rkfs_mkdir(), and rkfs_super_read_inode().

struct super_operations rkfs_sops

super block operations structure

Definition at line 47 of file fs_inode.c.


Generated on Mon May 28 13:33:08 2007 for MYSQLFS by  doxygen 1.5.0