library name fixups
[libmvfs.git] / libmvfs / default_ops.c
blobf022a96401c80d9a81becf5ab631c638fcfe6aca
1 /*
2 libmvfs - metux Virtual Filesystem Library
4 Default filesystem and file operation handlers
6 Copyright (C) 2008 Enrico Weigelt, metux IT service <weigelt@metux.de>
7 This code is published under the terms of the GNU Public License 2.0
8 */
10 #include "mvfs-internal.h"
12 #define _LARGEFILE64_SOURCE
14 #include <sys/types.h>
15 #include <stdio.h>
16 #include <errno.h>
17 #include <malloc.h>
19 #include <mvfs/mvfs.h>
20 #include <mvfs/default_ops.h>
21 #include <mvfs/_utils.h>
23 /* release the file's data */
24 int mvfs_default_fileops_free (MVFS_FILE* file)
26 // call the close() handler just for sure
27 if (!(file->ops.close == NULL))
28 file->ops.close(file);
30 mvfs_fs_unref(file->fs);
31 return 0;
34 int mvfs_default_fileops_close (MVFS_FILE* file)
36 DEBUGMSG("DUMMY");
37 return 0;
40 int mvfs_default_fileops_open (MVFS_FILE* fp, mode_t mode)
42 DEBUGMSG("DUMMY");
43 fp->errcode = 0;
44 return 0;
47 off64_t mvfs_default_fileops_seek (MVFS_FILE* fp, off64_t offset, int whence)
49 DEBUGMSG("DUMMY");
50 fp->errcode = ESPIPE;
51 return (off64_t) -1;
54 ssize_t mvfs_default_fileops_read (MVFS_FILE* fp, void* buf, size_t count)
56 DEBUGMSG("DUMMY");
57 fp->errcode = EINVAL;
58 return (ssize_t) -1;
61 ssize_t mvfs_default_fileops_write (MVFS_FILE* fp, const void* buf, size_t count)
63 DEBUGMSG("DUMMY");
64 fp->errcode = EINVAL;
65 return (ssize_t) -1;
68 ssize_t mvfs_default_fileops_pread (MVFS_FILE* fp, void* buf, size_t count, off64_t offset)
70 DEBUGMSG("DUMMY");
71 fp->errcode = EINVAL;
72 return (ssize_t) -1;
75 ssize_t mvfs_default_fileops_pwrite (MVFS_FILE* fp, const void* buf, size_t count, off64_t offset)
77 DEBUGMSG("DUMMY");
78 fp->errcode = EINVAL;
79 return (ssize_t) -1;
82 static inline const char* __mvfs_flag2str(MVFS_FILE_FLAG f)
84 switch (f)
86 case NONBLOCK: return "NONBLOCK";
87 case READ_TIMEOUT: return "READ_TIMEOUT";
88 case WRITE_TIMEOUT: return "WRITE_TIMEOUT";
89 case READ_AHEAD: return "READ_AHEAD";
90 case WRITE_ASYNC: return "WRITE_ASYNNC";
91 default: return "UNKNOWN";
95 int mvfs_default_fileops_setflag (MVFS_FILE* fp, MVFS_FILE_FLAG flag, long value)
97 DEBUGMSG("Flag %s not supported", __mvfs_flag2str(flag));
98 fp->errcode = EINVAL;
99 return -1;
102 int mvfs_default_fileops_getflag (MVFS_FILE* fp, MVFS_FILE_FLAG flag, long* value)
104 DEBUGMSG("Flag %s not supported", __mvfs_flag2str(flag));
105 fp->errcode = EINVAL;
106 return -1;
109 MVFS_STAT* mvfs_default_fileops_stat(MVFS_FILE* fp)
111 DEBUGMSG("DUMMY");
112 fp->errcode = EINVAL;
113 return NULL;
116 MVFS_FILE* mvfs_default_fsops_openfile(MVFS_FILESYSTEM* fs, const char* name, mode_t mode)
118 DEBUGMSG("DUMMY");
119 if (fs!=NULL)
120 fs->errcode = EINVAL;
121 return NULL;
124 MVFS_STAT* mvfs_default_fsops_stat(MVFS_FILESYSTEM* fs, const char* name)
126 DEBUGMSG("DUMMY");
127 if (fs!=NULL)
128 fs->errcode = EINVAL;
129 return NULL;
132 int mvfs_default_fsops_unlink(MVFS_FILESYSTEM* fs, const char* name)
134 DEBUGMSG("DUMMY");
135 if (fs!=NULL)
136 fs->errcode = EINVAL;
137 return -EINVAL;
140 int mvfs_default_fileops_eof(MVFS_FILE* file)
142 DEBUGMSG("DUMMY");
143 return 0;
146 MVFS_FILE* mvfs_default_fileops_lookup(MVFS_FILE* file, const char* name)
148 return NULL;
151 MVFS_STAT* mvfs_default_fileops_scan(MVFS_FILE* file)
153 return NULL;
156 int mvfs_default_fileops_reset(MVFS_FILE* file)
158 return -EINVAL;