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
10 #include "mvfs-internal.h"
12 #define _LARGEFILE64_SOURCE
14 #include <sys/types.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
);
34 int mvfs_default_fileops_close (MVFS_FILE
* file
)
40 int mvfs_default_fileops_open (MVFS_FILE
* fp
, mode_t mode
)
47 off64_t
mvfs_default_fileops_seek (MVFS_FILE
* fp
, off64_t offset
, int whence
)
54 ssize_t
mvfs_default_fileops_read (MVFS_FILE
* fp
, void* buf
, size_t count
)
61 ssize_t
mvfs_default_fileops_write (MVFS_FILE
* fp
, const void* buf
, size_t count
)
68 ssize_t
mvfs_default_fileops_pread (MVFS_FILE
* fp
, void* buf
, size_t count
, off64_t offset
)
75 ssize_t
mvfs_default_fileops_pwrite (MVFS_FILE
* fp
, const void* buf
, size_t count
, off64_t offset
)
82 static inline const char* __mvfs_flag2str(MVFS_FILE_FLAG 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
));
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
;
109 MVFS_STAT
* mvfs_default_fileops_stat(MVFS_FILE
* fp
)
112 fp
->errcode
= EINVAL
;
116 MVFS_FILE
* mvfs_default_fsops_openfile(MVFS_FILESYSTEM
* fs
, const char* name
, mode_t mode
)
120 fs
->errcode
= EINVAL
;
124 MVFS_STAT
* mvfs_default_fsops_stat(MVFS_FILESYSTEM
* fs
, const char* name
)
128 fs
->errcode
= EINVAL
;
132 int mvfs_default_fsops_unlink(MVFS_FILESYSTEM
* fs
, const char* name
)
136 fs
->errcode
= EINVAL
;
140 int mvfs_default_fileops_eof(MVFS_FILE
* file
)
146 MVFS_FILE
* mvfs_default_fileops_lookup(MVFS_FILE
* file
, const char* name
)
151 MVFS_STAT
* mvfs_default_fileops_scan(MVFS_FILE
* file
)
156 int mvfs_default_fileops_reset(MVFS_FILE
* file
)