/*************************************************************************** $RCSfile$ ------------------- cvs : $Id$ begin : Thu Aug 15 2002 copyright : (C) 2002 by Martin Preuss email : martin@libchipcard.de *************************************************************************** * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * * * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include "cardfs.h" extern "C" { void* cardfs_init(struct list_head *cfg, struct dir_cache *cache, struct credentials *cred, void **global_fs){ return (void*)new CardFS(cfg, cache); } void cardfs_free(void *ctx){ CardFS *p = (CardFS*)ctx; delete p; } int cardfs_mount(void *ctx){ return ((CardFS*)ctx)->do_mount(); } void cardfs_umount(void *ctx){ // return ((CardFS*)ctx)->do_umount(); } int cardfs_readdir(void *ctx, char *dir_name, struct directory *dir){ return ((CardFS*)ctx)->do_readdir(dir_name, dir); } int cardfs_stat(void *ctx, char *name, struct lufs_fattr *fattr){ return ((CardFS*)ctx)->do_stat(name, fattr); } int cardfs_mkdir(void *ctx, char *dir, int mode){ return ((CardFS*)ctx)->do_mkdir(dir, mode); } int cardfs_rmdir(void *ctx, char *dir){ return ((CardFS*)ctx)->do_rmdir(dir); } int cardfs_create(void *ctx, char *file, int mode){ return ((CardFS*)ctx)->do_create(file, mode); } int cardfs_unlink(void *ctx, char *file){ return ((CardFS*)ctx)->do_unlink(file); } int cardfs_rename(void *ctx, char *old_name, char *new_name){ return ((CardFS*)ctx)->do_rename(old_name, new_name); } int cardfs_open(void *ctx, char *file, unsigned mode){ return ((CardFS*)ctx)->do_open(file, mode); } int cardfs_release(void *ctx, char *file){ return ((CardFS*)ctx)->do_release(file); } int cardfs_read(void *ctx, char *file, unsigned long offset, unsigned long count, char *buf){ return ((CardFS*)ctx)->do_read(file, offset, count, buf); } int cardfs_write(void *ctx, char *file, unsigned long offset, unsigned long count, char *buf){ return ((CardFS*)ctx)->do_write(file, offset, count, buf); } int cardfs_readlink(void *ctx, char *link, char *buf, int buflen){ return ((CardFS*)ctx)->do_readlink(link, buf, buflen); } int cardfs_link(void *ctx, char *target, char *link){ return ((CardFS*)ctx)->do_link(target, link); } int cardfs_symlink(void *ctx, char *target, char *link){ return ((CardFS*)ctx)->do_symlink(target, link); } int cardfs_setattr(void *ctx, char *file, struct lufs_fattr *fattr){ return ((CardFS*)ctx)->do_setattr(file, fattr); } } /* extern "C" */ CardFS::CardFS(struct list_head *c, struct dir_cache *cache, struct credentials *cred) { cfg = c; this->cache = cache; this->cred = cred; _cid="LUFS:CardFS:"+CTMisc::num2string(getpid()); } CardFS::~CardFS(){ } int CardFS::do_mount(){ unsigned int pos; string tmp; try { tmp=options.o_host; pos=tmp.find("@"); if (pos!=string::npos) { _terminal=tmp.substr(0,pos); if (pos+1=0) { if (entry.attributes() & CTDirEntry::Attr_USED) { fattr=_entry2fattr(entry); lu_cache_add2dir(dir, (char*)entry.name().c_str(), NULL, &fattr); } } // while return 0; } int CardFS::do_stat(char *nm, struct lufs_fattr *fattr){ int result; CTDirEntry entry; INFO("do_stat "<"<"<"<