CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fs_traversal Struct Reference

#include <fs_traversal_interface.h>

Collaboration diagram for fs_traversal:

Public Attributes

struct fs_traversal_contextcontext_
 
struct fs_traversal_context *(* initialize )(const char *repo, const char *base, const char *data, const char *config, int num_threads)
 
void(* finalize )(struct fs_traversal_context *ctx)
 
void(* archive_provenance )(struct fs_traversal_context *src, struct fs_traversal_context *dest)
 
void(* list_dir )(struct fs_traversal_context *ctx, const char *dir, char ***buf, size_t *len)
 
int(* get_stat )(struct fs_traversal_context *ctx, const char *path, struct cvmfs_attr *stat, bool get_hash)
 
bool(* is_hash_consistent )(struct fs_traversal_context *ctx, const struct cvmfs_attr *stat)
 
int(* set_meta )(struct fs_traversal_context *ctx, const char *path, const struct cvmfs_attr *stat)
 
char *(* get_identifier )(struct fs_traversal_context *ctx, const struct cvmfs_attr *stat)
 
bool(* has_file )(struct fs_traversal_context *ctx, const char *identifier)
 
int(* do_link )(struct fs_traversal_context *ctx, const char *path, const char *identifier)
 
int(* do_unlink )(struct fs_traversal_context *ctx, const char *path)
 
int(* do_mkdir )(struct fs_traversal_context *ctx, const char *path, const struct cvmfs_attr *stat)
 
int(* do_rmdir )(struct fs_traversal_context *ctx, const char *path)
 
int(* touch )(struct fs_traversal_context *ctx, const struct cvmfs_attr *stat)
 
void *(* get_handle )(struct fs_traversal_context *ctx, const char *identifier)
 
int(* do_symlink )(struct fs_traversal_context *ctx, const char *src, const char *dest, const struct cvmfs_attr *stat_info)
 
int(* garbage_collector )(struct fs_traversal_context *ctx)
 
int(* do_fopen )(void *file_ctx, fs_open_type op_mode)
 
int(* do_fclose )(void *file_ctx)
 
int(* do_fread )(void *file_ctx, char *buff, size_t len, size_t *read_len)
 
int(* do_fwrite )(void *file_ctx, const char *buff, size_t len)
 
void(* do_ffree )(void *file_ctx)
 

Detailed Description

Definition at line 30 of file fs_traversal_interface.h.

Member Data Documentation

void(* fs_traversal::archive_provenance)(struct fs_traversal_context *src, struct fs_traversal_context *dest)

Method that takes the specifications provided and stores them in a provenance directory.

Parameters
[in]srcThe src context being archived
[in]destThe dest context being archived

Definition at line 74 of file fs_traversal_interface.h.

Referenced by main(), and posix_get_interface().

struct fs_traversal_context* fs_traversal::context_

Local copy of the context that should be set with the returned value of initialize. This is allocated using initialize and freed using finalize.

Definition at line 36 of file fs_traversal_interface.h.

Referenced by shrinkwrap::copyFile(), shrinkwrap::cvmfs_attr_cmp(), shrinkwrap::GarbageCollect(), shrinkwrap::handle_dir(), shrinkwrap::handle_file(), shrinkwrap::list_src_dir(), main(), shrinkwrap::Sync(), and shrinkwrap::updateStat().

int(* fs_traversal::do_fclose)(void *file_ctx)

Method which closes a file described by the given file context. Needs to be called after open. After this operation open needs to be called again before further read and write operations

Parameters
[in,out]file_ctxThe file context used
Returns
0 on success

Definition at line 329 of file fs_traversal_interface.h.

Referenced by shrinkwrap::copyFile(), libcvmfs_get_interface(), and posix_get_interface().

void(* fs_traversal::do_ffree)(void *file_ctx)

Method which frees a given file context

Definition at line 357 of file fs_traversal_interface.h.

Referenced by shrinkwrap::copyFile(), libcvmfs_get_interface(), and posix_get_interface().

int(* fs_traversal::do_fopen)(void *file_ctx, fs_open_type op_mode)

Method which opens a file described by the given file context. Needs to be called before read and write operations

Parameters
[in,out]file_ctxThe file context used for opening
[in]op_modeThe mode for opening the file
Returns
0 on success

Definition at line 318 of file fs_traversal_interface.h.

Referenced by shrinkwrap::copyFile(), libcvmfs_get_interface(), and posix_get_interface().

int(* fs_traversal::do_fread)(void *file_ctx, char *buff, size_t len, size_t *read_len)

Method which reads len chars into buff from the file described by the given context

Parameters
[in]file_ctxThe file context used
[out]buffThe buffer to write to
[in]lenThe length of the buffer buff
[out]read_lenThe number of chars read $returns 0 on success

Definition at line 341 of file fs_traversal_interface.h.

Referenced by shrinkwrap::copyFile(), libcvmfs_get_interface(), and posix_get_interface().

int(* fs_traversal::do_fwrite)(void *file_ctx, const char *buff, size_t len)

Method which writes len chars from buff into the file described by the given context

Parameters
[in]file_ctxThe file context used
[in]buffThe buffer to read from
[in]lenThe length of the buffer buff
Returns
0 on success

Definition at line 352 of file fs_traversal_interface.h.

Referenced by shrinkwrap::copyFile(), libcvmfs_get_interface(), and posix_get_interface().

int(* fs_traversal::do_link)(struct fs_traversal_context *ctx, const char *path, const char *identifier)

Method which creates a hardlink from the given path to the file given by its identifier

For this call to succeed the file given by its identifier already needs to exist in the destination filesystem

If the path already exists the old entry will silently be removed and a new link will be created

Error if:

  • File described by identifier does not exist
  • Directory does not exist
Parameters
[in]ctxThe file system traversal context
[in]pathThe path where the file should be linked
[in]identifierThe identifier of the file (usually obtained through get_identifier)

Definition at line 196 of file fs_traversal_interface.h.

Referenced by shrinkwrap::handle_file(), and posix_get_interface().

int(* fs_traversal::do_mkdir)(struct fs_traversal_context *ctx, const char *path, const struct cvmfs_attr *stat)

Method which will create the given directory

If the path already exists the old entry will silently be removed and a new directory will be created

Error if:

  • Parent directory not defined
Parameters
[in]ctxThe file system traversal context
[in]pathThe path to the directory that should be created
[in]statThe stat containing the meta data for directory creation

Definition at line 227 of file fs_traversal_interface.h.

Referenced by shrinkwrap::handle_dir(), and posix_get_interface().

int(* fs_traversal::do_rmdir)(struct fs_traversal_context *ctx, const char *path)

Method which removes the given directory

Error if:

  • Directory doesn't exist
  • Directory is not empty
Parameters
[in]ctxThe file system traversal context
[in]pathThe path to the directory that should be removed

Definition at line 241 of file fs_traversal_interface.h.

Referenced by posix_get_interface(), and shrinkwrap::Sync().

int(* fs_traversal::do_symlink)(struct fs_traversal_context *ctx, const char *src, const char *dest, const struct cvmfs_attr *stat_info)

Method which creates a symlink at src which points to dest

If src already exists the old entry will silently be removed and a new symlink will be created

Error:

  • src directory doesn't exist
  • symlink creation fails
  • on empty destination
Parameters
[in]ctxThe file system traversal context
[in]srcThe position at which the symlink should be saved (parent directory must exist)
[in]destThe position the symlink should point to
[in]stat_infoThe stat containing the meta data for symlink creation
Note
(steuber): Currently permissions and user. xattributes are not established due to posix limitations.

Definition at line 291 of file fs_traversal_interface.h.

Referenced by posix_get_interface(), and shrinkwrap::Sync().

int(* fs_traversal::do_unlink)(struct fs_traversal_context *ctx, const char *path)

Method removes the hardlink at the given path

Error if:

  • Link does not exist
  • Link is directory
  • Unlink not successful
Parameters
[in]ctxThe file system traversal context
[in]pathThe path which should be removed

Definition at line 211 of file fs_traversal_interface.h.

Referenced by posix_get_interface(), and shrinkwrap::Sync().

void(* fs_traversal::finalize)(struct fs_traversal_context *ctx)

Method which finalizes the file system traversal. Must always be called after a context had been initialized and before the procedure ends

The context is freed during execution of this method

Parameters
[in]ctxThe context to finalize and free

Definition at line 65 of file fs_traversal_interface.h.

Referenced by libcvmfs_get_interface(), main(), and posix_get_interface().

int(* fs_traversal::garbage_collector)(struct fs_traversal_context *ctx)

Method which executes garbage collection on the file systems hidden data directories.

This method is usually quite costly in terms of time and should only be invoked with care! If multiple repositories share the same hidden data repository it makes sense to invoke it only once all repositories are up to date.

Parameters
[in]ctxThe file system traversal context
Returns
0 on success

Definition at line 308 of file fs_traversal_interface.h.

Referenced by shrinkwrap::GarbageCollect(), and posix_get_interface().

void*(* fs_traversal::get_handle)(struct fs_traversal_context *ctx, const char *identifier)

Retrieves a handle struct which allows the manipulation of the file defined by the given identifier

Parameters
[in]ctxThe file system traversal context
[in]identifierThe identifier of the file to manipulate (usually obtained through get_identifier)
Returns
A context that can be used for reading from and writing to the specified file (needs to be freed by ffree method)

Definition at line 268 of file fs_traversal_interface.h.

Referenced by shrinkwrap::copyFile(), libcvmfs_get_interface(), and posix_get_interface().

char*(* fs_traversal::get_identifier)(struct fs_traversal_context *ctx, const struct cvmfs_attr *stat)

Method which returns an identifier (usually a path) to a file identified by a stat struct

The memory of the char is allocated on the heap and needs to be freed by the caller

Parameters
[in]ctxThe file system traversal context
[in]statThe stat struct describing the file
Returns
A path that can be used to identify the file

Definition at line 161 of file fs_traversal_interface.h.

Referenced by shrinkwrap::handle_file(), libcvmfs_get_interface(), and posix_get_interface().

int(* fs_traversal::get_stat)(struct fs_traversal_context *ctx, const char *path, struct cvmfs_attr *stat, bool get_hash)

Method which returns a stat struct given a file path. If the file doesn't exist, NULL is returned

Note
(steuber): The content checksum only needs to be calculated if this is a source file system!

For correct behaviour the following fields must be set (and may not be NULL):

  • version
  • size
  • st_mode
  • st_uid
  • st_gid
  • cvm_name
Parameters
[in]ctxThe file system traversal context
[in]pathThe path of the object to stat
[out]statThe stat struct to write the information into
[in]get_hashWhether the file hash in cvm_checksum should be calculated (true) or not (false)
Returns
0 on success

Definition at line 115 of file fs_traversal_interface.h.

Referenced by libcvmfs_get_interface(), posix_get_interface(), and shrinkwrap::updateStat().

bool(* fs_traversal::has_file)(struct fs_traversal_context *ctx, const char *identifier)

Method which checks whether the file described by the given path exists in the destination file system

Parameters
[in]ctxThe file system traversal context
[in]identifierThe identifier of the file (obtained by get_identifier)
Returns
True if file was found, false if not

Definition at line 174 of file fs_traversal_interface.h.

Referenced by libcvmfs_get_interface(), and posix_get_interface().

struct fs_traversal_context*(* fs_traversal::initialize)(const char *repo, const char *base, const char *data, const char *config, int num_threads)

Method which initializes a file system traversal context based on repository and data storage information

Parameters
[in]repoRepository name
[in]baseBase repository location
[in]dataData storage information
[in]configA configuration file name
[in]num_threadsNumber of threads that may be started
[out]Apointer to the context

Definition at line 49 of file fs_traversal_interface.h.

Referenced by libcvmfs_get_interface(), main(), and posix_get_interface().

bool(* fs_traversal::is_hash_consistent)(struct fs_traversal_context *ctx, const struct cvmfs_attr *stat)

Checks whether for a given stat the file at the stat's path name is actually linked to the file described by the stat's checksum

If this method returns false it usually means the file is out of sync and needs to be copied and linked

Error if:

  • Visible path (stat->cvm_name) doesn't exist (ENOENT)
Parameters
[in]ctxThe file system traversal context
[in]statThe stat which should be used for the consistency check
Returns
true if consistent, false if not is_hash_consistent returns false and a non-zero errno on error

Definition at line 134 of file fs_traversal_interface.h.

Referenced by shrinkwrap::cvmfs_attr_cmp(), posix_get_interface(), and shrinkwrap::Sync().

void(* fs_traversal::list_dir)(struct fs_traversal_context *ctx, const char *dir, char ***buf, size_t *len)

Method which returns a list of the given directory. Should not include "." or "..".

Parameters
[in]ctxThe file system traversal context
[in]dirThe directory over which should be iterated
[out]bufThe list of the paths to the elements in the directory
[out]lenLength of the output list

Definition at line 86 of file fs_traversal_interface.h.

Referenced by libcvmfs_get_interface(), shrinkwrap::list_src_dir(), posix_get_interface(), and shrinkwrap::Sync().

int(* fs_traversal::set_meta)(struct fs_traversal_context *ctx, const char *path, const struct cvmfs_attr *stat)

Sets the meta information for the directory entry. This assumes that other information is the same, and only updates the metadata. Used only on directories.

Parameters
[in]ctxThe file system traversal context
[in]pathThe path of the object to be updated
[in]statThe stat structure that determines the new values
Returns
0 on success, -1 otherwise

Definition at line 147 of file fs_traversal_interface.h.

Referenced by shrinkwrap::handle_dir(), and posix_get_interface().

int(* fs_traversal::touch)(struct fs_traversal_context *ctx, const struct cvmfs_attr *stat)

Atomically creates the file representing the given identifier

Error:

  • If file exists (errno set to EEXIST)
  • Error during creation and meta data saving operations
Parameters
[in]ctxThe file system traversal context
[in]statThe stat containing the meta data for file creation

Definition at line 255 of file fs_traversal_interface.h.

Referenced by shrinkwrap::handle_file(), and posix_get_interface().


The documentation for this struct was generated from the following file: