Forgot to remove some more .s strings and do a rename in order to prevent compiler...
[midnight-commander.git] / vfs / vfs.h
blobd79c706f474be4d22d7a26439b3cac62f6d71711
1 #ifndef MC_VFS_VFS_H
2 #define MC_VFS_VFS_H
4 void vfs_init (void);
5 void vfs_shut (void);
7 char *vfs_strip_suffix_from_filename (const char *filename);
8 char *vfs_canon (const char *path);
9 char *mc_get_current_wd (char *buffer, int bufsize);
10 char *vfs_get_current_dir (void);
11 int vfs_current_is_local (void);
12 int vfs_file_is_local (const char *filename);
14 /* Only the routines outside of the VFS module need the emulation macros */
16 int mc_open (const char *filename, int flags, ...);
17 int mc_close (int handle);
18 ssize_t mc_read (int handle, void *buffer, int count);
19 ssize_t mc_write (int handle, const void *buffer, int count);
20 off_t mc_lseek (int fd, off_t offset, int whence);
21 int mc_chdir (const char *path);
23 DIR *mc_opendir (const char *dirname);
24 struct dirent *mc_readdir (DIR * dirp);
25 int mc_closedir (DIR * dir);
27 int mc_stat (const char *path, struct stat *buf);
28 int mc_lstat (const char *path, struct stat *buf);
29 int mc_fstat (int fd, struct stat *buf);
31 int mc_chmod (const char *path, mode_t mode);
32 int mc_chown (const char *path, uid_t owner, gid_t group);
33 int mc_utime (const char *path, struct utimbuf *times);
34 int mc_readlink (const char *path, char *buf, int bufsiz);
35 int mc_unlink (const char *path);
36 int mc_symlink (const char *name1, const char *name2);
37 int mc_link (const char *name1, const char *name2);
38 int mc_mknod (const char *, mode_t, dev_t);
39 int mc_rename (const char *original, const char *target);
40 int mc_rmdir (const char *path);
41 int mc_mkdir (const char *path, mode_t mode);
43 char *mc_getlocalcopy (const char *pathname);
44 int mc_ungetlocalcopy (const char *pathname, const char *local, int has_changed);
45 int mc_ctl (int fd, int ctlop, void *arg);
46 int mc_setctl (const char *path, int ctlop, void *arg);
48 /* Operations for mc_ctl - on open file */
49 enum {
50 VFS_CTL_IS_NOTREADY
53 /* Operations for mc_setctl - on path */
54 enum {
55 VFS_SETCTL_FORGET,
56 VFS_SETCTL_RUN,
57 VFS_SETCTL_LOGFILE,
58 VFS_SETCTL_FLUSH, /* invalidate directory cache */
60 /* Setting this makes vfs layer give out potentially incorrect data,
61 but it also makes some operations much faster. Use with caution. */
62 VFS_SETCTL_STALE_DATA
65 #define O_ALL (O_CREAT | O_EXCL | O_NOCTTY | O_NDELAY | O_SYNC | O_WRONLY | O_RDWR | O_RDONLY)
66 /* Midnight commander code should _not_ use other flags than those
67 listed above and O_APPEND */
69 #if (O_ALL & O_APPEND)
70 #warning "Unexpected problem with flags, O_LINEAR disabled, contact pavel@ucw.cz"
71 #define O_LINEAR 0
72 #define IS_LINEAR(a) 0
73 #define NO_LINEAR(a) a
74 #else
75 #define O_LINEAR O_APPEND
76 #define IS_LINEAR(a) ((a) == (O_RDONLY | O_LINEAR)) /* Return only 0 and 1 ! */
77 #define NO_LINEAR(a) (((a) == (O_RDONLY | O_LINEAR)) ? O_RDONLY : (a))
78 #endif
80 /* O_LINEAR is strange beast, be careful. If you open file asserting
81 * O_RDONLY | O_LINEAR, you promise:
83 * a) to read file linearly from beginning to the end
84 * b) not to open another file before you close this one
85 * (this will likely go away in future)
86 * as a special gift, you may
87 * c) lseek() immediately after open(), giving ftpfs chance to
88 * reget. Be warned that this lseek() can fail, and you _have_
89 * to handle that gratefully.
91 * O_LINEAR allows filesystems not to create temporary file in some
92 * cases (ftp transfer). -- pavel@ucw.cz
95 /* And now some defines for our errors. */
97 #ifdef ENOSYS
98 #define E_NOTSUPP ENOSYS /* for use in vfs when module does not provide function */
99 #else
100 #define E_NOTSUPP EFAULT /* Does this happen? */
101 #endif
103 #ifdef ENOMSG
104 #define E_UNKNOWN ENOMSG /* if we do not know what error happened */
105 #else
106 #define E_UNKNOWN EIO /* if we do not know what error happened */
107 #endif
109 #ifdef EREMOTEIO
110 #define E_REMOTE EREMOTEIO /* if other side of ftp/fish reports error */
111 #else
112 #define E_REMOTE ENETUNREACH /* :-( there's no EREMOTEIO on some systems */
113 #endif
115 #ifdef EPROTO
116 #define E_PROTO EPROTO /* if other side fails to follow protocol */
117 #else
118 #define E_PROTO EIO
119 #endif
121 #endif