next up previous contents
Next: PkgMgr Up: Definizioni delle classi Previous: Definizioni delle classi   Indice

PKGFS

/*
 * pkgfs.h
 * Copyright (C) 2004 Luca Ferroni <fferroni@cs.unibo.it>
 *
 * PKGFS is the very basic PackageFS class. It mainly implements 
 * the shared library symbols to be resolved by lufsd. It owns a 
 * complete public interface to carry out the common file system 
 * functions.
 *
 * This file is released under the GPL v2.
 * This file may be redistributed under the terms of the GNU Public
 * License.
 */
#ifndef _PKGFS_H_
#define _PKGFS_H_

#include <string>

#define AVAIL_DIR	"/AVAILABLE\0"
#define INSTALL_DIR	"/INSTALL\0"
#define HOLD_DIR	"/HOLD\0"

#define DEPENDS_DIR	"DEPENDS_ON\0"
#define RDEPENDS_DIR	"DEPEND_FOR\0"

using namespace std;

struct directory;
struct dir_cache;

class PkgManager;
class PKGFSCache;
class Vtree;

class PKGFS {

    public:
    
        PKGFS(struct list_head*, struct dir_cache*, struct credentials*);
        ~PKGFS();
		
        int do_mount();
        void do_umount();
        int do_readdir(char*, struct directory*);
        int do_stat(char*, struct lufs_fattr*);
        int do_readlink(char*, char*, int);
        int do_open(char*, unsigned);
        int do_release(char*);
        int do_read(char*, long long, unsigned long, char*);
        int do_mkdir(char*, int);
        int do_rmdir(char*);
        int do_unlink(char*);
        int do_create(char*, int);
        int do_symlink(char*, char*);
        int do_rename(char*, char*);
        int do_write(char*, long long, unsigned long, char*);
        int do_setattr(char*, struct lufs_fattr*);

    private:
	
        struct credentials *cred;
        struct dir_cache *cache;

        //! Configuration options
        struct list_head *cfg;
		
        //! The package manager virtual abstraction layer
        PkgManager *pkgmgr;
		
        //! The pointer to the package entry found in 
        //! the package manager cache
        void *pkgPtr;

        //! Virtual tree structure to store the directory hierarchy
        Vtree *pkgVtree;
		
        //! Useful for reading and saving the cache
        PKGFSCache *pcache;

        //! Section and Priority settings */
        int sectionValue, priorityValue;
		
        //! Level of the packages base directory:
        //! At what depth can I find packages ?
        //! The answer depends from sectionValue and priorityValue
        unsigned int baselevel;
	
    protected:
		
        char *get_dir(char *);
		
        //! Strip the last entry of a path
        string get_pkgname(char *);
		
        //! Return the directory level
        int dir_level(string);
		
        //! Package manager operation wrappers
        int installation(char *);
        int removal(char *);
	
        //! Initialize the base directories (AVAIL_DIR, ...)
        int initPkgFs(string buffer);

        //! Create available package subdirectory
        //! and the "info" fakefile to get infos about the package
        int mkAvailSubdir(string);
		
        //! Create package subdirectory and symlinks to owned files
        //! and dependencies subdirectories
        int mkpkgSubdir(string,string);
	
        //! If the dependencies of a package were installed by pkgmgr
        //! during package installation, create their entries in pkgfs.
        int mkpkgDepSubdir(string);
		
        //! Create dependencies subdirectory DEPENDS_DIR and 
        //! RDEPENDS_DIR and make symlink to installed dependency
        //! or a fakefile if it is not installed
        int mkpkgDepSubtree(string,depFlag);
		
        //! Create subdirs and symlinks for dependencies by type
        int mkpkgDepSymlinks(string, string, string);
	
        //! Create subdirs or symlink to package owned files
        int mkpkgSymlinks(string, string);
	
        //! Create directory and symlinks to each package dependency
        //! installed with a package
        int mkdepSubdir(string,string);	

};

#endif


2004-11-19