2 * VFS module implementing get_real_filename for Scality SOFS
4 * Copyright (C) 2016, Jean-Marc Saffroy <jm@scality.com>
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 3 of the License, or
9 * (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "smbd/smbd.h"
25 #define GRFN_PREFIX "scal.grfn."
26 #define GRFN_PREFIX_LEN (sizeof(GRFN_PREFIX)-1)
28 static int vfs_ring_get_real_filename(struct vfs_handle_struct
*handle
,
35 char attr_name
[NAME_MAX
+1];
36 char attr_value
[NAME_MAX
+1];
38 const struct smb_filename
*smb_fname
= NULL
;
40 if (!strcmp(path
, ""))
43 smb_fname
= synthetic_smb_fname(talloc_tos(),
48 if (smb_fname
== NULL
) {
53 DEBUG(DBG
, ("vfs_ring_get_real_filename: under \"%s\" lookup \"%s\"\n",
56 mangled
= mangle_is_mangled(name
, handle
->conn
->params
);
58 return SMB_VFS_NEXT_GET_REAL_FILENAME(
59 handle
, path
, name
, mem_ctx
, found_name
);
62 if (strlen(name
) > NAME_MAX
- GRFN_PREFIX_LEN
) {
67 strncpy(attr_name
, GRFN_PREFIX
, sizeof(attr_name
));
68 strncpy(attr_name
+ GRFN_PREFIX_LEN
, name
,
69 sizeof(attr_name
) - GRFN_PREFIX_LEN
);
71 rc
= SMB_VFS_NEXT_GETXATTR(handle
, smb_fname
, attr_name
,
72 attr_value
, sizeof(attr_value
));
74 DEBUG(DBG
, ("vfs_ring_get_real_filename: getxattr(\"%s\",\"%s\") -> %s\n",
75 path
, name
, strerror(errno
)));
76 if (errno
== EOPNOTSUPP
)
77 return SMB_VFS_NEXT_GET_REAL_FILENAME(
78 handle
, path
, name
, mem_ctx
, found_name
);
85 *found_name
= talloc_strdup(mem_ctx
, attr_value
);
86 if (*found_name
== NULL
) {
91 DEBUG(DBG
, ("vfs_ring_get_real_filename: under \"%s\" found \"%s\" as \"%s\"\n",
92 path
, name
, *found_name
));
97 static struct vfs_fn_pointers vfs_ring_fns
= {
98 .get_real_filename_fn
= vfs_ring_get_real_filename
,
101 NTSTATUS
vfs_ring_init(TALLOC_CTX
*);
102 NTSTATUS
vfs_ring_init(TALLOC_CTX
*ctx
)
106 ret
= smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "ring",
108 if (!NT_STATUS_IS_OK(ret
)) {