1 2 /* 3 FUNIONFS: UNIONFS over FUSE Usermode filesystem 4 Copyright (C) 2005-2006 Stephane APIOU <stephane.apiou@free.fr> 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 20 */ 21 #ifndef _FUNIONFS_H 22 #define _FUNIONFS_H 23 24 #include <limits.h> 25 #include <pthread.h> 26 27 // use the new API 28 29 #define VERSION "0.4.2" 30 31 #define MAX_LINKPATH 4096 32 #define MAX_READLINKS 50 33 34 #define DELETED_STRING "_DELETED~" 35 36 #define FILE_EXIST 0X01 37 #define FILE_WRITEABLE 0X02 38 #define FILE_DELETED 0X04 39 #define FILE_CREATABLE 0X08 40 #define FILE_TODELETE 0X10 41 42 #define IDX_GET 0 43 #define IDX_PUT 1 44 #define IDX_NEW 2 45 46 #define _DEBUG 1 47 48 #if _DEBUG 49 #define DEBUG_PRINTF(args...) \ 50 do { if (f_opt.debug) fprintf(stderr, args); } while(0) 51 #else 52 #define DEBUG_PRINTF(args...) 53 #endif 54 55 #define CONTROL_FILE "._funionfs_control~" 56 #define CONTROL_BUFFER_SIZE (3*PATH_MAX) 57 58 #define LOG(args...)\ 59 do { if(log_fd) fprintf(log_fd, args); fflush (log_fd); } while(0) 60 61 struct unionfs_desc 62 { 63 char *path; 64 char ro; 65 struct unionfs_desc *pnext; 66 }; 67 68 struct unionfs_walk 69 { 70 char *path; 71 char *str; 72 struct unionfs_desc *curdir; 73 }; 74 75 typedef struct funionfs_options 76 { 77 char *uid; 78 char *gid; 79 char *mode; 80 int delete; 81 int copyup; 82 int debug; 83 char *dirlist; 84 char *firstdir; 85 char *mountpoint; 86 char *del_string; 87 int del_len; 88 char *log; 89 } f_opt_t; 90 91 typedef struct control_buffer 92 { 93 char data[CONTROL_BUFFER_SIZE]; 94 long start; 95 long length; 96 } f_cbuf_t; 97 98 99 int getrightstr(char *str, char *substr); 100 101 char *rel2abspath(char *relpath, char *basepath); 102 103 int funionfs_addpath(char *path, int ro); 104 int funionfs_realpath(const char *path, char **get_path, char **put_path, 105 char **new_path, struct unionfs_desc *tab[3]); 106 int funionfs_copytowrite(char *readpath, char *writepath); 107 int funionfs_pathtowrite(const char *path); 108 109 int parse_and_add_dirs(void); 110 111 struct unionfs_walk *funionfs_openpath(const char *path); 112 char *funionfs_readpath(struct unionfs_walk *pwalk, long *type); 113 int funionfs_closepath(struct unionfs_walk *pwalk); 114 115 int funionfs_control_write(const char *buf, size_t size); 116 117 int funionfs_relist(void); 118 119 #endif 120