All debug messages must be always dumped to 'stderr' (never 'stdout').
[lufs.git] / include / lufs / fs.h
1 /*
2  * lufs.h
3  * Copyright (C) 2002 Florin Malita <mali@go.ro>
4  *
5  * This file is part of LUFS, a free userspace filesystem implementation.
6  * See http://lufs.sourceforge.net/ for updates.
7  *
8  * LUFS is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * LUFS is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef _LUFS_FS_H_
24 #define _LUFS_FS_H_
25
26 #include <sys/types.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 struct dir_cache;
33 struct directory;
34 struct lufs_fattr;
35 struct file_system;
36 struct list_head;
37 struct dir_cache;
38
39 #define MAX_LEN         64
40
41 struct credentials{
42     char        user[MAX_LEN];
43     char        group[MAX_LEN];
44     uid_t       uid;
45     gid_t       gid;
46 };
47
48
49 struct directory* lu_cache_mkdir(char*);
50 int lu_cache_add2dir(struct directory*, char*, char*, struct lufs_fattr*);
51 int lu_cache_lookup(struct dir_cache*, char*, char*, struct lufs_fattr*, char*, int);
52 void lu_cache_add_dir(struct dir_cache*, struct directory*);
53 void lu_cache_killdir(struct directory*);
54
55 int lu_check_to(int, int, int);
56 int lu_atomic_read(int, char*, int, int);
57 int lu_atomic_write(int, char*, int, int);
58
59 int lu_opt_loadcfg(struct list_head*, char*);
60 int lu_opt_parse(struct list_head*, char*, char*);
61 int lu_opt_getint(struct list_head*, char*, char*, long int*, int);
62 const char* lu_opt_getchar(struct list_head*, char*, char*);
63
64
65 #ifdef __cplusplus
66 } /* end of extern "C" { */
67 #endif
68
69 #ifdef TRACE
70 #undef TRACE
71 #endif
72 #ifdef WARN
73 #undef WARN
74 #endif
75 #ifdef ERROR
76 #undef ERROR
77 #endif
78
79 #ifdef __cplusplus
80
81 #include <iostream>
82
83 #ifdef DEBUG
84 #define TRACE(x)        cout<<std::hex<<"["<<getpid()<<"]("<<__func__<<")"<<x<<"\n"
85 #define WARN(x)         cerr<<std::hex<<"["<<getpid()<<"]("<<__func__<<")"<<x<<"\n"
86 #define ERROR(x)        cerr<<std::hex<<"["<<getpid()<<"]("<<__func__<<")"<<x<<"\n"
87 #else
88 #define TRACE(x...)     do{}while(0)
89 #define WARN(x...)      do{}while(0)
90 #define ERROR(x...)     cerr<<x<<"\n"
91 #endif
92
93 #else
94
95 #include <stdio.h>
96
97 #ifdef DEBUG
98 #define TRACE(x...)     do{fprintf(stderr, "[%x](%s) ", getpid(), __func__); fprintf(stderr, x); fprintf(stderr, "\n");}while(0)
99 #define WARN(x...)      do{fprintf(stderr, "[%x](%s) ", getpid(), __func__); fprintf(stderr, x); fprintf(stderr, "\n");}while(0)
100 #define ERROR(x...)     do{fprintf(stderr, "[%x](%s) ", getpid(), __func__); fprintf(stderr, x); fprintf(stderr, "\n");}while(0)
101 #else
102 #define TRACE(x...)     do{}while(0)
103 #define WARN(x...)      do{}while(0)
104 #define ERROR(x...)     do{fprintf(stderr, x); fprintf(stderr, "\n");}while(0)
105 #endif
106
107 #endif
108
109
110
111 #endif
112