/** * @file tarfs_tar.h * * Header file for tarfs_tar.c * Contains functions needed for parsing tar * This interface is aimed for interoperability with VFS * * @author Jaroslav Drazan * @author Petr Cermak */ /* ************************************************************************* * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * ************************************************************************* */ #ifndef __TARFS_TAR_H__ #define __TARFS_TAR_H__ // super_block #include /** * @brief Performs quick valiadtion of tar * * This function controls only the first block * * @param s Super block structure needed to perform i/o operations * @return 1 - OK, 0 - is not tar, or other error */ int tar_quick_validation(struct super_block* s); /** * @brief Returns number of root inode * * @param s Super block structure needed to perform i/o operations * @return Number of root inode, TARFS_EVAL - error */ unsigned long tar_get_root_ino(struct super_block* s); /** * @breif Returns number of blocks in tar * * @param s Super block structure needed to perform i/o operations * @return Number of blocks, 0 - error (or empty) */ unsigned long tar_length(struct super_block* s); /** * @brief Reads inode from tar * * Fills inode data like times, acces rights, size of file * * @param s Super block structure needed to perform i/o operations * @param inode Inode structure to be filled * @param rdev [out] If inode type is device, this parameter is filled with value * kdev_t_to_nr(major, minor) * @return Type of inode, as defined in stat.h (S_IFREG, S_IFLNK, S_IFCHR, S_IFBLK, S_IFIFO, S_IFDIR), 0 in case of error */ int tar_fill_inode(struct super_block* s, struct inode* inode, int* rdev); /** * @brief Reads directory entries * * Reads directory entries, until stopped by returning <0 from filldir function, * after that, it stores last entry id read into filp->f_pos. When called again, * it continues from the last f_pos stored. * * @param s Super block structure needed to perform i/o operations * @param filp A file structure representing directory being read * @param dirent Falls through this function to the filldir call * @param filldir Pointer to a function called to add new dir entry * @return Count of directory entries read, TARFS_EVAL otherwise */ unsigned long tar_readdir(struct file* filp, void* dirent, filldir_t filldir); /** * @brief Searches for file in given directory * * @param s Super block structure needed to perform i/o operations * @param ino Inode of directory to be searched in * @param fname Name of desired file * @param fsize Size of fname * @return Inode number of file if found, @a TARFS_EVAL otherwise */ unsigned long tar_lookup(struct super_block* s, unsigned long ino,const char* fname, unsigned int fsize); /** * @brief Fills buffer with data from given inode * * Reads data from inode with given offset to the end of file or end of buffer (max PAGE_SIZE bytes) * * @param s Super block structure needed to perform i/o operations * @param inode Inode with data to be read * @param offset Offset of desired data * @param buffer Alredy allocated buffer of size PAGE_SIZE (PAGE_SIZE should be multiple of 512) * @return 0 - EOF, 1 - OK, 2 - Symlink, TARFS_EVAL otherwise */ unsigned long tar_read_page(struct super_block* s, struct inode* inode, loff_t offset, void* buffer); #endif //__TARFS_TAR_H__