Debian Codegraph @

xlators/storage/posix/src/posix-inode-handle.h

raw symbols SCIP
1 /*
2 Copyright (c) 2011-2017 Red Hat, Inc. <http://www.redhat.com>
3 This file is part of GlusterFS.
4
5 This file is licensed to you under your choice of the GNU Lesser
6 General Public License, version 3 or any later version (LGPLv3 or
7 later), or the GNU General Public License, version 2 (GPLv2), in all
8 cases as published by the Free Software Foundation.
9 */
10 #ifndef _POSIX_INODE_HANDLE_H
11 #define _POSIX_INODE_HANDLE_H
12
13 #include <limits.h>
14 #include <sys/types.h>
15 #include <glusterfs/gf-dirent.h>
16
17 /* From Open Group Base Specifications Issue 6 */
18 #ifndef _XOPEN_PATH_MAX
19 #define _XOPEN_PATH_MAX 1024
20 #endif
21
22 #define TRASH_DIR "landfill"
23
24 #define UUID0_STR "00000000-0000-0000-0000-000000000000"
25
26 #define LOC_HAS_ABSPATH(loc) (loc && (loc->path) && (loc->path[0] == '/'))
27 #define LOC_IS_DIR(loc) \
28 (loc && (loc->inode) && (loc->inode->ia_type == IA_IFDIR))
29 #define MAKE_REAL_PATH(var, this, path) \
30 do { \
31 size_t path_len = strlen(path); \
32 size_t var_len = path_len + POSIX_BASE_PATH_LEN(this) + 1; \
33 if (POSIX_PATH_MAX(this) != -1 && var_len >= POSIX_PATH_MAX(this)) { \
34 var = alloca(path_len + 1); \
35 strcpy(var, (path[0] == '/') ? path + 1 : path); \
36 } else { \
37 var = alloca(var_len); \
38 strcpy(var, POSIX_BASE_PATH(this)); \
39 strcpy(&var[POSIX_BASE_PATH_LEN(this)], path); \
40 } \
41 } while (0)
42
43 #define MAKE_HANDLE_PATH(var, this, gfid, base) \
44 do { \
45 int __len = 0; \
46 int tot = PATH_MAX; \
47 var = alloca(tot); \
48 __len = posix_handle_path(this, gfid, base, var, tot); \
49 if (__len <= 0) { \
50 var = NULL; \
51 } \
52 } while (0)
53
54 /* TODO: it is not a good idea to change a variable which
55 is not passed to the macro.. Fix it later */
56 #define MAKE_INODE_HANDLE(rpath, this, loc, iatt_p) \
57 do { \
58 if (!this->private) { \
59 op_ret = -1; \
60 gf_msg("make_inode_handle", GF_LOG_ERROR, 0, \
61 P_MSG_INODE_HANDLE_CREATE, \
62 "private is NULL, fini is already called"); \
63 break; \
64 } \
65 if (gf_uuid_is_null(loc->gfid)) { \
66 op_ret = -1; \
67 gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INODE_HANDLE_CREATE, \
68 "null gfid for path %s", (loc)->path); \
69 break; \
70 } \
71 if (LOC_IS_DIR(loc) && LOC_HAS_ABSPATH(loc)) { \
72 MAKE_REAL_PATH(rpath, this, (loc)->path); \
73 op_ret = posix_pstat(this, (loc)->inode, (loc)->gfid, rpath, \
74 iatt_p, _gf_false, _gf_true); \
75 break; \
76 } \
77 errno = 0; \
78 op_ret = posix_istat(this, loc->inode, loc->gfid, NULL, iatt_p, \
79 _gf_true); \
80 if (errno != ELOOP) { \
81 MAKE_HANDLE_PATH(rpath, this, (loc)->gfid, NULL); \
82 if (!rpath) { \
83 op_ret = -1; \
84 gf_msg(this->name, GF_LOG_ERROR, errno, \
85 P_MSG_INODE_HANDLE_CREATE, \
86 "Failed to create inode handle " \
87 "for path %s", \
88 (loc)->path); \
89 } \
90 break; \
91 } /* __ret == -1 && errno == ELOOP */ \
92 else { \
93 op_ret = -1; \
94 } \
95 } while (0)
96
97 #define POSIX_ANCESTRY_PATH (1 << 0)
98 #define POSIX_ANCESTRY_DENTRY (1 << 1)
99
100 int
101 posix_handle_path(xlator_t *this, uuid_t gfid, const char *basename, char *buf,
102 size_t len);
103
104 int
105 posix_make_ancestryfromgfid(xlator_t *this, char *path, int pathsize,
106 gf_dirent_t *head, int type, uuid_t gfid,
107 const size_t handle_size,
108 const char *priv_base_path, inode_table_t *table,
109 inode_t **parent, dict_t *xdata, int32_t *op_errno);
110
111 int
112 posix_handle_init(xlator_t *this);
113
114 int
115 posix_handle_trash_init(xlator_t *this);
116
117 #endif /* !_POSIX_INODE_HANDLE_H */