15a1d355fSStephan Aßmus // netfs.cpp
25a1d355fSStephan Aßmus
35a1d355fSStephan Aßmus #include <new>
45a1d355fSStephan Aßmus
55a1d355fSStephan Aßmus #include <KernelExport.h>
65a1d355fSStephan Aßmus #include <fsproto.h>
75a1d355fSStephan Aßmus
85a1d355fSStephan Aßmus #include "DebugSupport.h"
95a1d355fSStephan Aßmus #include "Node.h"
105a1d355fSStephan Aßmus #include "ObjectTracker.h"
115a1d355fSStephan Aßmus #include "QueryManager.h"
125a1d355fSStephan Aßmus #include "RootVolume.h"
135a1d355fSStephan Aßmus #include "VolumeManager.h"
145a1d355fSStephan Aßmus
155a1d355fSStephan Aßmus // #pragma mark -
165a1d355fSStephan Aßmus // #pragma mark ----- prototypes -----
175a1d355fSStephan Aßmus
185a1d355fSStephan Aßmus extern "C" {
195a1d355fSStephan Aßmus
205a1d355fSStephan Aßmus // fs
215a1d355fSStephan Aßmus static int netfs_mount(nspace_id nsid, const char *device, ulong flags,
225a1d355fSStephan Aßmus void *parameters, size_t len, void **data, vnode_id *rootID);
235a1d355fSStephan Aßmus static int netfs_unmount(void *ns);
240ea1aab2SOliver Tappe //static int netfs_sync(void *ns);
255a1d355fSStephan Aßmus static int netfs_read_fs_stat(void *ns, struct fs_info *info);
260ea1aab2SOliver Tappe //static int netfs_write_fs_stat(void *ns, struct fs_info *info, long mask);
275a1d355fSStephan Aßmus
285a1d355fSStephan Aßmus // vnodes
295a1d355fSStephan Aßmus static int netfs_read_vnode(void *ns, vnode_id vnid, char reenter,
305a1d355fSStephan Aßmus void **node);
315a1d355fSStephan Aßmus static int netfs_write_vnode(void *ns, void *node, char reenter);
325a1d355fSStephan Aßmus static int netfs_remove_vnode(void *ns, void *node, char reenter);
335a1d355fSStephan Aßmus
345a1d355fSStephan Aßmus // nodes
350ea1aab2SOliver Tappe //static int netfs_fsync(void *ns, void *node);
365a1d355fSStephan Aßmus static int netfs_read_stat(void *ns, void *node, struct stat *st);
375a1d355fSStephan Aßmus static int netfs_write_stat(void *ns, void *node, struct stat *st,
385a1d355fSStephan Aßmus long mask);
395a1d355fSStephan Aßmus static int netfs_access(void *ns, void *node, int mode);
405a1d355fSStephan Aßmus
415a1d355fSStephan Aßmus // files
425a1d355fSStephan Aßmus static int netfs_create(void *ns, void *dir, const char *name,
435a1d355fSStephan Aßmus int openMode, int mode, vnode_id *vnid, void **cookie);
445a1d355fSStephan Aßmus static int netfs_open(void *ns, void *node, int openMode, void **cookie);
455a1d355fSStephan Aßmus static int netfs_close(void *ns, void *node, void *cookie);
465a1d355fSStephan Aßmus static int netfs_free_cookie(void *ns, void *node, void *cookie);
475a1d355fSStephan Aßmus static int netfs_read(void *ns, void *node, void *cookie, off_t pos,
485a1d355fSStephan Aßmus void *buffer, size_t *bufferSize);
495a1d355fSStephan Aßmus static int netfs_write(void *ns, void *node, void *cookie, off_t pos,
505a1d355fSStephan Aßmus const void *buffer, size_t *bufferSize);
515a1d355fSStephan Aßmus static int netfs_ioctl(void *ns, void *node, void *cookie, int cmd,
525a1d355fSStephan Aßmus void *buffer, size_t bufferSize);
530ea1aab2SOliver Tappe //static int netfs_setflags(void *ns, void *node, void *cookie, int flags);
545a1d355fSStephan Aßmus
555a1d355fSStephan Aßmus // hard links / symlinks
565a1d355fSStephan Aßmus static int netfs_link(void *ns, void *dir, const char *name, void *node);
575a1d355fSStephan Aßmus static int netfs_unlink(void *ns, void *dir, const char *name);
585a1d355fSStephan Aßmus static int netfs_symlink(void *ns, void *dir, const char *name,
595a1d355fSStephan Aßmus const char *path);
605a1d355fSStephan Aßmus static int netfs_read_link(void *ns, void *node, char *buffer,
615a1d355fSStephan Aßmus size_t *bufferSize);
625a1d355fSStephan Aßmus static int netfs_rename(void *ns, void *oldDir, const char *oldName,
635a1d355fSStephan Aßmus void *newDir, const char *newName);
645a1d355fSStephan Aßmus
655a1d355fSStephan Aßmus // directories
665a1d355fSStephan Aßmus static int netfs_mkdir(void *ns, void *dir, const char *name, int mode);
675a1d355fSStephan Aßmus static int netfs_rmdir(void *ns, void *dir, const char *name);
685a1d355fSStephan Aßmus static int netfs_open_dir(void *ns, void *node, void **cookie);
695a1d355fSStephan Aßmus static int netfs_close_dir(void *ns, void *node, void *cookie);
705a1d355fSStephan Aßmus static int netfs_free_dir_cookie(void *ns, void *node, void *cookie);
715a1d355fSStephan Aßmus static int netfs_read_dir(void *ns, void *node, void *cookie,
725a1d355fSStephan Aßmus long *count, struct dirent *buffer, size_t bufferSize);
735a1d355fSStephan Aßmus static int netfs_rewind_dir(void *ns, void *node, void *cookie);
745a1d355fSStephan Aßmus static int netfs_walk(void *ns, void *dir, const char *entryName,
755a1d355fSStephan Aßmus char **resolvedPath, vnode_id *vnid);
765a1d355fSStephan Aßmus
775a1d355fSStephan Aßmus // attributes
785a1d355fSStephan Aßmus static int netfs_open_attrdir(void *ns, void *node, void **cookie);
795a1d355fSStephan Aßmus static int netfs_close_attrdir(void *ns, void *node, void *cookie);
805a1d355fSStephan Aßmus static int netfs_free_attrdir_cookie(void *ns, void *node, void *cookie);
815a1d355fSStephan Aßmus static int netfs_read_attrdir(void *ns, void *node, void *cookie,
825a1d355fSStephan Aßmus long *count, struct dirent *buffer, size_t bufferSize);
835a1d355fSStephan Aßmus static int netfs_read_attr(void *ns, void *node, const char *name,
845a1d355fSStephan Aßmus int type, void *buffer, size_t *bufferSize, off_t pos);
855a1d355fSStephan Aßmus static int netfs_rewind_attrdir(void *ns, void *node, void *cookie);
865a1d355fSStephan Aßmus static int netfs_write_attr(void *ns, void *node, const char *name,
875a1d355fSStephan Aßmus int type, const void *buffer, size_t *bufferSize, off_t pos);
885a1d355fSStephan Aßmus static int netfs_remove_attr(void *ns, void *node, const char *name);
895a1d355fSStephan Aßmus static int netfs_rename_attr(void *ns, void *node, const char *oldName,
905a1d355fSStephan Aßmus const char *newName);
915a1d355fSStephan Aßmus static int netfs_stat_attr(void *ns, void *node, const char *name,
925a1d355fSStephan Aßmus struct attr_info *attrInfo);
935a1d355fSStephan Aßmus
945a1d355fSStephan Aßmus // queries
955a1d355fSStephan Aßmus static int netfs_open_query(void *ns, const char *queryString, ulong flags,
965a1d355fSStephan Aßmus port_id port, long token, void **cookie);
975a1d355fSStephan Aßmus static int netfs_close_query(void *ns, void *cookie);
985a1d355fSStephan Aßmus static int netfs_free_query_cookie(void *ns, void *node, void *cookie);
995a1d355fSStephan Aßmus static int netfs_read_query(void *ns, void *cookie, long *count,
1005a1d355fSStephan Aßmus struct dirent *buffer, size_t bufferSize);
1015a1d355fSStephan Aßmus
1025a1d355fSStephan Aßmus } // extern "C"
1035a1d355fSStephan Aßmus
1045a1d355fSStephan Aßmus /* vnode_ops struct. Fill this in to tell the kernel how to call
1055a1d355fSStephan Aßmus functions in your driver.
1065a1d355fSStephan Aßmus */
1075a1d355fSStephan Aßmus vnode_ops fs_entry = {
1085a1d355fSStephan Aßmus &netfs_read_vnode, // read_vnode
1095a1d355fSStephan Aßmus &netfs_write_vnode, // write_vnode
1105a1d355fSStephan Aßmus &netfs_remove_vnode, // remove_vnode
1115a1d355fSStephan Aßmus NULL, // secure_vnode (not needed)
1125a1d355fSStephan Aßmus &netfs_walk, // walk
1135a1d355fSStephan Aßmus &netfs_access, // access
1145a1d355fSStephan Aßmus &netfs_create, // create
1155a1d355fSStephan Aßmus &netfs_mkdir, // mkdir
1165a1d355fSStephan Aßmus &netfs_symlink, // symlink
1175a1d355fSStephan Aßmus &netfs_link, // link
1185a1d355fSStephan Aßmus &netfs_rename, // rename
1195a1d355fSStephan Aßmus &netfs_unlink, // unlink
1205a1d355fSStephan Aßmus &netfs_rmdir, // rmdir
1215a1d355fSStephan Aßmus &netfs_read_link, // readlink
1225a1d355fSStephan Aßmus &netfs_open_dir, // opendir
1235a1d355fSStephan Aßmus &netfs_close_dir, // closedir
1245a1d355fSStephan Aßmus &netfs_free_dir_cookie, // free_dircookie
1255a1d355fSStephan Aßmus &netfs_rewind_dir, // rewinddir
1265a1d355fSStephan Aßmus &netfs_read_dir, // readdir
1275a1d355fSStephan Aßmus &netfs_open, // open file
1285a1d355fSStephan Aßmus &netfs_close, // close file
1295a1d355fSStephan Aßmus &netfs_free_cookie, // free cookie
1305a1d355fSStephan Aßmus &netfs_read, // read file
1315a1d355fSStephan Aßmus &netfs_write, // write file
1325a1d355fSStephan Aßmus NULL, // readv
1335a1d355fSStephan Aßmus NULL, // writev
1345a1d355fSStephan Aßmus &netfs_ioctl, // ioctl
1355a1d355fSStephan Aßmus NULL, // setflags file
1365a1d355fSStephan Aßmus &netfs_read_stat, // read stat
1375a1d355fSStephan Aßmus &netfs_write_stat, // write stat
1385a1d355fSStephan Aßmus NULL, // fsync
1395a1d355fSStephan Aßmus NULL, // initialize
1405a1d355fSStephan Aßmus &netfs_mount, // mount
1415a1d355fSStephan Aßmus &netfs_unmount, // unmount
1425a1d355fSStephan Aßmus NULL, // sync
1435a1d355fSStephan Aßmus &netfs_read_fs_stat, // read fs stat
1445a1d355fSStephan Aßmus NULL, // write fs stat
1455a1d355fSStephan Aßmus NULL, // select
1465a1d355fSStephan Aßmus NULL, // deselect
1475a1d355fSStephan Aßmus
1485a1d355fSStephan Aßmus NULL, // open index dir
1495a1d355fSStephan Aßmus NULL, // close index dir
1505a1d355fSStephan Aßmus NULL, // free index dir cookie
1515a1d355fSStephan Aßmus NULL, // rewind index dir
1525a1d355fSStephan Aßmus NULL, // read index dir
1535a1d355fSStephan Aßmus NULL, // create index
1545a1d355fSStephan Aßmus NULL, // remove index
1555a1d355fSStephan Aßmus NULL, // rename index
1565a1d355fSStephan Aßmus NULL, // stat index
1575a1d355fSStephan Aßmus
1585a1d355fSStephan Aßmus &netfs_open_attrdir, // open attr dir
1595a1d355fSStephan Aßmus &netfs_close_attrdir, // close attr dir
1605a1d355fSStephan Aßmus &netfs_free_attrdir_cookie, // free attr dir cookie
1615a1d355fSStephan Aßmus &netfs_rewind_attrdir, // rewind attr dir
1625a1d355fSStephan Aßmus &netfs_read_attrdir, // read attr dir
1635a1d355fSStephan Aßmus &netfs_write_attr, // write attr
1645a1d355fSStephan Aßmus &netfs_read_attr, // read attr
1655a1d355fSStephan Aßmus &netfs_remove_attr, // remove attr
1665a1d355fSStephan Aßmus &netfs_rename_attr, // rename attr
1675a1d355fSStephan Aßmus &netfs_stat_attr, // stat attr
1685a1d355fSStephan Aßmus
1695a1d355fSStephan Aßmus &netfs_open_query, // open query
1705a1d355fSStephan Aßmus &netfs_close_query, // close query
1715a1d355fSStephan Aßmus &netfs_free_query_cookie, // free query cookie
1725a1d355fSStephan Aßmus &netfs_read_query, // read query
1735a1d355fSStephan Aßmus };
1745a1d355fSStephan Aßmus
1755a1d355fSStephan Aßmus int32 api_version = B_CUR_FS_API_VERSION;
1765a1d355fSStephan Aßmus
1775a1d355fSStephan Aßmus // #pragma mark -
1785a1d355fSStephan Aßmus // #pragma mark ----- fs -----
1795a1d355fSStephan Aßmus
1805a1d355fSStephan Aßmus // netfs_mount
1815a1d355fSStephan Aßmus static
1825a1d355fSStephan Aßmus int
netfs_mount(nspace_id nsid,const char * device,ulong flags,void * parameters,size_t len,void ** data,vnode_id * rootID)1835a1d355fSStephan Aßmus netfs_mount(nspace_id nsid, const char *device, ulong flags,
1845a1d355fSStephan Aßmus void *parameters, size_t len, void **data, vnode_id *rootID)
1855a1d355fSStephan Aßmus {
1865a1d355fSStephan Aßmus status_t error = B_OK;
1875a1d355fSStephan Aßmus init_debugging();
1885a1d355fSStephan Aßmus
1895a1d355fSStephan Aßmus #ifdef DEBUG_OBJECT_TRACKING
1905a1d355fSStephan Aßmus ObjectTracker::InitDefault();
1915a1d355fSStephan Aßmus #endif
1925a1d355fSStephan Aßmus
1935a1d355fSStephan Aßmus // create and init the volume manager
1945a1d355fSStephan Aßmus VolumeManager* volumeManager = new(std::nothrow) VolumeManager(nsid, flags);
1955a1d355fSStephan Aßmus Volume* rootVolume = NULL;
1965a1d355fSStephan Aßmus if (volumeManager) {
1975a1d355fSStephan Aßmus error = volumeManager->MountRootVolume(device,
1985a1d355fSStephan Aßmus (const char*)parameters, len, &rootVolume);
1995a1d355fSStephan Aßmus if (error != B_OK) {
2005a1d355fSStephan Aßmus delete volumeManager;
2015a1d355fSStephan Aßmus volumeManager = NULL;
2025a1d355fSStephan Aßmus }
2035a1d355fSStephan Aßmus } else
2045a1d355fSStephan Aßmus error = B_NO_MEMORY;
2055a1d355fSStephan Aßmus VolumePutter _(rootVolume);
2065a1d355fSStephan Aßmus
2075a1d355fSStephan Aßmus // set results
2085a1d355fSStephan Aßmus if (error == B_OK) {
2095a1d355fSStephan Aßmus *data = volumeManager;
2105a1d355fSStephan Aßmus *rootID = rootVolume->GetRootID();
2115a1d355fSStephan Aßmus } else {
2125a1d355fSStephan Aßmus #ifdef DEBUG_OBJECT_TRACKING
2135a1d355fSStephan Aßmus ObjectTracker::ExitDefault();
2145a1d355fSStephan Aßmus #endif
2155a1d355fSStephan Aßmus exit_debugging();
2165a1d355fSStephan Aßmus }
2175a1d355fSStephan Aßmus return error;
2185a1d355fSStephan Aßmus }
2195a1d355fSStephan Aßmus
2205a1d355fSStephan Aßmus // netfs_unmount
2215a1d355fSStephan Aßmus static
2225a1d355fSStephan Aßmus int
netfs_unmount(void * ns)2235a1d355fSStephan Aßmus netfs_unmount(void *ns)
2245a1d355fSStephan Aßmus {
2255a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
2265a1d355fSStephan Aßmus
2273c1afd35SPawel Dziepak PRINT("netfs_unmount()\n");
2285a1d355fSStephan Aßmus
2295a1d355fSStephan Aßmus volumeManager->UnmountRootVolume();
2305a1d355fSStephan Aßmus delete volumeManager;
2315a1d355fSStephan Aßmus
2325a1d355fSStephan Aßmus #ifdef DEBUG_OBJECT_TRACKING
2335a1d355fSStephan Aßmus ObjectTracker::ExitDefault();
2345a1d355fSStephan Aßmus #endif
2355a1d355fSStephan Aßmus
2363c1afd35SPawel Dziepak PRINT("netfs_unmount() done\n");
2375a1d355fSStephan Aßmus
2385a1d355fSStephan Aßmus exit_debugging();
2395a1d355fSStephan Aßmus return B_OK;
2405a1d355fSStephan Aßmus }
2415a1d355fSStephan Aßmus
2420ea1aab2SOliver Tappe #if 0 // not used
2430ea1aab2SOliver Tappe
2445a1d355fSStephan Aßmus // netfs_sync
2455a1d355fSStephan Aßmus static
2465a1d355fSStephan Aßmus int
2475a1d355fSStephan Aßmus netfs_sync(void *ns)
2485a1d355fSStephan Aßmus {
2495a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
2505a1d355fSStephan Aßmus Volume* volume = volumeManager->GetRootVolume();
2515a1d355fSStephan Aßmus VolumePutter _(volume);
2525a1d355fSStephan Aßmus
2533c1afd35SPawel Dziepak PRINT("netfs_sync(%p)\n", ns);
2545a1d355fSStephan Aßmus
2555a1d355fSStephan Aßmus status_t error = B_BAD_VALUE;
2565a1d355fSStephan Aßmus if (volume)
2575a1d355fSStephan Aßmus error = volume->Sync();
2585a1d355fSStephan Aßmus
2594cfa5b2dSJérôme Duval PRINT("netfs_sync() done: %" B_PRIx32 " \n", error);
2605a1d355fSStephan Aßmus
2615a1d355fSStephan Aßmus return error;
2625a1d355fSStephan Aßmus }
2635a1d355fSStephan Aßmus
2640ea1aab2SOliver Tappe #endif
2650ea1aab2SOliver Tappe
2665a1d355fSStephan Aßmus // netfs_read_fs_stat
2675a1d355fSStephan Aßmus static
2685a1d355fSStephan Aßmus int
netfs_read_fs_stat(void * ns,struct fs_info * info)2695a1d355fSStephan Aßmus netfs_read_fs_stat(void *ns, struct fs_info *info)
2705a1d355fSStephan Aßmus {
2715a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
2725a1d355fSStephan Aßmus Volume* volume = volumeManager->GetRootVolume();
2735a1d355fSStephan Aßmus VolumePutter _(volume);
2745a1d355fSStephan Aßmus
2753c1afd35SPawel Dziepak PRINT("netfs_read_fs_stat(%p, %p)\n", ns, info);
2765a1d355fSStephan Aßmus
2775a1d355fSStephan Aßmus status_t error = B_BAD_VALUE;
2785a1d355fSStephan Aßmus if (volume)
2795a1d355fSStephan Aßmus error = volume->ReadFSStat(info);
2805a1d355fSStephan Aßmus
2814cfa5b2dSJérôme Duval PRINT("netfs_read_fs_stat() done: %" B_PRIx32 " \n", error);
2825a1d355fSStephan Aßmus
2835a1d355fSStephan Aßmus return error;
2845a1d355fSStephan Aßmus }
2855a1d355fSStephan Aßmus
2860ea1aab2SOliver Tappe #if 0 // not used
2870ea1aab2SOliver Tappe
2885a1d355fSStephan Aßmus // netfs_write_fs_stat
2895a1d355fSStephan Aßmus static
2905a1d355fSStephan Aßmus int
2915a1d355fSStephan Aßmus netfs_write_fs_stat(void *ns, struct fs_info *info, long mask)
2925a1d355fSStephan Aßmus {
2935a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
2945a1d355fSStephan Aßmus Volume* volume = volumeManager->GetRootVolume();
2955a1d355fSStephan Aßmus VolumePutter _(volume);
2965a1d355fSStephan Aßmus
2973c1afd35SPawel Dziepak PRINT("netfs_write_fs_stat(%p, %p, %ld)\n", ns, info, mask);
2985a1d355fSStephan Aßmus
2995a1d355fSStephan Aßmus status_t error = B_BAD_VALUE;
3005a1d355fSStephan Aßmus if (volume)
3015a1d355fSStephan Aßmus error = volume->WriteFSStat(info, mask);
3025a1d355fSStephan Aßmus
3034cfa5b2dSJérôme Duval PRINT("netfs_write_fs_stat() done: %" B_PRIx32 " \n", error);
3045a1d355fSStephan Aßmus
3055a1d355fSStephan Aßmus return error;
3065a1d355fSStephan Aßmus }
3075a1d355fSStephan Aßmus
3080ea1aab2SOliver Tappe #endif
3090ea1aab2SOliver Tappe
3105a1d355fSStephan Aßmus // #pragma mark -
3115a1d355fSStephan Aßmus // #pragma mark ----- vnodes -----
3125a1d355fSStephan Aßmus
3135a1d355fSStephan Aßmus // netfs_read_vnode
3145a1d355fSStephan Aßmus static
3155a1d355fSStephan Aßmus int
netfs_read_vnode(void * ns,vnode_id vnid,char reenter,void ** node)3165a1d355fSStephan Aßmus netfs_read_vnode(void *ns, vnode_id vnid, char reenter, void **node)
3175a1d355fSStephan Aßmus {
3185a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
3195a1d355fSStephan Aßmus Volume* volume = volumeManager->GetVolume(vnid);
3205a1d355fSStephan Aßmus VolumePutter _(volume);
3215a1d355fSStephan Aßmus
3224cfa5b2dSJérôme Duval PRINT("netfs_read_vnode(%p, %" B_PRIdINO ", %d, %p)\n", ns, vnid, reenter,
3234cfa5b2dSJérôme Duval node);
3245a1d355fSStephan Aßmus
3255a1d355fSStephan Aßmus status_t error = B_BAD_VALUE;
3265a1d355fSStephan Aßmus if (volume)
3275a1d355fSStephan Aßmus error = volume->ReadVNode(vnid, reenter, (Node**)node);
3285a1d355fSStephan Aßmus
3294cfa5b2dSJérôme Duval PRINT("netfs_read_vnode() done: (%" B_PRIx32 ", %p)\n", error, *node);
3305a1d355fSStephan Aßmus
3315a1d355fSStephan Aßmus return error;
3325a1d355fSStephan Aßmus }
3335a1d355fSStephan Aßmus
3345a1d355fSStephan Aßmus // netfs_write_vnode
3355a1d355fSStephan Aßmus static
3365a1d355fSStephan Aßmus int
netfs_write_vnode(void * ns,void * _node,char reenter)3375a1d355fSStephan Aßmus netfs_write_vnode(void *ns, void *_node, char reenter)
3385a1d355fSStephan Aßmus {
3395a1d355fSStephan Aßmus Node* node = (Node*)_node;
3405a1d355fSStephan Aßmus // DANGER: If dbg_printf() is used, this thread will enter another FS and
3415a1d355fSStephan Aßmus // even perform a write operation. The is dangerous here, since this hook
3425a1d355fSStephan Aßmus // may be called out of the other FSs, since, for instance a put_vnode()
3435a1d355fSStephan Aßmus // called from another FS may cause the VFS layer to free vnodes and thus
3445a1d355fSStephan Aßmus // invoke this hook.
3455a1d355fSStephan Aßmus // PRINT(("netfs_write_vnode(%p, %p, %d)\n", ns, node, reenter));
3465a1d355fSStephan Aßmus status_t error = node->GetVolume()->WriteVNode(node, reenter);
3474cfa5b2dSJérôme Duval // PRINT(("netfs_write_vnode() done: %" B_PRIx32 "\n", error));
3485a1d355fSStephan Aßmus return error;
3495a1d355fSStephan Aßmus }
3505a1d355fSStephan Aßmus
3515a1d355fSStephan Aßmus // netfs_remove_vnode
3525a1d355fSStephan Aßmus static
3535a1d355fSStephan Aßmus int
netfs_remove_vnode(void * ns,void * _node,char reenter)3545a1d355fSStephan Aßmus netfs_remove_vnode(void *ns, void *_node, char reenter)
3555a1d355fSStephan Aßmus {
3565a1d355fSStephan Aßmus Node* node = (Node*)_node;
3575a1d355fSStephan Aßmus // DANGER: See netfs_write_vnode().
3585a1d355fSStephan Aßmus // PRINT(("netfs_remove_vnode(%p, %p, %d)\n", ns, node, reenter));
3595a1d355fSStephan Aßmus status_t error = node->GetVolume()->RemoveVNode(node, reenter);
3604cfa5b2dSJérôme Duval // PRINT(("netfs_remove_vnode() done: %" B_PRIx32 "\n", error));
3615a1d355fSStephan Aßmus return error;
3625a1d355fSStephan Aßmus }
3635a1d355fSStephan Aßmus
3645a1d355fSStephan Aßmus // #pragma mark -
3655a1d355fSStephan Aßmus // #pragma mark ----- nodes -----
3665a1d355fSStephan Aßmus
3670ea1aab2SOliver Tappe #if 0 // not used
3680ea1aab2SOliver Tappe
3695a1d355fSStephan Aßmus // netfs_fsync
3705a1d355fSStephan Aßmus static
3715a1d355fSStephan Aßmus int
3725a1d355fSStephan Aßmus netfs_fsync(void *ns, void *_node)
3735a1d355fSStephan Aßmus {
3745a1d355fSStephan Aßmus Node* node = (Node*)_node;
3753c1afd35SPawel Dziepak PRINT("netfs_fsync(%p, %p)\n", ns, node);
3765a1d355fSStephan Aßmus status_t error = node->GetVolume()->FSync(node);
3774cfa5b2dSJérôme Duval PRINT("netfs_fsync() done: %" B_PRIx32 "\n", error);
3785a1d355fSStephan Aßmus return error;
3795a1d355fSStephan Aßmus }
3805a1d355fSStephan Aßmus
3810ea1aab2SOliver Tappe #endif
3820ea1aab2SOliver Tappe
3835a1d355fSStephan Aßmus // netfs_read_stat
3845a1d355fSStephan Aßmus static
3855a1d355fSStephan Aßmus int
netfs_read_stat(void * ns,void * _node,struct stat * st)3865a1d355fSStephan Aßmus netfs_read_stat(void *ns, void *_node, struct stat *st)
3875a1d355fSStephan Aßmus {
3885a1d355fSStephan Aßmus Node* node = (Node*)_node;
3893c1afd35SPawel Dziepak PRINT("netfs_read_stat(%p, %p, %p)\n", ns, node, st);
3905a1d355fSStephan Aßmus status_t error = node->GetVolume()->ReadStat(node, st);
3914cfa5b2dSJérôme Duval PRINT("netfs_read_stat() done: %" B_PRIx32 "\n", error);
3925a1d355fSStephan Aßmus return error;
3935a1d355fSStephan Aßmus }
3945a1d355fSStephan Aßmus
3955a1d355fSStephan Aßmus // netfs_write_stat
3965a1d355fSStephan Aßmus static
3975a1d355fSStephan Aßmus int
netfs_write_stat(void * ns,void * _node,struct stat * st,long mask)3985a1d355fSStephan Aßmus netfs_write_stat(void *ns, void *_node, struct stat *st, long mask)
3995a1d355fSStephan Aßmus {
4005a1d355fSStephan Aßmus Node* node = (Node*)_node;
4013c1afd35SPawel Dziepak PRINT("netfs_write_stat(%p, %p, %p, %ld)\n", ns, node, st, mask);
4025a1d355fSStephan Aßmus status_t error = node->GetVolume()->WriteStat(node, st, mask);
4034cfa5b2dSJérôme Duval PRINT("netfs_write_stat() done: %" B_PRIx32 "\n", error);
4045a1d355fSStephan Aßmus return error;
4055a1d355fSStephan Aßmus }
4065a1d355fSStephan Aßmus
4075a1d355fSStephan Aßmus // netfs_access
4085a1d355fSStephan Aßmus static
4095a1d355fSStephan Aßmus int
netfs_access(void * ns,void * _node,int mode)4105a1d355fSStephan Aßmus netfs_access(void *ns, void *_node, int mode)
4115a1d355fSStephan Aßmus {
4125a1d355fSStephan Aßmus Node* node = (Node*)_node;
4133c1afd35SPawel Dziepak PRINT("netfs_access(%p, %p, %d)\n", ns, node, mode);
4145a1d355fSStephan Aßmus status_t error = node->GetVolume()->Access(node, mode);
4154cfa5b2dSJérôme Duval PRINT("netfs_access() done: %" B_PRIx32 "\n", error);
4165a1d355fSStephan Aßmus return error;
4175a1d355fSStephan Aßmus }
4185a1d355fSStephan Aßmus
4195a1d355fSStephan Aßmus // #pragma mark -
4205a1d355fSStephan Aßmus // #pragma mark ----- files -----
4215a1d355fSStephan Aßmus
4225a1d355fSStephan Aßmus // netfs_create
4235a1d355fSStephan Aßmus static
4245a1d355fSStephan Aßmus int
netfs_create(void * ns,void * _dir,const char * name,int openMode,int mode,vnode_id * vnid,void ** cookie)4255a1d355fSStephan Aßmus netfs_create(void *ns, void *_dir, const char *name, int openMode, int mode,
4265a1d355fSStephan Aßmus vnode_id *vnid, void **cookie)
4275a1d355fSStephan Aßmus {
4285a1d355fSStephan Aßmus Node* dir = (Node*)_dir;
4293c1afd35SPawel Dziepak PRINT("netfs_create(%p, %p, `%s', %d, %d, %p, %p)\n", ns, dir,
4303c1afd35SPawel Dziepak name, openMode, mode, vnid, cookie);
4315a1d355fSStephan Aßmus status_t error = dir->GetVolume()->Create(dir, name, openMode, mode, vnid,
4325a1d355fSStephan Aßmus cookie);
4334cfa5b2dSJérôme Duval PRINT("netfs_create() done: (%" B_PRIx32 ", %" B_PRIdINO ", %p)\n", error, *vnid,
4343c1afd35SPawel Dziepak *cookie);
4355a1d355fSStephan Aßmus return error;
4365a1d355fSStephan Aßmus }
4375a1d355fSStephan Aßmus
4385a1d355fSStephan Aßmus // netfs_open
4395a1d355fSStephan Aßmus static
4405a1d355fSStephan Aßmus int
netfs_open(void * ns,void * _node,int openMode,void ** cookie)4415a1d355fSStephan Aßmus netfs_open(void *ns, void *_node, int openMode, void **cookie)
4425a1d355fSStephan Aßmus {
4435a1d355fSStephan Aßmus Node* node = (Node*)_node;
4443c1afd35SPawel Dziepak PRINT("netfs_open(%p, %p, %d)\n", ns, node, openMode);
4455a1d355fSStephan Aßmus status_t error = node->GetVolume()->Open(node, openMode, cookie);
4464cfa5b2dSJérôme Duval PRINT("netfs_open() done: (%" B_PRIx32 ", %p)\n", error, *cookie);
4475a1d355fSStephan Aßmus return error;
4485a1d355fSStephan Aßmus }
4495a1d355fSStephan Aßmus
4505a1d355fSStephan Aßmus // netfs_close
4515a1d355fSStephan Aßmus static
4525a1d355fSStephan Aßmus int
netfs_close(void * ns,void * _node,void * cookie)4535a1d355fSStephan Aßmus netfs_close(void *ns, void *_node, void *cookie)
4545a1d355fSStephan Aßmus {
4555a1d355fSStephan Aßmus Node* node = (Node*)_node;
4563c1afd35SPawel Dziepak PRINT("netfs_close(%p, %p, %p)\n", ns, node, cookie);
4575a1d355fSStephan Aßmus status_t error = node->GetVolume()->Close(node, cookie);
4584cfa5b2dSJérôme Duval PRINT("netfs_close() done: %" B_PRIx32 "\n", error);
4595a1d355fSStephan Aßmus return error;
4605a1d355fSStephan Aßmus }
4615a1d355fSStephan Aßmus
4625a1d355fSStephan Aßmus // netfs_free_cookie
4635a1d355fSStephan Aßmus static
4645a1d355fSStephan Aßmus int
netfs_free_cookie(void * ns,void * _node,void * cookie)4655a1d355fSStephan Aßmus netfs_free_cookie(void *ns, void *_node, void *cookie)
4665a1d355fSStephan Aßmus {
4675a1d355fSStephan Aßmus Node* node = (Node*)_node;
4683c1afd35SPawel Dziepak PRINT("netfs_free_cookie(%p, %p, %p)\n", ns, node, cookie);
4695a1d355fSStephan Aßmus status_t error = node->GetVolume()->FreeCookie(node, cookie);
4704cfa5b2dSJérôme Duval PRINT("netfs_free_cookie() done: %" B_PRIx32 "\n", error);
4715a1d355fSStephan Aßmus return error;
4725a1d355fSStephan Aßmus }
4735a1d355fSStephan Aßmus
4745a1d355fSStephan Aßmus // netfs_read
4755a1d355fSStephan Aßmus static
4765a1d355fSStephan Aßmus int
netfs_read(void * ns,void * _node,void * cookie,off_t pos,void * buffer,size_t * bufferSize)4775a1d355fSStephan Aßmus netfs_read(void *ns, void *_node, void *cookie, off_t pos, void *buffer,
4785a1d355fSStephan Aßmus size_t *bufferSize)
4795a1d355fSStephan Aßmus {
4805a1d355fSStephan Aßmus Node* node = (Node*)_node;
4814cfa5b2dSJérôme Duval PRINT("netfs_read(%p, %p, %p, %" B_PRIdOFF ", %p, %lu)\n", ns, node,
4824cfa5b2dSJérôme Duval cookie, pos, buffer, *bufferSize);
4835a1d355fSStephan Aßmus status_t error = node->GetVolume()->Read(node, cookie, pos, buffer,
4845a1d355fSStephan Aßmus *bufferSize, bufferSize);
4854cfa5b2dSJérôme Duval PRINT("netfs_read() done: (%" B_PRIx32 ", %lu)\n", error, *bufferSize);
4865a1d355fSStephan Aßmus return error;
4875a1d355fSStephan Aßmus }
4885a1d355fSStephan Aßmus
4895a1d355fSStephan Aßmus // netfs_write
4905a1d355fSStephan Aßmus static
4915a1d355fSStephan Aßmus int
netfs_write(void * ns,void * _node,void * cookie,off_t pos,const void * buffer,size_t * bufferSize)4925a1d355fSStephan Aßmus netfs_write(void *ns, void *_node, void *cookie, off_t pos,
4935a1d355fSStephan Aßmus const void *buffer, size_t *bufferSize)
4945a1d355fSStephan Aßmus {
4955a1d355fSStephan Aßmus Node* node = (Node*)_node;
4964cfa5b2dSJérôme Duval PRINT("netfs_write(%p, %p, %p, %" B_PRIdOFF ", %p, %lu)\n", ns, node,
4974cfa5b2dSJérôme Duval cookie, pos, buffer, *bufferSize);
4985a1d355fSStephan Aßmus status_t error = node->GetVolume()->Write(node, cookie, pos, buffer,
4995a1d355fSStephan Aßmus *bufferSize, bufferSize);
5004cfa5b2dSJérôme Duval PRINT("netfs_write() done: (%" B_PRIx32 ", %lu)\n", error, *bufferSize);
5015a1d355fSStephan Aßmus return error;
5025a1d355fSStephan Aßmus }
5035a1d355fSStephan Aßmus
5045a1d355fSStephan Aßmus // netfs_ioctl
5055a1d355fSStephan Aßmus static
5065a1d355fSStephan Aßmus int
netfs_ioctl(void * ns,void * _node,void * cookie,int cmd,void * buffer,size_t bufferSize)5075a1d355fSStephan Aßmus netfs_ioctl(void *ns, void *_node, void *cookie, int cmd, void *buffer,
5085a1d355fSStephan Aßmus size_t bufferSize)
5095a1d355fSStephan Aßmus {
5105a1d355fSStephan Aßmus Node* node = (Node*)_node;
5113c1afd35SPawel Dziepak PRINT("netfs_ioctl(%p, %p, %p, %d, %p, %lu)\n", ns, node, cookie, cmd,
5123c1afd35SPawel Dziepak buffer, bufferSize);
5135a1d355fSStephan Aßmus status_t error = node->GetVolume()->IOCtl(node, cookie, cmd, buffer,
5145a1d355fSStephan Aßmus bufferSize);
5154cfa5b2dSJérôme Duval PRINT("netfs_ioctl() done: (%" B_PRIx32 ")\n", error);
5165a1d355fSStephan Aßmus return error;
5175a1d355fSStephan Aßmus }
5185a1d355fSStephan Aßmus
5195a1d355fSStephan Aßmus // netfs_setflags
5205a1d355fSStephan Aßmus //static
5215a1d355fSStephan Aßmus //int
5225a1d355fSStephan Aßmus //netfs_setflags(void *ns, void *_node, void *cookie, int flags)
5235a1d355fSStephan Aßmus //{
5245a1d355fSStephan Aßmus // Node* node = (Node*)_node;
5255a1d355fSStephan Aßmus // PRINT(("netfs_setflags(%p, %p, %p, %d)\n", ns, node, cookie, flags));
5265a1d355fSStephan Aßmus // status_t error = node->GetVolume()->SetFlags(node, cookie, flags);
5275a1d355fSStephan Aßmus // PRINT(("netfs_setflags() done: (%lx)\n", error));
5285a1d355fSStephan Aßmus // return error;
5295a1d355fSStephan Aßmus //}
5305a1d355fSStephan Aßmus
5315a1d355fSStephan Aßmus // #pragma mark -
5325a1d355fSStephan Aßmus // #pragma mark ----- hard links / symlinks -----
5335a1d355fSStephan Aßmus
5345a1d355fSStephan Aßmus // netfs_link
5355a1d355fSStephan Aßmus static
5365a1d355fSStephan Aßmus int
netfs_link(void * ns,void * _dir,const char * name,void * _node)5375a1d355fSStephan Aßmus netfs_link(void *ns, void *_dir, const char *name, void *_node)
5385a1d355fSStephan Aßmus {
5395a1d355fSStephan Aßmus Node* dir = (Node*)_dir;
5405a1d355fSStephan Aßmus Node* node = (Node*)_node;
5413c1afd35SPawel Dziepak PRINT("netfs_link(%p, %p, `%s', %p)\n", ns, dir, name, node);
5425a1d355fSStephan Aßmus status_t error = dir->GetVolume()->Link(dir, name, node);
5434cfa5b2dSJérôme Duval PRINT("netfs_link() done: (%" B_PRIx32 ")\n", error);
5445a1d355fSStephan Aßmus return error;
5455a1d355fSStephan Aßmus }
5465a1d355fSStephan Aßmus
5475a1d355fSStephan Aßmus // netfs_unlink
5485a1d355fSStephan Aßmus static
5495a1d355fSStephan Aßmus int
netfs_unlink(void * ns,void * _dir,const char * name)5505a1d355fSStephan Aßmus netfs_unlink(void *ns, void *_dir, const char *name)
5515a1d355fSStephan Aßmus {
5525a1d355fSStephan Aßmus Node* dir = (Node*)_dir;
5533c1afd35SPawel Dziepak PRINT("netfs_unlink(%p, %p, `%s')\n", ns, dir, name);
5545a1d355fSStephan Aßmus status_t error = dir->GetVolume()->Unlink(dir, name);
5554cfa5b2dSJérôme Duval PRINT("netfs_unlink() done: (%" B_PRIx32 ")\n", error);
5565a1d355fSStephan Aßmus return error;
5575a1d355fSStephan Aßmus }
5585a1d355fSStephan Aßmus
5595a1d355fSStephan Aßmus // netfs_symlink
5605a1d355fSStephan Aßmus static
5615a1d355fSStephan Aßmus int
netfs_symlink(void * ns,void * _dir,const char * name,const char * path)5625a1d355fSStephan Aßmus netfs_symlink(void *ns, void *_dir, const char *name, const char *path)
5635a1d355fSStephan Aßmus {
5645a1d355fSStephan Aßmus Node* dir = (Node*)_dir;
5653c1afd35SPawel Dziepak PRINT("netfs_symlink(%p, %p, `%s', `%s')\n", ns, dir, name, path);
5665a1d355fSStephan Aßmus status_t error = dir->GetVolume()->Symlink(dir, name, path);
5674cfa5b2dSJérôme Duval PRINT("netfs_symlink() done: (%" B_PRIx32 ")\n", error);
5685a1d355fSStephan Aßmus return error;
5695a1d355fSStephan Aßmus }
5705a1d355fSStephan Aßmus
5715a1d355fSStephan Aßmus // netfs_read_link
5725a1d355fSStephan Aßmus static
5735a1d355fSStephan Aßmus int
netfs_read_link(void * ns,void * _node,char * buffer,size_t * bufferSize)5745a1d355fSStephan Aßmus netfs_read_link(void *ns, void *_node, char *buffer, size_t *bufferSize)
5755a1d355fSStephan Aßmus {
5765a1d355fSStephan Aßmus Node* node = (Node*)_node;
5773c1afd35SPawel Dziepak PRINT("netfs_read_link(%p, %p, %p, %lu)\n", ns, node, buffer,
5783c1afd35SPawel Dziepak *bufferSize);
579*e1b7c1c7SKyle Ambroff-Kao
580*e1b7c1c7SKyle Ambroff-Kao // TODO: If this were to be implemented (which it isn't, it currently just
581*e1b7c1c7SKyle Ambroff-Kao // returns B_BAD_VALUE) then this will need to be changed to return the
582*e1b7c1c7SKyle Ambroff-Kao // length of the node and not the number of bytes read into buffer.
5835a1d355fSStephan Aßmus status_t error = node->GetVolume()->ReadLink(node, buffer, *bufferSize,
5845a1d355fSStephan Aßmus bufferSize);
5854cfa5b2dSJérôme Duval PRINT("netfs_read_link() done: (%" B_PRIx32 ", %lu)\n", error,
5864cfa5b2dSJérôme Duval *bufferSize);
5875a1d355fSStephan Aßmus return error;
5885a1d355fSStephan Aßmus }
5895a1d355fSStephan Aßmus
5905a1d355fSStephan Aßmus // netfs_rename
5915a1d355fSStephan Aßmus static
5925a1d355fSStephan Aßmus int
netfs_rename(void * ns,void * _oldDir,const char * oldName,void * _newDir,const char * newName)5935a1d355fSStephan Aßmus netfs_rename(void *ns, void *_oldDir, const char *oldName, void *_newDir,
5945a1d355fSStephan Aßmus const char *newName)
5955a1d355fSStephan Aßmus {
5965a1d355fSStephan Aßmus Node* oldDir = (Node*)_oldDir;
5975a1d355fSStephan Aßmus Node* newDir = (Node*)_newDir;
5983c1afd35SPawel Dziepak PRINT("netfs_rename(%p, %p, `%s', %p, `%s')\n", ns, oldDir, oldName,
5993c1afd35SPawel Dziepak newDir, newName);
6005a1d355fSStephan Aßmus status_t error = oldDir->GetVolume()->Rename(oldDir, oldName,
6015a1d355fSStephan Aßmus newDir, newName);
6024cfa5b2dSJérôme Duval PRINT("netfs_rename() done: (%" B_PRIx32 ")\n", error);
6035a1d355fSStephan Aßmus return error;
6045a1d355fSStephan Aßmus }
6055a1d355fSStephan Aßmus
6065a1d355fSStephan Aßmus // #pragma mark -
6075a1d355fSStephan Aßmus // #pragma mark ----- directories -----
6085a1d355fSStephan Aßmus
6095a1d355fSStephan Aßmus // netfs_mkdir
6105a1d355fSStephan Aßmus static
6115a1d355fSStephan Aßmus int
netfs_mkdir(void * ns,void * _dir,const char * name,int mode)6125a1d355fSStephan Aßmus netfs_mkdir(void *ns, void *_dir, const char *name, int mode)
6135a1d355fSStephan Aßmus {
6145a1d355fSStephan Aßmus Node* dir = (Node*)_dir;
6153c1afd35SPawel Dziepak PRINT("netfs_mkdir(%p, %p, `%s', %d)\n", ns, dir, name, mode);
6165a1d355fSStephan Aßmus status_t error = dir->GetVolume()->MkDir(dir, name, mode);
6174cfa5b2dSJérôme Duval PRINT("netfs_mkdir() done: (%" B_PRIx32 ")\n", error);
6185a1d355fSStephan Aßmus return error;
6195a1d355fSStephan Aßmus }
6205a1d355fSStephan Aßmus
6215a1d355fSStephan Aßmus // netfs_rmdir
6225a1d355fSStephan Aßmus static
6235a1d355fSStephan Aßmus int
netfs_rmdir(void * ns,void * _dir,const char * name)6245a1d355fSStephan Aßmus netfs_rmdir(void *ns, void *_dir, const char *name)
6255a1d355fSStephan Aßmus {
6265a1d355fSStephan Aßmus Node* dir = (Node*)_dir;
6273c1afd35SPawel Dziepak PRINT("netfs_rmdir(%p, %p, `%s')\n", ns, dir, name);
6285a1d355fSStephan Aßmus status_t error = dir->GetVolume()->RmDir(dir, name);
6294cfa5b2dSJérôme Duval PRINT("netfs_rmdir() done: (%" B_PRIx32 ")\n", error);
6305a1d355fSStephan Aßmus return error;
6315a1d355fSStephan Aßmus }
6325a1d355fSStephan Aßmus
6335a1d355fSStephan Aßmus // netfs_open_dir
6345a1d355fSStephan Aßmus static
6355a1d355fSStephan Aßmus int
netfs_open_dir(void * ns,void * _node,void ** cookie)6365a1d355fSStephan Aßmus netfs_open_dir(void *ns, void *_node, void **cookie)
6375a1d355fSStephan Aßmus {
6385a1d355fSStephan Aßmus Node* node = (Node*)_node;
6393c1afd35SPawel Dziepak PRINT("netfs_open_dir(%p, %p)\n", ns, node);
6405a1d355fSStephan Aßmus status_t error = node->GetVolume()->OpenDir(node, cookie);
6414cfa5b2dSJérôme Duval PRINT("netfs_open_dir() done: (%" B_PRIx32 ", %p)\n", error, *cookie);
6425a1d355fSStephan Aßmus return error;
6435a1d355fSStephan Aßmus }
6445a1d355fSStephan Aßmus
6455a1d355fSStephan Aßmus // netfs_close_dir
6465a1d355fSStephan Aßmus static
6475a1d355fSStephan Aßmus int
netfs_close_dir(void * ns,void * _node,void * cookie)6485a1d355fSStephan Aßmus netfs_close_dir(void *ns, void *_node, void *cookie)
6495a1d355fSStephan Aßmus {
6505a1d355fSStephan Aßmus Node* node = (Node*)_node;
6513c1afd35SPawel Dziepak PRINT("netfs_close_dir(%p, %p, %p)\n", ns, node, cookie);
6525a1d355fSStephan Aßmus status_t error = node->GetVolume()->CloseDir(node, cookie);
6534cfa5b2dSJérôme Duval PRINT("netfs_close_dir() done: %" B_PRIx32 "\n", error);
6545a1d355fSStephan Aßmus return error;
6555a1d355fSStephan Aßmus }
6565a1d355fSStephan Aßmus
6575a1d355fSStephan Aßmus // netfs_free_dir_cookie
6585a1d355fSStephan Aßmus static
6595a1d355fSStephan Aßmus int
netfs_free_dir_cookie(void * ns,void * _node,void * cookie)6605a1d355fSStephan Aßmus netfs_free_dir_cookie(void *ns, void *_node, void *cookie)
6615a1d355fSStephan Aßmus {
6625a1d355fSStephan Aßmus Node* node = (Node*)_node;
6633c1afd35SPawel Dziepak PRINT("netfs_free_dir_cookie(%p, %p, %p)\n", ns, node, cookie);
6645a1d355fSStephan Aßmus status_t error = node->GetVolume()->FreeDirCookie(node, cookie);
6654cfa5b2dSJérôme Duval PRINT("netfs_free_dir_cookie() done: %" B_PRIx32 " \n", error);
6665a1d355fSStephan Aßmus return error;
6675a1d355fSStephan Aßmus }
6685a1d355fSStephan Aßmus
6695a1d355fSStephan Aßmus // netfs_read_dir
6705a1d355fSStephan Aßmus static
6715a1d355fSStephan Aßmus int
netfs_read_dir(void * ns,void * _node,void * cookie,long * count,struct dirent * buffer,size_t bufferSize)6725a1d355fSStephan Aßmus netfs_read_dir(void *ns, void *_node, void *cookie, long *count,
6735a1d355fSStephan Aßmus struct dirent *buffer, size_t bufferSize)
6745a1d355fSStephan Aßmus {
6755a1d355fSStephan Aßmus Node* node = (Node*)_node;
6763c1afd35SPawel Dziepak PRINT("netfs_read_dir(%p, %p, %p, %ld, %p, %lu)\n", ns, node, cookie,
6773c1afd35SPawel Dziepak *count, buffer, bufferSize);
67820f046edSJérôme Duval int32 _count = *count;
6795a1d355fSStephan Aßmus status_t error = node->GetVolume()->ReadDir(node, cookie, buffer,
68020f046edSJérôme Duval bufferSize, _count, &_count);
68120f046edSJérôme Duval *count = _count;
6824cfa5b2dSJérôme Duval PRINT("netfs_read_dir() done: (%" B_PRIx32 ", %ld)\n", error, *count);
6835a1d355fSStephan Aßmus #if DEBUG
6845a1d355fSStephan Aßmus dirent* entry = buffer;
6855a1d355fSStephan Aßmus for (int32 i = 0; i < *count; i++) {
6865a1d355fSStephan Aßmus // R5's kernel vsprintf() doesn't seem to know `%.<number>s', so
6875a1d355fSStephan Aßmus // we need to work around.
6885a1d355fSStephan Aßmus char name[B_FILE_NAME_LENGTH];
6895a1d355fSStephan Aßmus int nameLen = strnlen(entry->d_name, B_FILE_NAME_LENGTH - 1);
6905a1d355fSStephan Aßmus strncpy(name, entry->d_name, nameLen);
6915a1d355fSStephan Aßmus name[nameLen] = '\0';
6924cfa5b2dSJérôme Duval PRINT(" entry: d_dev: %" B_PRIdDEV ", d_pdev: %" B_PRIdDEV
6934cfa5b2dSJérôme Duval ", d_ino: %" B_PRIdINO ", d_pino: %" B_PRIdINO
6944cfa5b2dSJérôme Duval ", d_reclen: %hu, d_name: `%s'\n",
6953c1afd35SPawel Dziepak entry->d_dev, entry->d_pdev, entry->d_ino,
6963c1afd35SPawel Dziepak entry->d_pino, entry->d_reclen, name);
6975a1d355fSStephan Aßmus entry = (dirent*)((char*)entry + entry->d_reclen);
6985a1d355fSStephan Aßmus }
6995a1d355fSStephan Aßmus #endif
7005a1d355fSStephan Aßmus
7015a1d355fSStephan Aßmus return error;
7025a1d355fSStephan Aßmus }
7035a1d355fSStephan Aßmus
7045a1d355fSStephan Aßmus // netfs_rewind_dir
7055a1d355fSStephan Aßmus static
7065a1d355fSStephan Aßmus int
netfs_rewind_dir(void * ns,void * _node,void * cookie)7075a1d355fSStephan Aßmus netfs_rewind_dir(void *ns, void *_node, void *cookie)
7085a1d355fSStephan Aßmus {
7095a1d355fSStephan Aßmus Node* node = (Node*)_node;
7103c1afd35SPawel Dziepak PRINT("netfs_rewind_dir(%p, %p, %p)\n", ns, node, cookie);
7115a1d355fSStephan Aßmus status_t error = node->GetVolume()->RewindDir(node, cookie);
7124cfa5b2dSJérôme Duval PRINT("netfs_rewind_dir() done: %" B_PRIx32 "\n", error);
7135a1d355fSStephan Aßmus return error;
7145a1d355fSStephan Aßmus }
7155a1d355fSStephan Aßmus
7165a1d355fSStephan Aßmus // netfs_walk
7175a1d355fSStephan Aßmus static
7185a1d355fSStephan Aßmus int
netfs_walk(void * ns,void * _dir,const char * entryName,char ** resolvedPath,vnode_id * vnid)7195a1d355fSStephan Aßmus netfs_walk(void *ns, void *_dir, const char *entryName,
7205a1d355fSStephan Aßmus char **resolvedPath, vnode_id *vnid)
7215a1d355fSStephan Aßmus {
7225a1d355fSStephan Aßmus Node* dir = (Node*)_dir;
7233c1afd35SPawel Dziepak PRINT("netfs_walk(%p, %p, `%s', %p, %p)\n", ns, dir,
7243c1afd35SPawel Dziepak entryName, resolvedPath, vnid);
7255a1d355fSStephan Aßmus status_t error = dir->GetVolume()->Walk(dir, entryName, resolvedPath, vnid);
7264cfa5b2dSJérôme Duval PRINT("netfs_walk() done: (%" B_PRIx32 ", `%s', %" B_PRIdINO ")\n", error,
7273c1afd35SPawel Dziepak (resolvedPath ? *resolvedPath : NULL), *vnid);
7285a1d355fSStephan Aßmus return error;
7295a1d355fSStephan Aßmus }
7305a1d355fSStephan Aßmus
7315a1d355fSStephan Aßmus // #pragma mark -
7325a1d355fSStephan Aßmus // #pragma mark ----- attributes -----
7335a1d355fSStephan Aßmus
7345a1d355fSStephan Aßmus // netfs_open_attrdir
7355a1d355fSStephan Aßmus static
7365a1d355fSStephan Aßmus int
netfs_open_attrdir(void * ns,void * _node,void ** cookie)7375a1d355fSStephan Aßmus netfs_open_attrdir(void *ns, void *_node, void **cookie)
7385a1d355fSStephan Aßmus {
7395a1d355fSStephan Aßmus Node* node = (Node*)_node;
7403c1afd35SPawel Dziepak PRINT("netfs_open_attrdir(%p, %p)\n", ns, node);
7415a1d355fSStephan Aßmus status_t error = node->GetVolume()->OpenAttrDir(node, cookie);
7424cfa5b2dSJérôme Duval PRINT("netfs_open_attrdir() done: (%" B_PRIx32 ", %p)\n", error, *cookie);
7435a1d355fSStephan Aßmus return error;
7445a1d355fSStephan Aßmus }
7455a1d355fSStephan Aßmus
7465a1d355fSStephan Aßmus // netfs_close_attrdir
7475a1d355fSStephan Aßmus static
7485a1d355fSStephan Aßmus int
netfs_close_attrdir(void * ns,void * _node,void * cookie)7495a1d355fSStephan Aßmus netfs_close_attrdir(void *ns, void *_node, void *cookie)
7505a1d355fSStephan Aßmus {
7515a1d355fSStephan Aßmus Node* node = (Node*)_node;
7523c1afd35SPawel Dziepak PRINT("netfs_close_attrdir(%p, %p, %p)\n", ns, node, cookie);
7535a1d355fSStephan Aßmus status_t error = node->GetVolume()->CloseAttrDir(node, cookie);
7544cfa5b2dSJérôme Duval PRINT("netfs_close_attrdir() done: (%" B_PRIx32 ")\n", error);
7555a1d355fSStephan Aßmus return error;
7565a1d355fSStephan Aßmus }
7575a1d355fSStephan Aßmus
7585a1d355fSStephan Aßmus // netfs_free_attrdir_cookie
7595a1d355fSStephan Aßmus static
7605a1d355fSStephan Aßmus int
netfs_free_attrdir_cookie(void * ns,void * _node,void * cookie)7615a1d355fSStephan Aßmus netfs_free_attrdir_cookie(void *ns, void *_node, void *cookie)
7625a1d355fSStephan Aßmus {
7635a1d355fSStephan Aßmus Node* node = (Node*)_node;
7643c1afd35SPawel Dziepak PRINT("netfs_free_attrdir_cookie(%p, %p, %p)\n", ns, node, cookie);
7655a1d355fSStephan Aßmus status_t error = node->GetVolume()->FreeAttrDirCookie(node, cookie);
7664cfa5b2dSJérôme Duval PRINT("netfs_free_attrdir_cookie() done: (%" B_PRIx32 ")\n", error);
7675a1d355fSStephan Aßmus return error;
7685a1d355fSStephan Aßmus }
7695a1d355fSStephan Aßmus
7705a1d355fSStephan Aßmus // netfs_read_attrdir
7715a1d355fSStephan Aßmus static
7725a1d355fSStephan Aßmus int
netfs_read_attrdir(void * ns,void * _node,void * cookie,long * count,struct dirent * buffer,size_t bufferSize)7735a1d355fSStephan Aßmus netfs_read_attrdir(void *ns, void *_node, void *cookie, long *count,
7745a1d355fSStephan Aßmus struct dirent *buffer, size_t bufferSize)
7755a1d355fSStephan Aßmus {
7765a1d355fSStephan Aßmus Node* node = (Node*)_node;
7773c1afd35SPawel Dziepak PRINT("netfs_read_attrdir(%p, %p, %p, %ld, %p, %lu)\n", ns, node,
7783c1afd35SPawel Dziepak cookie, *count, buffer, bufferSize);
77920f046edSJérôme Duval int32 _count = *count;
7805a1d355fSStephan Aßmus status_t error = node->GetVolume()->ReadAttrDir(node, cookie, buffer,
78120f046edSJérôme Duval bufferSize, _count, &_count);
78220f046edSJérôme Duval *count = _count;
7834cfa5b2dSJérôme Duval PRINT("netfs_read_attrdir() done: (%" B_PRIx32 ", %ld)\n", error, *count);
7845a1d355fSStephan Aßmus return error;
7855a1d355fSStephan Aßmus }
7865a1d355fSStephan Aßmus
7875a1d355fSStephan Aßmus // netfs_rewind_attrdir
7885a1d355fSStephan Aßmus static
7895a1d355fSStephan Aßmus int
netfs_rewind_attrdir(void * ns,void * _node,void * cookie)7905a1d355fSStephan Aßmus netfs_rewind_attrdir(void *ns, void *_node, void *cookie)
7915a1d355fSStephan Aßmus {
7925a1d355fSStephan Aßmus Node* node = (Node*)_node;
7933c1afd35SPawel Dziepak PRINT("netfs_rewind_attrdir(%p, %p, %p)\n", ns, node, cookie);
7945a1d355fSStephan Aßmus status_t error = node->GetVolume()->RewindAttrDir(node, cookie);
7954cfa5b2dSJérôme Duval PRINT("netfs_rewind_attrdir() done: (%" B_PRIx32 ")\n", error);
7965a1d355fSStephan Aßmus return error;
7975a1d355fSStephan Aßmus }
7985a1d355fSStephan Aßmus
7995a1d355fSStephan Aßmus // netfs_read_attr
8005a1d355fSStephan Aßmus static
8015a1d355fSStephan Aßmus int
netfs_read_attr(void * ns,void * _node,const char * name,int type,void * buffer,size_t * bufferSize,off_t pos)8025a1d355fSStephan Aßmus netfs_read_attr(void *ns, void *_node, const char *name, int type,
8035a1d355fSStephan Aßmus void *buffer, size_t *bufferSize, off_t pos)
8045a1d355fSStephan Aßmus {
8055a1d355fSStephan Aßmus Node* node = (Node*)_node;
8064cfa5b2dSJérôme Duval PRINT("netfs_read_attr(%p, %p, `%s', %d, %p, %lu, %" B_PRIdOFF ")\n", ns,
8074cfa5b2dSJérôme Duval node, name, type, buffer, *bufferSize, pos);
8085a1d355fSStephan Aßmus status_t error = node->GetVolume()->ReadAttr(node, name, type, pos, buffer,
8095a1d355fSStephan Aßmus *bufferSize, bufferSize);
8104cfa5b2dSJérôme Duval PRINT("netfs_read_attr() done: (%" B_PRIx32 ", %ld)\n", error,
8114cfa5b2dSJérôme Duval *bufferSize);
8125a1d355fSStephan Aßmus return error;
8135a1d355fSStephan Aßmus }
8145a1d355fSStephan Aßmus
8155a1d355fSStephan Aßmus // netfs_write_attr
8165a1d355fSStephan Aßmus static
8175a1d355fSStephan Aßmus int
netfs_write_attr(void * ns,void * _node,const char * name,int type,const void * buffer,size_t * bufferSize,off_t pos)8185a1d355fSStephan Aßmus netfs_write_attr(void *ns, void *_node, const char *name, int type,
8195a1d355fSStephan Aßmus const void *buffer, size_t *bufferSize, off_t pos)
8205a1d355fSStephan Aßmus {
8215a1d355fSStephan Aßmus Node* node = (Node*)_node;
8224cfa5b2dSJérôme Duval PRINT("netfs_write_attr(%p, %p, `%s', %d, %p, %lu, %" B_PRIdOFF ")\n", ns,
8234cfa5b2dSJérôme Duval node, name, type, buffer, *bufferSize, pos);
8245a1d355fSStephan Aßmus status_t error = node->GetVolume()->WriteAttr(node, name, type, pos, buffer,
8255a1d355fSStephan Aßmus *bufferSize, bufferSize);
8264cfa5b2dSJérôme Duval PRINT("netfs_write_attr() done: (%" B_PRIx32 ", %ld)\n", error,
8274cfa5b2dSJérôme Duval *bufferSize);
8285a1d355fSStephan Aßmus return error;
8295a1d355fSStephan Aßmus }
8305a1d355fSStephan Aßmus
8315a1d355fSStephan Aßmus // netfs_remove_attr
8325a1d355fSStephan Aßmus static
8335a1d355fSStephan Aßmus int
netfs_remove_attr(void * ns,void * _node,const char * name)8345a1d355fSStephan Aßmus netfs_remove_attr(void *ns, void *_node, const char *name)
8355a1d355fSStephan Aßmus {
8365a1d355fSStephan Aßmus Node* node = (Node*)_node;
8373c1afd35SPawel Dziepak PRINT("netfs_remove_attr(%p, %p, `%s')\n", ns, node, name);
8385a1d355fSStephan Aßmus status_t error = node->GetVolume()->RemoveAttr(node, name);
8394cfa5b2dSJérôme Duval PRINT("netfs_remove_attr() done: (%" B_PRIx32 ")\n", error);
8405a1d355fSStephan Aßmus return error;
8415a1d355fSStephan Aßmus }
8425a1d355fSStephan Aßmus
8435a1d355fSStephan Aßmus // netfs_rename_attr
8445a1d355fSStephan Aßmus static
8455a1d355fSStephan Aßmus int
netfs_rename_attr(void * ns,void * _node,const char * oldName,const char * newName)8465a1d355fSStephan Aßmus netfs_rename_attr(void *ns, void *_node, const char *oldName,
8475a1d355fSStephan Aßmus const char *newName)
8485a1d355fSStephan Aßmus {
8495a1d355fSStephan Aßmus Node* node = (Node*)_node;
8503c1afd35SPawel Dziepak PRINT("netfs_rename_attr(%p, %p, `%s', `%s')\n", ns, node, oldName,
8513c1afd35SPawel Dziepak newName);
8525a1d355fSStephan Aßmus status_t error = node->GetVolume()->RenameAttr(node, oldName, newName);
8534cfa5b2dSJérôme Duval PRINT("netfs_rename_attr() done: (%" B_PRIx32 ")\n", error);
8545a1d355fSStephan Aßmus return error;
8555a1d355fSStephan Aßmus }
8565a1d355fSStephan Aßmus
8575a1d355fSStephan Aßmus // netfs_stat_attr
8585a1d355fSStephan Aßmus static
8595a1d355fSStephan Aßmus int
netfs_stat_attr(void * ns,void * _node,const char * name,struct attr_info * attrInfo)8605a1d355fSStephan Aßmus netfs_stat_attr(void *ns, void *_node, const char *name,
8615a1d355fSStephan Aßmus struct attr_info *attrInfo)
8625a1d355fSStephan Aßmus {
8635a1d355fSStephan Aßmus Node* node = (Node*)_node;
8643c1afd35SPawel Dziepak PRINT("netfs_stat_attr(%p, %p, `%s', %p)\n", ns, node, name,
8653c1afd35SPawel Dziepak attrInfo);
8665a1d355fSStephan Aßmus status_t error = node->GetVolume()->StatAttr(node, name, attrInfo);
8674cfa5b2dSJérôme Duval PRINT("netfs_stat_attr() done: (%" B_PRIx32 ")\n", error);
8685a1d355fSStephan Aßmus return error;
8695a1d355fSStephan Aßmus }
8705a1d355fSStephan Aßmus
8715a1d355fSStephan Aßmus // #pragma mark -
8725a1d355fSStephan Aßmus // #pragma mark ----- queries -----
8735a1d355fSStephan Aßmus
8745a1d355fSStephan Aßmus // netfs_open_query
8755a1d355fSStephan Aßmus static
8765a1d355fSStephan Aßmus int
netfs_open_query(void * ns,const char * queryString,ulong flags,port_id port,long token,void ** cookie)8775a1d355fSStephan Aßmus netfs_open_query(void *ns, const char *queryString, ulong flags,
8785a1d355fSStephan Aßmus port_id port, long token, void **cookie)
8795a1d355fSStephan Aßmus {
8805a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
8815a1d355fSStephan Aßmus Volume* volume = volumeManager->GetRootVolume();
8825a1d355fSStephan Aßmus VolumePutter _(volume);
8835a1d355fSStephan Aßmus
8844cfa5b2dSJérôme Duval PRINT("netfs_open_query(%p, `%s', %lu, %" B_PRId32 ", %ld, %p)\n", ns,
8853c1afd35SPawel Dziepak queryString, flags, port, token, cookie);
8865a1d355fSStephan Aßmus
8875a1d355fSStephan Aßmus status_t error = B_BAD_VALUE;
8885a1d355fSStephan Aßmus if (volume) {
8895a1d355fSStephan Aßmus error = volume->OpenQuery(queryString, flags, port, token,
8905a1d355fSStephan Aßmus (QueryIterator**)cookie);
8915a1d355fSStephan Aßmus }
8925a1d355fSStephan Aßmus
8934cfa5b2dSJérôme Duval PRINT("netfs_open_query() done: (%" B_PRIx32 ", %p)\n", error, *cookie);
8945a1d355fSStephan Aßmus return error;
8955a1d355fSStephan Aßmus }
8965a1d355fSStephan Aßmus
8975a1d355fSStephan Aßmus // netfs_close_query
8985a1d355fSStephan Aßmus static
8995a1d355fSStephan Aßmus int
netfs_close_query(void * ns,void * cookie)9005a1d355fSStephan Aßmus netfs_close_query(void *ns, void *cookie)
9015a1d355fSStephan Aßmus {
9023c1afd35SPawel Dziepak PRINT("netfs_close_query(%p, %p)\n", ns, cookie);
9035a1d355fSStephan Aßmus
9045a1d355fSStephan Aßmus status_t error = B_OK;
9055a1d355fSStephan Aßmus // no-op: we don't use this hook
9065a1d355fSStephan Aßmus
9074cfa5b2dSJérôme Duval PRINT("netfs_close_query() done: (%" B_PRIx32 ")\n", error);
9085a1d355fSStephan Aßmus return error;
9095a1d355fSStephan Aßmus }
9105a1d355fSStephan Aßmus
9115a1d355fSStephan Aßmus // netfs_free_query_cookie
9125a1d355fSStephan Aßmus static
9135a1d355fSStephan Aßmus int
netfs_free_query_cookie(void * ns,void * node,void * cookie)9145a1d355fSStephan Aßmus netfs_free_query_cookie(void *ns, void *node, void *cookie)
9155a1d355fSStephan Aßmus {
9165a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
9175a1d355fSStephan Aßmus QueryIterator* iterator = (QueryIterator*)cookie;
9185a1d355fSStephan Aßmus
9193c1afd35SPawel Dziepak PRINT("netfs_free_query_cookie(%p, %p)\n", ns, cookie);
9205a1d355fSStephan Aßmus
9215a1d355fSStephan Aßmus status_t error = B_OK;
9225a1d355fSStephan Aßmus volumeManager->GetQueryManager()->PutIterator(iterator);
9235a1d355fSStephan Aßmus
9244cfa5b2dSJérôme Duval PRINT("netfs_free_query_cookie() done: (%" B_PRIx32 ")\n", error);
9255a1d355fSStephan Aßmus return error;
9265a1d355fSStephan Aßmus }
9275a1d355fSStephan Aßmus
9285a1d355fSStephan Aßmus // netfs_read_query
9295a1d355fSStephan Aßmus static
9305a1d355fSStephan Aßmus int
netfs_read_query(void * ns,void * cookie,long * count,struct dirent * buffer,size_t bufferSize)9315a1d355fSStephan Aßmus netfs_read_query(void *ns, void *cookie, long *count,
9325a1d355fSStephan Aßmus struct dirent *buffer, size_t bufferSize)
9335a1d355fSStephan Aßmus {
9345a1d355fSStephan Aßmus VolumeManager* volumeManager = (VolumeManager*)ns;
9355a1d355fSStephan Aßmus Volume* volume = volumeManager->GetRootVolume();
9365a1d355fSStephan Aßmus QueryIterator* iterator = (QueryIterator*)cookie;
9375a1d355fSStephan Aßmus VolumePutter _(volume);
9385a1d355fSStephan Aßmus
9393c1afd35SPawel Dziepak PRINT("netfs_read_query(%p, %p, %ld, %p, %lu)\n", ns, cookie,
9403c1afd35SPawel Dziepak *count, buffer, bufferSize);
9415a1d355fSStephan Aßmus
9425a1d355fSStephan Aßmus status_t error = B_BAD_VALUE;
9435a1d355fSStephan Aßmus if (volume) {
94420f046edSJérôme Duval int32 _count = *count;
9455a1d355fSStephan Aßmus error = volume->ReadQuery(iterator, buffer, bufferSize,
94620f046edSJérôme Duval _count, &_count);
94720f046edSJérôme Duval *count = _count;
9485a1d355fSStephan Aßmus }
9495a1d355fSStephan Aßmus
9504cfa5b2dSJérôme Duval PRINT("netfs_read_query() done: (%" B_PRIx32 ", %ld)\n", error, *count);
9515a1d355fSStephan Aßmus return error;
9525a1d355fSStephan Aßmus }
9535a1d355fSStephan Aßmus
954