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 int onefs_statvfs(vfs_handle_struct *handle, const char *path,
44 vfs_statvfs_struct *statbuf)
46 struct statvfs statvfs_buf;
49 DEBUG(5, ("Calling SMB_STAT_VFS \n"));
50 result = statvfs(path, &statvfs_buf);
51 ZERO_STRUCTP(statbuf);
54 statbuf->OptimalTransferSize = statvfs_buf.f_iosize;
55 statbuf->BlockSize = statvfs_buf.f_bsize;
56 statbuf->TotalBlocks = statvfs_buf.f_blocks;
57 statbuf->BlocksAvail = statvfs_buf.f_bfree;
58 statbuf->UserBlocksAvail = statvfs_buf.f_bavail;
59 statbuf->TotalFileNodes = statvfs_buf.f_files;
60 statbuf->FreeFileNodes = statvfs_buf.f_ffree;
61 statbuf->FsIdentifier =
62 (((uint64_t)statvfs_buf.f_fsid.val[0]<<32) &
63 0xffffffff00000000LL) |
64 (uint64_t)statvfs_buf.f_fsid.val[1];
69 static int onefs_ntimes(vfs_handle_struct *handle, const char *fname,
70 struct smb_file_time *ft)
73 struct timespec times[3];
75 if (!null_timespec(ft->atime)) {
78 DEBUG(6,("**** onefs_ntimes: actime: %s.%d\n",
79 time_to_asc(convert_timespec_to_time_t(ft->atime)),
83 if (!null_timespec(ft->mtime)) {
86 DEBUG(6,("**** onefs_ntimes: modtime: %s.%d\n",
87 time_to_asc(convert_timespec_to_time_t(ft->mtime)),
91 if (!null_timespec(ft->create_time)) {
93 times[2] = ft->create_time;
94 DEBUG(6,("**** onefs_ntimes: createtime: %s.%d\n",
95 time_to_asc(convert_timespec_to_time_t(ft->create_time)),
96 ft->create_time.tv_nsec));
99 return onefs_vtimes_streams(handle, fname, flags, times);
102 static uint32_t onefs_fs_capabilities(struct vfs_handle_struct *handle)
104 return SMB_VFS_NEXT_FS_CAPABILITIES(handle) | FILE_NAMED_STREAMS;
107 static vfs_op_tuple onefs_ops[] = {
108 {SMB_VFS_OP(onefs_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
109 SMB_VFS_LAYER_TRANSPARENT},
110 {SMB_VFS_OP(onefs_mkdir), SMB_VFS_OP_MKDIR,
111 SMB_VFS_LAYER_OPAQUE},
112 {SMB_VFS_OP(onefs_open), SMB_VFS_OP_OPEN,
113 SMB_VFS_LAYER_OPAQUE},
114 {SMB_VFS_OP(onefs_create_file), SMB_VFS_OP_CREATE_FILE,
115 SMB_VFS_LAYER_OPAQUE},
116 {SMB_VFS_OP(onefs_close), SMB_VFS_OP_CLOSE,
117 SMB_VFS_LAYER_TRANSPARENT},
118 {SMB_VFS_OP(onefs_rename), SMB_VFS_OP_RENAME,
119 SMB_VFS_LAYER_TRANSPARENT},
120 {SMB_VFS_OP(onefs_stat), SMB_VFS_OP_STAT,
121 SMB_VFS_LAYER_TRANSPARENT},
122 {SMB_VFS_OP(onefs_fstat), SMB_VFS_OP_FSTAT,
123 SMB_VFS_LAYER_TRANSPARENT},
124 {SMB_VFS_OP(onefs_lstat), SMB_VFS_OP_LSTAT,
125 SMB_VFS_LAYER_TRANSPARENT},
126 {SMB_VFS_OP(onefs_unlink), SMB_VFS_OP_UNLINK,
127 SMB_VFS_LAYER_TRANSPARENT},
128 {SMB_VFS_OP(onefs_ntimes), SMB_VFS_OP_NTIMES,
129 SMB_VFS_LAYER_OPAQUE},
130 {SMB_VFS_OP(onefs_chflags), SMB_VFS_OP_CHFLAGS,
131 SMB_VFS_LAYER_TRANSPARENT},
132 {SMB_VFS_OP(onefs_streaminfo), SMB_VFS_OP_STREAMINFO,
133 SMB_VFS_LAYER_OPAQUE},
134 {SMB_VFS_OP(onefs_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
135 SMB_VFS_LAYER_OPAQUE},
136 {SMB_VFS_OP(onefs_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
137 SMB_VFS_LAYER_OPAQUE},
138 {SMB_VFS_OP(onefs_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
139 SMB_VFS_LAYER_OPAQUE},
140 {SMB_VFS_OP(onefs_statvfs), SMB_VFS_OP_STATVFS,
141 SMB_VFS_LAYER_OPAQUE},
142 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
145 NTSTATUS vfs_onefs_init(void)
147 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "onefs",