ShingledFS 2.0
SMR-AwareFUSE-basedFileSystem
|
Implementation of Helper functions. More...
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/xattr.h>
#include <linux/limits.h>
#include "helper.h"
#include "failstop.h"
#include "emulator.h"
#include "band_log.h"
Go to the source code of this file.
Functions | |
void | read_edi_parameters (int fd, uint32_t *blk_size, band_t *band_count, rba_t *band_size) |
Reads the EDI Parameters and saves them in the FUSE private context. | |
void | translate_path (const char *in_path, const char *prefix, char *out_path) |
Translate the incoming path by adding the specified prefix to it. | |
void | xattr_path (const char *in_path, char *out_path) |
Generates the name of the attribute replication file for the specified input file path. | |
int | xattr_get (const char *path, const char *name, void *value, size_t size) |
Retrieves the extended attributes of the specified file. | |
void | xattr_set (const char *path, const char *name, void *value, size_t size, int flags) |
Sets the replicated attributes of the specified file. | |
int | is_valid_dir (const char *path) |
Validates the specified path to be a directory. | |
int | is_valid_file (const char *path) |
Validates the specified path to be a file. | |
void | mark_for_cleaning (inode_t inode) |
Performs all the updates needed to mark the band space defined by the specified inode for cleaning. | |
void | inode_free (int inodeno) |
Frees the specified inode. | |
void | inode_update (inode_t *inode, band_t band, rba_t rba, size_t size) |
Updates the band usage data in the inode. | |
void | inode_unlink (inode_t inode) |
Unlinks the inode. |
Implementation of Helper functions.
Definition in file helper.c.
void inode_free | ( | int | inodeno | ) | [inline] |
Frees the specified inode.
This function should be called when an inode needs to be freed. This usually occurs when a file has been deleted or renamed (when a file is renamed to an existing file).
inodeno | The inode no. of the inode to be freed |
Definition at line 302 of file helper.c.
Referenced by inode_unlink().
void inode_unlink | ( | inode_t | inode | ) | [inline] |
Unlinks the inode.
This function marks the space described by the inode for cleaning and then frees the inode.
inode | Inode of the file that is being deleted |
Definition at line 360 of file helper.c.
References inode_free(), and mark_for_cleaning().
Referenced by bc_close(), bc_rename(), and shingledfs_unlink().
void inode_update | ( | inode_t * | inode, |
band_t | band, | ||
rba_t | rba, | ||
size_t | size | ||
) | [inline] |
int is_valid_dir | ( | const char * | path | ) |
int is_valid_file | ( | const char * | path | ) |
void mark_for_cleaning | ( | inode_t | inode | ) | [inline] |
Performs all the updates needed to mark the band space defined by the specified inode for cleaning.
This function should be called whenever a space allocated to a file on any band needs to be marked for cleaning. This should usually be called when a file is updated or deleted.
inode | Inode of the file that is being deleted/updated. |
Definition at line 274 of file helper.c.
Referenced by inode_unlink().
void read_edi_parameters | ( | int | fd, |
uint32_t * | blk_size, | ||
band_t * | band_count, | ||
rba_t * | band_size | ||
) |
Reads the EDI Parameters and saves them in the FUSE private context.
fd_edi | File Descriptor to open EDI file |
blk_size | Pointer to variable storing the block size of the EDI |
band_count | Pointer to variable storing the no. of bands on the EDI |
band_size | Pointer to variable storing the size of a band on the EDI |
Definition at line 50 of file helper.c.
Referenced by shingledfs_init().
void translate_path | ( | const char * | in_path, |
const char * | prefix, | ||
char * | out_path | ||
) |
Translate the incoming path by adding the specified prefix to it.
out_path must be large enough to store the concatenation of in_path and prefix, plus the terminating null character.
in_path | The input path |
prefix | The path to prefix to the incoming path |
out_path | The location to store the resulting concatenation |
Definition at line 77 of file helper.c.
Referenced by init_inodebitmap(), init_inodelist(), shingledfs_access(), shingledfs_chmod(), shingledfs_chown(), shingledfs_getattr(), shingledfs_getxattr(), shingledfs_link(), shingledfs_listxattr(), shingledfs_mkdir(), shingledfs_mknod(), shingledfs_open(), shingledfs_opendir(), shingledfs_readlink(), shingledfs_release(), shingledfs_releasedir(), shingledfs_removexattr(), shingledfs_rename(), shingledfs_rmdir(), shingledfs_setxattr(), shingledfs_statfs(), shingledfs_symlink(), shingledfs_truncate(), shingledfs_unlink(), and shingledfs_utime().
int xattr_get | ( | const char * | path, |
const char * | name, | ||
void * | value, | ||
size_t | size | ||
) |
Retrieves the extended attributes of the specified file.
path | The path to the file on the unshingled partition |
name | Name of the extended attribute to retrieve |
value | Buffer to hold the value of the extended attribute |
size | Size of the buffer |
Definition at line 162 of file helper.c.
References xattr_path().
Referenced by bc_open(), shingledfs_access(), shingledfs_chmod(), shingledfs_chown(), shingledfs_getattr(), shingledfs_getxattr(), shingledfs_link(), shingledfs_truncate(), shingledfs_unlink(), and shingledfs_utime().
void xattr_path | ( | const char * | in_path, |
char * | out_path | ||
) |
Generates the name of the attribute replication file for the specified input file path.
This function should not be called for directories!
Given the path to the input file, this function appends the Attribute Replication file prefix (.xattr_) to the name of the file.
in_path | The path to the file on the unshingled partition |
out_path | The location to store the resulting concatenation |
Definition at line 114 of file helper.c.
Referenced by bc_open(), shingledfs_mknod(), shingledfs_rename(), shingledfs_unlink(), xattr_get(), and xattr_set().
void xattr_set | ( | const char * | path, |
const char * | name, | ||
void * | value, | ||
size_t | size, | ||
int | flags | ||
) |
Sets the replicated attributes of the specified file.
path | The path to the file on the unshingled partition |
name | Name of the extended attribute to update |
value | Buffer holding the value to be set for the extended attribute |
size | Size of the data in the buffer |
Definition at line 187 of file helper.c.
References xattr_path().
Referenced by shingledfs_chmod(), shingledfs_chown(), shingledfs_link(), shingledfs_mknod(), shingledfs_setxattr(), shingledfs_truncate(), and shingledfs_utime().