2 * Unix SMB/CIFS implementation.
5 * Copyright (C) Tim Prouty, 2008
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 #define DBGC_CLASS DBGC_VFS
27 static int onefs_mkdir(vfs_handle_struct *handle, const char *path,
30 /* SMB_VFS_MKDIR should never be called in vfs_onefs */
32 return SMB_VFS_NEXT_MKDIR(handle, path, mode);
35 static int onefs_open(vfs_handle_struct *handle, const char *fname,
36 files_struct *fsp, int flags, mode_t mode)
38 /* SMB_VFS_OPEN should never be called in vfs_onefs */
40 return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
43 static uint64_t onefs_get_alloc_size(struct vfs_handle_struct *handle, files_struct *fsp,
44 const SMB_STRUCT_STAT *sbuf)
48 START_PROFILE(syscall_get_alloc_size);
50 if(S_ISDIR(sbuf->st_mode)) {
55 /* Just use the file size since st_blocks is unreliable on OneFS. */
56 result = get_file_size_stat(sbuf);
58 if (fsp && fsp->initial_allocation_size)
59 result = MAX(result,fsp->initial_allocation_size);
61 result = smb_roundup(handle->conn, result);
64 END_PROFILE(syscall_get_alloc_size);
68 static int onefs_statvfs(vfs_handle_struct *handle, const char *path,
69 vfs_statvfs_struct *statbuf)
71 struct statvfs statvfs_buf;
74 DEBUG(5, ("Calling SMB_STAT_VFS \n"));
75 result = statvfs(path, &statvfs_buf);
76 ZERO_STRUCTP(statbuf);
79 statbuf->OptimalTransferSize = statvfs_buf.f_iosize;
80 statbuf->BlockSize = statvfs_buf.f_bsize;
81 statbuf->TotalBlocks = statvfs_buf.f_blocks;
82 statbuf->BlocksAvail = statvfs_buf.f_bfree;
83 statbuf->UserBlocksAvail = statvfs_buf.f_bavail;
84 statbuf->TotalFileNodes = statvfs_buf.f_files;
85 statbuf->FreeFileNodes = statvfs_buf.f_ffree;
86 statbuf->FsIdentifier =
87 (((uint64_t)statvfs_buf.f_fsid.val[0]<<32) &
88 0xffffffff00000000LL) |
89 (uint64_t)statvfs_buf.f_fsid.val[1];
94 static int onefs_ntimes(vfs_handle_struct *handle, const char *fname,
95 struct smb_file_time *ft)
98 struct timespec times[3];
100 if (!null_timespec(ft->atime)) {
102 times[0] = ft->atime;
103 DEBUG(6,("**** onefs_ntimes: actime: %s.%d\n",
104 time_to_asc(convert_timespec_to_time_t(ft->atime)),
108 if (!null_timespec(ft->mtime)) {
110 times[1] = ft->mtime;
111 DEBUG(6,("**** onefs_ntimes: modtime: %s.%d\n",
112 time_to_asc(convert_timespec_to_time_t(ft->mtime)),
116 if (!null_timespec(ft->create_time)) {
118 times[2] = ft->create_time;
119 DEBUG(6,("**** onefs_ntimes: createtime: %s.%d\n",
120 time_to_asc(convert_timespec_to_time_t(ft->create_time)),
121 ft->create_time.tv_nsec));
124 return onefs_vtimes_streams(handle, fname, flags, times);
127 static uint32_t onefs_fs_capabilities(struct vfs_handle_struct *handle)
129 return SMB_VFS_NEXT_FS_CAPABILITIES(handle) | FILE_NAMED_STREAMS;
132 static vfs_op_tuple onefs_ops[] = {
133 {SMB_VFS_OP(onefs_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
134 SMB_VFS_LAYER_TRANSPARENT},
135 {SMB_VFS_OP(onefs_mkdir), SMB_VFS_OP_MKDIR,
136 SMB_VFS_LAYER_OPAQUE},
137 {SMB_VFS_OP(onefs_open), SMB_VFS_OP_OPEN,
138 SMB_VFS_LAYER_OPAQUE},
139 {SMB_VFS_OP(onefs_create_file), SMB_VFS_OP_CREATE_FILE,
140 SMB_VFS_LAYER_OPAQUE},
141 {SMB_VFS_OP(onefs_close), SMB_VFS_OP_CLOSE,
142 SMB_VFS_LAYER_TRANSPARENT},
143 {SMB_VFS_OP(onefs_rename), SMB_VFS_OP_RENAME,
144 SMB_VFS_LAYER_TRANSPARENT},
145 {SMB_VFS_OP(onefs_stat), SMB_VFS_OP_STAT,
146 SMB_VFS_LAYER_TRANSPARENT},
147 {SMB_VFS_OP(onefs_fstat), SMB_VFS_OP_FSTAT,
148 SMB_VFS_LAYER_TRANSPARENT},
149 {SMB_VFS_OP(onefs_lstat), SMB_VFS_OP_LSTAT,
150 SMB_VFS_LAYER_TRANSPARENT},
151 {SMB_VFS_OP(onefs_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE,
152 SMB_VFS_LAYER_OPAQUE},
153 {SMB_VFS_OP(onefs_unlink), SMB_VFS_OP_UNLINK,
154 SMB_VFS_LAYER_TRANSPARENT},
155 {SMB_VFS_OP(onefs_ntimes), SMB_VFS_OP_NTIMES,
156 SMB_VFS_LAYER_OPAQUE},
157 {SMB_VFS_OP(onefs_chflags), SMB_VFS_OP_CHFLAGS,
158 SMB_VFS_LAYER_TRANSPARENT},
159 {SMB_VFS_OP(onefs_streaminfo), SMB_VFS_OP_STREAMINFO,
160 SMB_VFS_LAYER_OPAQUE},
161 {SMB_VFS_OP(onefs_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
162 SMB_VFS_LAYER_OPAQUE},
163 {SMB_VFS_OP(onefs_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
164 SMB_VFS_LAYER_OPAQUE},
165 {SMB_VFS_OP(onefs_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
166 SMB_VFS_LAYER_OPAQUE},
167 {SMB_VFS_OP(onefs_statvfs), SMB_VFS_OP_STATVFS,
168 SMB_VFS_LAYER_OPAQUE},
169 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
172 NTSTATUS vfs_onefs_init(void)
174 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "onefs",