2 Unix SMB/CIFS implementation.
4 simple NTVFS filesystem backend
6 Copyright (C) Andrew Tridgell 2003
8 This program 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.
13 This program 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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 this implements a very simple NTVFS filesystem backend.
25 this backend largely ignores the POSIX -> CIFS mappings, just doing absolutely
26 minimal work to give a working backend.
36 #define CHECK_READ_ONLY(req) do { if (lp_readonly(req->tcon->service)) return NT_STATUS_ACCESS_DENIED; } while (0)
39 static ssize_t pread(int __fd, void *__buf, size_t __nbytes, off_t __offset)
41 if (lseek(__fd, __offset, SEEK_SET) != __offset) {
44 return read(__fd, __buf, __nbytes);
49 static ssize_t pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
51 if (lseek(__fd, __offset, SEEK_SET) != __offset) {
54 return write(__fd, __buf, __nbytes);
59 connect to a share - used when a tree_connect operation comes
60 in. For a disk based backend we needs to ensure that the base
61 directory exists (tho it doesn't need to be accessible by the user,
64 static NTSTATUS svfs_connect(struct smbsrv_request *req, const char *sharename)
67 struct smbsrv_tcon *tcon = req->tcon;
68 struct svfs_private *private;
70 tcon->ntvfs_private = talloc_p(tcon, struct svfs_private);
72 private = tcon->ntvfs_private;
74 private->next_search_handle = 0;
75 private->connectpath = talloc_strdup(tcon, lp_pathname(tcon->service));
76 private->open_files = NULL;
78 /* the directory must exist */
79 if (stat(private->connectpath, &st) != 0 || !S_ISDIR(st.st_mode)) {
80 DEBUG(0,("'%s' is not a directory, when connecting to [%s]\n",
81 private->connectpath, sharename));
82 return NT_STATUS_BAD_NETWORK_NAME;
85 tcon->fs_type = talloc_strdup(tcon, "NTFS");
86 tcon->dev_type = talloc_strdup(tcon, "A:");
88 DEBUG(0,("WARNING: ntvfs simple: connect to share [%s] with ROOT privileges!!!\n",sharename));
94 disconnect from a share
96 static NTSTATUS svfs_disconnect(struct smbsrv_tcon *tcon)
102 find open file handle given fd
104 static struct svfs_file *find_fd(struct svfs_private *private, int fd)
107 for (f=private->open_files;f;f=f->next) {
116 delete a file - the dirtype specifies the file types to include in the search.
117 The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
119 static NTSTATUS svfs_unlink(struct smbsrv_request *req, struct smb_unlink *unl)
123 CHECK_READ_ONLY(req);
125 unix_path = svfs_unix_path(req, unl->in.pattern);
127 /* ignoring wildcards ... */
128 if (unlink(unix_path) == -1) {
129 return map_nt_error_from_unix(errno);
137 ioctl interface - we don't do any
139 static NTSTATUS svfs_ioctl(struct smbsrv_request *req, union smb_ioctl *io)
141 return NT_STATUS_INVALID_PARAMETER;
145 check if a directory exists
147 static NTSTATUS svfs_chkpath(struct smbsrv_request *req, struct smb_chkpath *cp)
152 unix_path = svfs_unix_path(req, cp->in.path);
154 if (stat(unix_path, &st) == -1) {
155 return map_nt_error_from_unix(errno);
158 if (!S_ISDIR(st.st_mode)) {
159 return NT_STATUS_NOT_A_DIRECTORY;
166 approximately map a struct stat to a generic fileinfo struct
168 static NTSTATUS svfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info,
169 struct stat *st, const char *unix_path)
171 struct svfs_dir *dir = NULL;
172 char *pattern = NULL;
174 const char *s, *short_name;
176 s = strrchr(unix_path, '/');
183 asprintf(&pattern, "%s:*", unix_path);
186 dir = svfs_list_unix(req, req, pattern);
189 unix_to_nt_time(&info->generic.out.create_time, st->st_ctime);
190 unix_to_nt_time(&info->generic.out.access_time, st->st_atime);
191 unix_to_nt_time(&info->generic.out.write_time, st->st_mtime);
192 unix_to_nt_time(&info->generic.out.change_time, st->st_mtime);
193 info->generic.out.alloc_size = st->st_size;
194 info->generic.out.size = st->st_size;
195 info->generic.out.attrib = svfs_unix_to_dos_attrib(st->st_mode);
196 info->generic.out.alloc_size = st->st_blksize * st->st_blocks;
197 info->generic.out.nlink = st->st_nlink;
198 info->generic.out.directory = S_ISDIR(st->st_mode) ? 1 : 0;
199 info->generic.out.file_id = svfs_file_id(st);
200 /* REWRITE: TODO stuff in here */
201 info->generic.out.delete_pending = 0;
202 info->generic.out.ea_size = 0;
203 info->generic.out.num_eas = 0;
204 info->generic.out.fname.s = talloc_strdup(req, short_name);
205 info->generic.out.alt_fname.s = talloc_strdup(req, short_name);
206 info->generic.out.ex_attrib = 0;
207 info->generic.out.compressed_size = 0;
208 info->generic.out.format = 0;
209 info->generic.out.unit_shift = 0;
210 info->generic.out.chunk_shift = 0;
211 info->generic.out.cluster_shift = 0;
213 info->generic.out.access_flags = 0;
214 info->generic.out.position = 0;
215 info->generic.out.mode = 0;
216 info->generic.out.alignment_requirement = 0;
217 info->generic.out.reparse_tag = 0;
218 info->generic.out.num_streams = 0;
219 /* setup a single data stream */
220 info->generic.out.num_streams = 1 + (dir?dir->count:0);
221 info->generic.out.streams = talloc_array_p(req,
222 struct stream_struct,
223 info->generic.out.num_streams);
224 if (!info->generic.out.streams) {
225 return NT_STATUS_NO_MEMORY;
227 info->generic.out.streams[0].size = st->st_size;
228 info->generic.out.streams[0].alloc_size = st->st_size;
229 info->generic.out.streams[0].stream_name.s = talloc_strdup(req,"::$DATA");
231 for (i=0;dir && i<dir->count;i++) {
232 s = strchr(dir->files[i].name, ':');
233 info->generic.out.streams[1+i].size = dir->files[i].st.st_size;
234 info->generic.out.streams[1+i].alloc_size = dir->files[i].st.st_size;
235 info->generic.out.streams[1+i].stream_name.s = s?s:dir->files[i].name;
242 return info on a pathname
244 static NTSTATUS svfs_qpathinfo(struct smbsrv_request *req, union smb_fileinfo *info)
249 DEBUG(19,("svfs_qpathinfo: file %s level 0x%x\n", info->generic.in.fname, info->generic.level));
250 if (info->generic.level != RAW_FILEINFO_GENERIC) {
251 return ntvfs_map_qpathinfo(req, info);
254 unix_path = svfs_unix_path(req, info->generic.in.fname);
255 DEBUG(19,("svfs_qpathinfo: file %s\n", unix_path));
256 if (stat(unix_path, &st) == -1) {
257 DEBUG(19,("svfs_qpathinfo: file %s errno=%d\n", unix_path, errno));
260 return map_nt_error_from_unix(errno);
262 DEBUG(19,("svfs_qpathinfo: file %s, stat done\n", unix_path));
263 return svfs_map_fileinfo(req, info, &st, unix_path);
267 query info on a open file
269 static NTSTATUS svfs_qfileinfo(struct smbsrv_request *req, union smb_fileinfo *info)
271 struct svfs_private *private = req->tcon->ntvfs_private;
275 if (info->generic.level != RAW_FILEINFO_GENERIC) {
276 return ntvfs_map_qfileinfo(req, info);
279 f = find_fd(private, info->generic.in.fnum);
281 return NT_STATUS_INVALID_HANDLE;
284 if (fstat(info->generic.in.fnum, &st) == -1) {
287 return map_nt_error_from_unix(errno);
290 return svfs_map_fileinfo(req, info, &st, f->name);
297 static NTSTATUS svfs_open(struct smbsrv_request *req, union smb_open *io)
299 struct svfs_private *private = req->tcon->ntvfs_private;
304 int create_flags, rdwr_flags;
306 if (io->generic.level != RAW_OPEN_GENERIC) {
307 return ntvfs_map_open(req, io);
310 if (lp_readonly(req->tcon->service)) {
312 rdwr_flags = O_RDONLY;
314 create_flags = O_CREAT;
318 unix_path = svfs_unix_path(req, io->ntcreatex.in.fname);
320 switch (io->generic.in.open_disposition) {
321 case NTCREATEX_DISP_SUPERSEDE:
322 case NTCREATEX_DISP_OVERWRITE_IF:
323 flags = create_flags | O_TRUNC;
325 case NTCREATEX_DISP_OPEN:
326 case NTCREATEX_DISP_OVERWRITE:
329 case NTCREATEX_DISP_CREATE:
330 flags = create_flags | O_EXCL;
332 case NTCREATEX_DISP_OPEN_IF:
333 flags = create_flags;
342 if (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY) {
343 flags = O_RDONLY | O_DIRECTORY;
344 if (lp_readonly(req->tcon->service)) {
347 switch (io->generic.in.open_disposition) {
348 case NTCREATEX_DISP_CREATE:
349 if (mkdir(unix_path, 0755) == -1) {
350 DEBUG(9,("svfs_open: mkdir %s errno=%d\n", unix_path, errno));
351 return map_nt_error_from_unix(errno);
354 case NTCREATEX_DISP_OPEN_IF:
355 if (mkdir(unix_path, 0755) == -1 && errno != EEXIST) {
356 DEBUG(9,("svfs_open: mkdir %s errno=%d\n", unix_path, errno));
357 return map_nt_error_from_unix(errno);
364 fd = open(unix_path, flags, 0644);
368 return map_nt_error_from_unix(errno);
371 if (fstat(fd, &st) == -1) {
372 DEBUG(9,("svfs_open: fstat errno=%d\n", errno));
376 return map_nt_error_from_unix(errno);
379 f = talloc_p(req->tcon, struct svfs_file);
381 f->name = talloc_strdup(req->tcon, unix_path);
383 DLIST_ADD(private->open_files, f);
385 ZERO_STRUCT(io->generic.out);
387 unix_to_nt_time(&io->generic.out.create_time, st.st_ctime);
388 unix_to_nt_time(&io->generic.out.access_time, st.st_atime);
389 unix_to_nt_time(&io->generic.out.write_time, st.st_mtime);
390 unix_to_nt_time(&io->generic.out.change_time, st.st_mtime);
391 io->generic.out.fnum = fd;
392 io->generic.out.alloc_size = st.st_size;
393 io->generic.out.size = st.st_size;
394 io->generic.out.attrib = svfs_unix_to_dos_attrib(st.st_mode);
395 io->generic.out.is_directory = S_ISDIR(st.st_mode) ? 1 : 0;
403 static NTSTATUS svfs_mkdir(struct smbsrv_request *req, union smb_mkdir *md)
407 CHECK_READ_ONLY(req);
409 if (md->generic.level != RAW_MKDIR_MKDIR) {
410 return NT_STATUS_INVALID_LEVEL;
413 unix_path = svfs_unix_path(req, md->mkdir.in.path);
415 if (mkdir(unix_path, 0777) == -1) {
416 return map_nt_error_from_unix(errno);
425 static NTSTATUS svfs_rmdir(struct smbsrv_request *req, struct smb_rmdir *rd)
429 CHECK_READ_ONLY(req);
431 unix_path = svfs_unix_path(req, rd->in.path);
433 if (rmdir(unix_path) == -1) {
434 return map_nt_error_from_unix(errno);
441 rename a set of files
443 static NTSTATUS svfs_rename(struct smbsrv_request *req, union smb_rename *ren)
445 char *unix_path1, *unix_path2;
447 CHECK_READ_ONLY(req);
449 if (ren->generic.level != RAW_RENAME_RENAME) {
450 return NT_STATUS_INVALID_LEVEL;
453 unix_path1 = svfs_unix_path(req, ren->rename.in.pattern1);
454 unix_path2 = svfs_unix_path(req, ren->rename.in.pattern2);
456 if (rename(unix_path1, unix_path2) != 0) {
457 return map_nt_error_from_unix(errno);
466 static NTSTATUS svfs_copy(struct smbsrv_request *req, struct smb_copy *cp)
468 return NT_STATUS_NOT_SUPPORTED;
474 static NTSTATUS svfs_read(struct smbsrv_request *req, union smb_read *rd)
478 if (rd->generic.level != RAW_READ_READX) {
479 return NT_STATUS_NOT_SUPPORTED;
482 ret = pread(rd->readx.in.fnum,
485 rd->readx.in.offset);
487 return map_nt_error_from_unix(errno);
490 rd->readx.out.nread = ret;
491 rd->readx.out.remaining = 0; /* should fill this in? */
492 rd->readx.out.compaction_mode = 0;
500 static NTSTATUS svfs_write(struct smbsrv_request *req, union smb_write *wr)
504 CHECK_READ_ONLY(req);
506 switch (wr->generic.level) {
507 case RAW_WRITE_WRITEX:
508 ret = pwrite(wr->writex.in.fnum,
511 wr->writex.in.offset);
513 return map_nt_error_from_unix(errno);
516 wr->writex.out.nwritten = ret;
517 wr->writex.out.remaining = 0; /* should fill this in? */
521 case RAW_WRITE_WRITE:
522 if (wr->write.in.count == 0) {
524 ret = ftruncate(wr->write.in.fnum, wr->write.in.offset);
526 ret = pwrite(wr->write.in.fnum,
529 wr->write.in.offset);
532 return map_nt_error_from_unix(errno);
535 wr->write.out.nwritten = ret;
540 return NT_STATUS_NOT_SUPPORTED;
546 static NTSTATUS svfs_seek(struct smbsrv_request *req, struct smb_seek *io)
548 return NT_STATUS_NOT_SUPPORTED;
554 static NTSTATUS svfs_flush(struct smbsrv_request *req, struct smb_flush *io)
563 static NTSTATUS svfs_close(struct smbsrv_request *req, union smb_close *io)
565 struct svfs_private *private = req->tcon->ntvfs_private;
568 if (io->generic.level != RAW_CLOSE_CLOSE) {
569 /* we need a mapping function */
570 return NT_STATUS_INVALID_LEVEL;
573 f = find_fd(private, io->close.in.fnum);
575 return NT_STATUS_INVALID_HANDLE;
578 if (close(io->close.in.fnum) != 0) {
579 return map_nt_error_from_unix(errno);
582 DLIST_REMOVE(private->open_files, f);
583 talloc_free(f->name);
590 exit - closing files?
592 static NTSTATUS svfs_exit(struct smbsrv_request *req)
594 return NT_STATUS_NOT_SUPPORTED;
600 static NTSTATUS svfs_lock(struct smbsrv_request *req, union smb_lock *lck)
602 DEBUG(0,("REWRITE: not doing byte range locking!\n"));
607 set info on a pathname
609 static NTSTATUS svfs_setpathinfo(struct smbsrv_request *req, union smb_setfileinfo *st)
611 CHECK_READ_ONLY(req);
613 return NT_STATUS_NOT_SUPPORTED;
617 set info on a open file
619 static NTSTATUS svfs_setfileinfo(struct smbsrv_request *req,
620 union smb_setfileinfo *info)
622 struct utimbuf unix_times;
625 CHECK_READ_ONLY(req);
627 switch (info->generic.level) {
628 case RAW_SFILEINFO_END_OF_FILE_INFO:
629 case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
630 if (ftruncate(info->end_of_file_info.file.fnum,
631 info->end_of_file_info.in.size) != 0) {
632 return map_nt_error_from_unix(errno);
635 case RAW_SFILEINFO_SETATTRE:
636 unix_times.actime = info->setattre.in.access_time;
637 unix_times.modtime = info->setattre.in.write_time;
638 fd = info->setattre.file.fnum;
640 if (unix_times.actime == 0 && unix_times.modtime == 0) {
644 /* set modify time = to access time if modify time was 0 */
645 if (unix_times.actime != 0 && unix_times.modtime == 0) {
646 unix_times.modtime = unix_times.actime;
649 /* Set the date on this file */
650 if (svfs_file_utime(fd, &unix_times) != 0) {
651 return NT_STATUS_ACCESS_DENIED;
660 return filesystem space info
662 static NTSTATUS svfs_fsinfo(struct smbsrv_request *req, union smb_fsinfo *fs)
664 struct svfs_private *private = req->tcon->ntvfs_private;
667 if (fs->generic.level != RAW_QFS_GENERIC) {
668 return ntvfs_map_fsinfo(req, fs);
671 if (sys_fsusage(private->connectpath,
672 &fs->generic.out.blocks_free,
673 &fs->generic.out.blocks_total) == -1) {
674 return map_nt_error_from_unix(errno);
677 fs->generic.out.block_size = 512;
679 if (stat(private->connectpath, &st) != 0) {
680 return NT_STATUS_DISK_CORRUPT_ERROR;
683 fs->generic.out.fs_id = st.st_ino;
684 unix_to_nt_time(&fs->generic.out.create_time, st.st_ctime);
685 fs->generic.out.serial_number = st.st_ino;
686 fs->generic.out.fs_attr = 0;
687 fs->generic.out.max_file_component_length = 255;
688 fs->generic.out.device_type = 0;
689 fs->generic.out.device_characteristics = 0;
690 fs->generic.out.quota_soft = 0;
691 fs->generic.out.quota_hard = 0;
692 fs->generic.out.quota_flags = 0;
693 fs->generic.out.volume_name = talloc_strdup(req, lp_servicename(req->tcon->service));
694 fs->generic.out.fs_type = req->tcon->fs_type;
701 return filesystem attribute info
703 static NTSTATUS svfs_fsattr(struct smbsrv_request *req, union smb_fsattr *fs)
706 struct svfs_private *private = req->tcon->ntvfs_private;
708 if (fs->generic.level != RAW_FSATTR_GENERIC) {
709 return ntvfs_map_fsattr(req, fs);
712 if (stat(private->connectpath, &st) != 0) {
713 return map_nt_error_from_unix(errno);
716 unix_to_nt_time(&fs->generic.out.create_time, st.st_ctime);
717 fs->generic.out.fs_attr =
718 FILE_CASE_PRESERVED_NAMES |
719 FILE_CASE_SENSITIVE_SEARCH |
720 FILE_PERSISTENT_ACLS;
721 fs->generic.out.max_file_component_length = 255;
722 fs->generic.out.serial_number = 1;
723 fs->generic.out.fs_type = talloc_strdup(req, "NTFS");
724 fs->generic.out.volume_name = talloc_strdup(req,
725 lp_servicename(req->tcon->service));
732 return print queue info
734 static NTSTATUS svfs_lpq(struct smbsrv_request *req, union smb_lpq *lpq)
736 return NT_STATUS_NOT_SUPPORTED;
740 list files in a directory matching a wildcard pattern
742 static NTSTATUS svfs_search_first(struct smbsrv_request *req, union smb_search_first *io,
743 void *search_private,
744 BOOL (*callback)(void *, union smb_search_data *))
746 struct svfs_dir *dir;
748 struct svfs_private *private = req->tcon->ntvfs_private;
749 struct search_state *search;
750 union smb_search_data file;
754 if (io->generic.level != RAW_SEARCH_BOTH_DIRECTORY_INFO) {
755 return NT_STATUS_NOT_SUPPORTED;
758 search = talloc_zero(private, sizeof(struct search_state));
760 return NT_STATUS_NO_MEMORY;
763 max_count = io->t2ffirst.in.max_count;
765 dir = svfs_list(private, req, io->t2ffirst.in.pattern);
767 talloc_free(mem_ctx);
768 return NT_STATUS_FOOBAR;
771 search->handle = private->next_search_handle;
774 if (dir->count < max_count) {
775 max_count = dir->count;
778 for (i=0; i < max_count;i++) {
780 unix_to_nt_time(&file.both_directory_info.create_time, dir->files[i].st.st_ctime);
781 unix_to_nt_time(&file.both_directory_info.access_time, dir->files[i].st.st_atime);
782 unix_to_nt_time(&file.both_directory_info.write_time, dir->files[i].st.st_mtime);
783 unix_to_nt_time(&file.both_directory_info.change_time, dir->files[i].st.st_mtime);
784 file.both_directory_info.name.s = dir->files[i].name;
785 file.both_directory_info.short_name.s = dir->files[i].name;
786 file.both_directory_info.size = dir->files[i].st.st_size;
787 file.both_directory_info.attrib = svfs_unix_to_dos_attrib(dir->files[i].st.st_mode);
789 if (!callback(search_private, &file)) {
794 search->current_index = i;
796 io->t2ffirst.out.count = i;
797 io->t2ffirst.out.handle = search->handle;
798 io->t2ffirst.out.end_of_search = (i == dir->count) ? 1 : 0;
800 /* work out if we are going to keep the search state */
801 if ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE) ||
802 ((io->t2ffirst.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) {
805 private->next_search_handle++;
806 DLIST_ADD(private->search, search);
812 /* continue a search */
813 static NTSTATUS svfs_search_next(struct smbsrv_request *req, union smb_search_next *io,
814 void *search_private,
815 BOOL (*callback)(void *, union smb_search_data *))
817 struct svfs_dir *dir;
819 struct svfs_private *private = req->tcon->ntvfs_private;
820 struct search_state *search;
821 union smb_search_data file;
824 if (io->generic.level != RAW_SEARCH_BOTH_DIRECTORY_INFO) {
825 return NT_STATUS_NOT_SUPPORTED;
828 for (search=private->search; search; search = search->next) {
829 if (search->handle == io->t2fnext.in.handle) break;
833 /* we didn't find the search handle */
834 return NT_STATUS_FOOBAR;
839 /* the client might be asking for something other than just continuing
841 if (!(io->t2fnext.in.flags & FLAG_TRANS2_FIND_CONTINUE) &&
842 (io->t2fnext.in.flags & FLAG_TRANS2_FIND_REQUIRE_RESUME) &&
843 io->t2fnext.in.last_name && *io->t2fnext.in.last_name) {
844 /* look backwards first */
845 for (i=search->current_index; i > 0; i--) {
846 if (strcmp(io->t2fnext.in.last_name, dir->files[i-1].name) == 0) {
847 search->current_index = i;
852 /* then look forwards */
853 for (i=search->current_index+1; i <= dir->count; i++) {
854 if (strcmp(io->t2fnext.in.last_name, dir->files[i-1].name) == 0) {
855 search->current_index = i;
862 max_count = search->current_index + io->t2fnext.in.max_count;
864 if (max_count > dir->count) {
865 max_count = dir->count;
868 for (i = search->current_index; i < max_count;i++) {
870 unix_to_nt_time(&file.both_directory_info.create_time, dir->files[i].st.st_ctime);
871 unix_to_nt_time(&file.both_directory_info.access_time, dir->files[i].st.st_atime);
872 unix_to_nt_time(&file.both_directory_info.write_time, dir->files[i].st.st_mtime);
873 unix_to_nt_time(&file.both_directory_info.change_time, dir->files[i].st.st_mtime);
874 file.both_directory_info.name.s = dir->files[i].name;
875 file.both_directory_info.short_name.s = dir->files[i].name;
876 file.both_directory_info.size = dir->files[i].st.st_size;
877 file.both_directory_info.attrib = svfs_unix_to_dos_attrib(dir->files[i].st.st_mode);
879 if (!callback(search_private, &file)) {
884 io->t2fnext.out.count = i - search->current_index;
885 io->t2fnext.out.end_of_search = (i == dir->count) ? 1 : 0;
887 search->current_index = i;
889 /* work out if we are going to keep the search state */
890 if ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE) ||
891 ((io->t2fnext.in.flags & FLAG_TRANS2_FIND_CLOSE_IF_END) && (i == dir->count))) {
892 DLIST_REMOVE(private->search, search);
900 static NTSTATUS svfs_search_close(struct smbsrv_request *req, union smb_search_close *io)
902 struct svfs_private *private = req->tcon->ntvfs_private;
903 struct search_state *search;
905 for (search=private->search; search; search = search->next) {
906 if (search->handle == io->findclose.in.handle) break;
910 /* we didn't find the search handle */
911 return NT_STATUS_FOOBAR;
914 DLIST_REMOVE(private->search, search);
920 /* SMBtrans - not used on file shares */
921 static NTSTATUS svfs_trans(struct smbsrv_request *req, struct smb_trans2 *trans2)
923 return NT_STATUS_ACCESS_DENIED;
928 initialialise the POSIX disk backend, registering ourselves with the ntvfs subsystem
930 NTSTATUS ntvfs_simple_init(void)
933 struct ntvfs_ops ops;
937 /* fill in the name and type */
938 ops.type = NTVFS_DISK;
940 /* fill in all the operations */
941 ops.connect = svfs_connect;
942 ops.disconnect = svfs_disconnect;
943 ops.unlink = svfs_unlink;
944 ops.chkpath = svfs_chkpath;
945 ops.qpathinfo = svfs_qpathinfo;
946 ops.setpathinfo = svfs_setpathinfo;
947 ops.open = svfs_open;
948 ops.mkdir = svfs_mkdir;
949 ops.rmdir = svfs_rmdir;
950 ops.rename = svfs_rename;
951 ops.copy = svfs_copy;
952 ops.ioctl = svfs_ioctl;
953 ops.read = svfs_read;
954 ops.write = svfs_write;
955 ops.seek = svfs_seek;
956 ops.flush = svfs_flush;
957 ops.close = svfs_close;
958 ops.exit = svfs_exit;
959 ops.lock = svfs_lock;
960 ops.setfileinfo = svfs_setfileinfo;
961 ops.qfileinfo = svfs_qfileinfo;
962 ops.fsinfo = svfs_fsinfo;
964 ops.search_first = svfs_search_first;
965 ops.search_next = svfs_search_next;
966 ops.search_close = svfs_search_close;
967 ops.trans = svfs_trans;
969 /* register ourselves with the NTVFS subsystem. We register
973 ret = register_backend("ntvfs", &ops);
975 if (!NT_STATUS_IS_OK(ret)) {
976 DEBUG(0,("Failed to register simple backend with name: %s!\n",