2 Unix SMB/CIFS implementation.
3 filename handling routines
4 Copyright (C) Andrew Tridgell 1992-1998
5 Copyright (C) Jeremy Allison 1999-2007
6 Copyright (C) Ying Chen 2000
7 Copyright (C) Volker Lendecke 2007
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * New hash table stat cache code added by Ying Chen.
29 static NTSTATUS
build_stream_path(TALLOC_CTX
*mem_ctx
,
30 connection_struct
*conn
,
31 const char *orig_path
,
32 struct smb_filename
*smb_fname
);
34 /****************************************************************************
35 Mangle the 2nd name and check if it is then equal to the first name.
36 ****************************************************************************/
38 static bool mangled_equal(const char *name1
,
40 const struct share_params
*p
)
44 if (!name_to_8_3(name2
, mname
, False
, p
)) {
47 return strequal(name1
, mname
);
50 /****************************************************************************
51 Cope with the differing wildcard and non-wildcard error cases.
52 ****************************************************************************/
54 static NTSTATUS
determine_path_error(const char *name
,
55 bool allow_wcard_last_component
)
59 if (!allow_wcard_last_component
) {
60 /* Error code within a pathname. */
61 return NT_STATUS_OBJECT_PATH_NOT_FOUND
;
64 /* We're terminating here so we
65 * can be a little slower and get
66 * the error code right. Windows
67 * treats the last part of the pathname
68 * separately I think, so if the last
69 * component is a wildcard then we treat
70 * this ./ as "end of component" */
72 p
= strchr(name
, '/');
74 if (!p
&& (ms_has_wild(name
) || ISDOT(name
))) {
75 /* Error code at the end of a pathname. */
76 return NT_STATUS_OBJECT_NAME_INVALID
;
78 /* Error code within a pathname. */
79 return NT_STATUS_OBJECT_PATH_NOT_FOUND
;
83 NTSTATUS
get_full_smb_filename(TALLOC_CTX
*ctx
, const struct smb_filename
*smb_fname
,
86 if (smb_fname
->stream_name
) {
87 *full_name
= talloc_asprintf(ctx
, "%s%s", smb_fname
->base_name
,
88 smb_fname
->stream_name
);
90 *full_name
= talloc_strdup(ctx
, smb_fname
->base_name
);
94 return NT_STATUS_NO_MEMORY
;
100 /****************************************************************************
101 This routine is called to convert names from the dos namespace to unix
102 namespace. It needs to handle any case conversions, mangling, format changes,
105 We assume that we have already done a chdir() to the right "root" directory
108 The function will return an NTSTATUS error if some part of the name except for
109 the last part cannot be resolved, else NT_STATUS_OK.
111 Note NT_STATUS_OK doesn't mean the name exists or is valid, just that we
112 didn't get any fatal errors that should immediately terminate the calling SMB
113 processing whilst resolving.
115 If the UCF_SAVE_LCOMP flag is passed in, then the unmodified last component
116 of the pathname is set in smb_filename->original_lcomp.
118 If UCF_ALLOW_WCARD_LCOMP is passed in, then a MS wildcard was detected and
119 should be allowed in the last component of the path only.
121 If the orig_path was a stream, smb_filename->base_name will point to the base
122 filename, and smb_filename->stream_name will point to the stream name. If
123 orig_path was not a stream, then smb_filename->stream_name will be NULL.
125 On exit from unix_convert, the smb_filename->st stat struct will be populated
126 if the file exists and was found, if not this stat struct will be filled with
127 zeros (and this can be detected by checking for nlinks = 0, which can never be
129 ****************************************************************************/
131 NTSTATUS
unix_convert(TALLOC_CTX
*ctx
,
132 connection_struct
*conn
,
133 const char *orig_path
,
134 struct smb_filename
**smb_fname_out
,
138 struct smb_filename
*smb_fname
= NULL
;
140 char *dirpath
= NULL
;
143 bool component_was_mangled
= False
;
144 bool name_has_wildcard
= False
;
145 bool posix_pathnames
= false;
146 bool allow_wcard_last_component
= ucf_flags
& UCF_ALLOW_WCARD_LCOMP
;
147 bool save_last_component
= ucf_flags
& UCF_SAVE_LCOMP
;
151 *smb_fname_out
= NULL
;
153 smb_fname
= TALLOC_ZERO_P(talloc_tos(), struct smb_filename
);
154 if (smb_fname
== NULL
) {
155 return NT_STATUS_NO_MEMORY
;
159 /* we don't ever use the filenames on a printer share as a
160 filename - so don't convert them */
161 if (!(smb_fname
->base_name
= talloc_strdup(smb_fname
,
163 return NT_STATUS_NO_MEMORY
;
165 *smb_fname_out
= smb_fname
;
169 DEBUG(5, ("unix_convert called on file \"%s\"\n", orig_path
));
172 * Conversion to basic unix format is already done in
173 * check_path_syntax().
177 * Names must be relative to the root of the service - any leading /.
178 * and trailing /'s should have been trimmed by check_path_syntax().
182 SMB_ASSERT(*orig_path
!= '/');
186 * If we trimmed down to a single '\0' character
187 * then we should use the "." directory to avoid
188 * searching the cache, but not if we are in a
190 * As we know this is valid we can return true here.
194 if (!(name
= talloc_strdup(ctx
,"."))) {
195 return NT_STATUS_NO_MEMORY
;
197 if (SMB_VFS_STAT(conn
,name
,&st
) == 0) {
200 return map_nt_error_from_unix(errno
);
202 DEBUG(5,("conversion finished \"\" -> %s\n",name
));
206 if (orig_path
[0] == '.' && (orig_path
[1] == '/' ||
207 orig_path
[1] == '\0')) {
208 /* Start of pathname can't be "." only. */
209 if (orig_path
[1] == '\0' || orig_path
[2] == '\0') {
210 result
= NT_STATUS_OBJECT_NAME_INVALID
;
212 result
=determine_path_error(
213 &orig_path
[2], allow_wcard_last_component
);
218 if (!(name
= talloc_strdup(ctx
, orig_path
))) {
219 DEBUG(0, ("talloc_strdup failed\n"));
220 return NT_STATUS_NO_MEMORY
;
224 * Large directory fix normalization. If we're case sensitive, and
225 * the case preserving parameters are set to "no", normalize the case of
226 * the incoming filename from the client WHETHER IT EXISTS OR NOT !
227 * This is in conflict with the current (3.0.20) man page, but is
228 * what people expect from the "large directory howto". I'll update
229 * the man page. Thanks to jht@samba.org for finding this. JRA.
232 if (conn
->case_sensitive
&& !conn
->case_preserve
&&
233 !conn
->short_case_preserve
) {
234 strnorm(name
, lp_defaultcase(SNUM(conn
)));
238 * Ensure saved_last_component is valid even if file exists.
241 if(save_last_component
) {
242 end
= strrchr_m(name
, '/');
244 smb_fname
->original_lcomp
= talloc_strdup(ctx
,
247 smb_fname
->original_lcomp
= talloc_strdup(ctx
, name
);
251 posix_pathnames
= lp_posix_pathnames();
253 /* Strip off the stream. Should we use any of the other stream parsing
254 * at this point? Also, should we set the is_stream bit? */
255 if (!posix_pathnames
) {
256 stream
= strchr_m(name
, ':');
258 if (stream
!= NULL
) {
259 char *tmp
= talloc_strdup(ctx
, stream
);
262 return NT_STATUS_NO_MEMORY
;
271 /* If we're providing case insentive semantics or
272 * the underlying filesystem is case insensitive,
273 * then a case-normalized hit in the stat-cache is
274 * authoratitive. JRA.
277 if((!conn
->case_sensitive
|| !(conn
->fs_capabilities
& FILE_CASE_SENSITIVE_SEARCH
)) &&
278 stat_cache_lookup(conn
, &name
, &dirpath
, &start
, &st
)) {
284 * Make sure "dirpath" is an allocated string, we use this for
285 * building the directories with asprintf and free it.
288 if ((dirpath
== NULL
) && (!(dirpath
= talloc_strdup(ctx
,"")))) {
289 DEBUG(0, ("talloc_strdup failed\n"));
291 return NT_STATUS_NO_MEMORY
;
295 * stat the name - if it exists then we are all done!
298 if (posix_pathnames
) {
299 ret
= SMB_VFS_LSTAT(conn
,name
,&st
);
301 ret
= SMB_VFS_STAT(conn
,name
,&st
);
305 /* Ensure we catch all names with in "/."
306 this is disallowed under Windows. */
307 const char *p
= strstr(name
, "/."); /* mb safe. */
310 /* Error code within a pathname. */
311 result
= NT_STATUS_OBJECT_PATH_NOT_FOUND
;
313 } else if (p
[2] == '\0') {
314 /* Error code at the end of a pathname. */
315 result
= NT_STATUS_OBJECT_NAME_INVALID
;
319 stat_cache_add(orig_path
, name
, conn
->case_sensitive
);
320 DEBUG(5,("conversion finished %s -> %s\n",orig_path
, name
));
325 DEBUG(5,("unix_convert begin: name = %s, dirpath = %s, start = %s\n",
326 name
, dirpath
, start
));
329 * A special case - if we don't have any mangling chars and are case
330 * sensitive or the underlying filesystem is case insentive then searching
334 if ((conn
->case_sensitive
|| !(conn
->fs_capabilities
& FILE_CASE_SENSITIVE_SEARCH
)) &&
335 !mangle_is_mangled(name
, conn
->params
)) {
340 * is_mangled() was changed to look at an entire pathname, not
341 * just a component. JRA.
344 if (mangle_is_mangled(start
, conn
->params
)) {
345 component_was_mangled
= True
;
349 * Now we need to recursively match the name against the real
350 * directory structure.
354 * Match each part of the path name separately, trying the names
355 * as is first, then trying to scan the directory for matching names.
358 for (; start
; start
= (end
?end
+1:(char *)NULL
)) {
360 * Pinpoint the end of this section of the filename.
362 /* mb safe. '/' can't be in any encoded char. */
363 end
= strchr(start
, '/');
366 * Chop the name at this point.
372 if (save_last_component
) {
373 TALLOC_FREE(smb_fname
->original_lcomp
);
374 smb_fname
->original_lcomp
= talloc_strdup(ctx
,
375 end
? end
+ 1 : start
);
376 if (!smb_fname
->original_lcomp
) {
377 DEBUG(0, ("talloc failed\n"));
378 return NT_STATUS_NO_MEMORY
;
382 /* The name cannot have a component of "." */
386 /* Error code at the end of a pathname. */
387 result
= NT_STATUS_OBJECT_NAME_INVALID
;
389 result
= determine_path_error(end
+1,
390 allow_wcard_last_component
);
395 /* The name cannot have a wildcard if it's not
396 the last component. */
398 name_has_wildcard
= ms_has_wild(start
);
400 /* Wildcard not valid anywhere. */
401 if (name_has_wildcard
&& !allow_wcard_last_component
) {
402 result
= NT_STATUS_OBJECT_NAME_INVALID
;
406 /* Wildcards never valid within a pathname. */
407 if (name_has_wildcard
&& end
) {
408 result
= NT_STATUS_OBJECT_NAME_INVALID
;
413 * Check if the name exists up to this point.
416 if (posix_pathnames
) {
417 ret
= SMB_VFS_LSTAT(conn
,name
, &st
);
419 ret
= SMB_VFS_STAT(conn
,name
, &st
);
424 * It exists. it must either be a directory or this must
425 * be the last part of the path for it to be OK.
427 if (end
&& !S_ISDIR(st
.st_ex_mode
)) {
429 * An intermediate part of the name isn't
432 DEBUG(5,("Not a dir %s\n",start
));
435 * We need to return the fact that the
436 * intermediate name resolution failed. This
437 * is used to return an error of ERRbadpath
438 * rather than ERRbadfile. Some Windows
439 * applications depend on the difference between
442 result
= NT_STATUS_OBJECT_PATH_NOT_FOUND
;
448 * We just scanned for, and found the end of
449 * the path. We must return the valid stat
457 char *found_name
= NULL
;
459 /* Stat failed - ensure we don't use it. */
460 SET_STAT_INVALID(st
);
463 * Reset errno so we can detect
464 * directory open errors.
469 * Try to find this part of the path in the directory.
472 if (name_has_wildcard
||
473 (get_real_filename(conn
, dirpath
, start
,
475 &found_name
) == -1)) {
480 * An intermediate part of the name
483 DEBUG(5,("Intermediate not found %s\n",
488 * We need to return the fact that the
489 * intermediate name resolution failed.
490 * This is used to return an error of
491 * ERRbadpath rather than ERRbadfile.
492 * Some Windows applications depend on
493 * the difference between these two
498 * ENOENT, ENOTDIR and ELOOP all map
499 * to NT_STATUS_OBJECT_PATH_NOT_FOUND
500 * in the filename walk.
503 if (errno
== ENOENT
||
507 NT_STATUS_OBJECT_PATH_NOT_FOUND
;
511 map_nt_error_from_unix(errno
);
516 /* ENOENT is the only valid error here. */
517 if ((errno
!= 0) && (errno
!= ENOENT
)) {
519 * ENOTDIR and ELOOP both map to
520 * NT_STATUS_OBJECT_PATH_NOT_FOUND
521 * in the filename walk.
523 if (errno
== ENOTDIR
||
526 NT_STATUS_OBJECT_PATH_NOT_FOUND
;
528 } else if (errno
!= EACCES
) {
530 map_nt_error_from_unix(errno
);
536 * Just the last part of the name doesn't exist.
537 * We need to strupper() or strlower() it as
538 * this conversion may be used for file creation
539 * purposes. Fix inspired by
540 * Thomas Neumann <t.neumann@iku-ag.de>.
542 if (!conn
->case_preserve
||
543 (mangle_is_8_3(start
, False
,
545 !conn
->short_case_preserve
)) {
547 lp_defaultcase(SNUM(conn
)));
551 * check on the mangled stack to see if we can
552 * recover the base of the filename.
555 if (mangle_is_mangled(start
, conn
->params
)
556 && mangle_lookup_name_from_8_3(ctx
,
561 size_t start_ofs
= start
- name
;
563 if (*dirpath
!= '\0') {
564 tmp
= talloc_asprintf(ctx
,
567 TALLOC_FREE(unmangled
);
573 DEBUG(0, ("talloc failed\n"));
574 return NT_STATUS_NO_MEMORY
;
578 start
= name
+ start_ofs
;
579 end
= start
+ strlen(start
);
582 DEBUG(5,("New file %s\n",start
));
588 * Restore the rest of the string. If the string was
589 * mangled the size may have changed.
593 size_t start_ofs
= start
- name
;
595 if (*dirpath
!= '\0') {
596 tmp
= talloc_asprintf(ctx
,
601 tmp
= talloc_asprintf(ctx
,
606 DEBUG(0, ("talloc_asprintf failed\n"));
607 return NT_STATUS_NO_MEMORY
;
611 start
= name
+ start_ofs
;
612 end
= start
+ strlen(found_name
);
616 size_t start_ofs
= start
- name
;
618 if (*dirpath
!= '\0') {
619 tmp
= talloc_asprintf(ctx
,
623 tmp
= talloc_strdup(ctx
,
627 DEBUG(0, ("talloc failed\n"));
628 return NT_STATUS_NO_MEMORY
;
632 start
= name
+ start_ofs
;
635 * We just scanned for, and found the end of
636 * the path. We must return a valid stat struct
640 if (posix_pathnames
) {
641 ret
= SMB_VFS_LSTAT(conn
,name
, &st
);
643 ret
= SMB_VFS_STAT(conn
,name
, &st
);
649 SET_STAT_INVALID(st
);
653 TALLOC_FREE(found_name
);
659 * We should never provide different behaviors
660 * depending on DEVELOPER!!!
662 if (VALID_STAT(st
)) {
664 get_file_infos(vfs_file_id_from_sbuf(conn
, &st
),
665 &delete_pending
, NULL
);
666 if (delete_pending
) {
667 result
= NT_STATUS_DELETE_PENDING
;
674 * Add to the dirpath that we have resolved so far.
677 if (*dirpath
!= '\0') {
678 char *tmp
= talloc_asprintf(ctx
,
679 "%s/%s", dirpath
, start
);
681 DEBUG(0, ("talloc_asprintf failed\n"));
682 return NT_STATUS_NO_MEMORY
;
684 TALLOC_FREE(dirpath
);
688 TALLOC_FREE(dirpath
);
689 if (!(dirpath
= talloc_strdup(ctx
,start
))) {
690 DEBUG(0, ("talloc_strdup failed\n"));
691 return NT_STATUS_NO_MEMORY
;
696 * Don't cache a name with mangled or wildcard components
697 * as this can change the size.
700 if(!component_was_mangled
&& !name_has_wildcard
) {
701 stat_cache_add(orig_path
, dirpath
,
702 conn
->case_sensitive
);
706 * Restore the / that we wiped out earlier.
714 * Don't cache a name with mangled or wildcard components
715 * as this can change the size.
718 if(!component_was_mangled
&& !name_has_wildcard
) {
719 stat_cache_add(orig_path
, name
, conn
->case_sensitive
);
723 * The name has been resolved.
726 DEBUG(5,("conversion finished %s -> %s\n",orig_path
, name
));
729 smb_fname
->base_name
= name
;
731 if (stream
!= NULL
) {
732 smb_fname
->stream_name
= stream
;
734 /* Check path now that the base_name has been converted. */
735 result
= build_stream_path(ctx
, conn
, orig_path
, smb_fname
);
736 if (!NT_STATUS_IS_OK(result
)) {
740 TALLOC_FREE(dirpath
);
741 *smb_fname_out
= smb_fname
;
744 DEBUG(10, ("dirpath = [%s] start = [%s]\n", dirpath
, start
));
745 if (*dirpath
!= '\0') {
746 smb_fname
->base_name
= talloc_asprintf(ctx
, "%s/%s", dirpath
,
749 smb_fname
->base_name
= talloc_strdup(ctx
, start
);
751 if (!smb_fname
->base_name
) {
752 DEBUG(0, ("talloc_asprintf failed\n"));
753 return NT_STATUS_NO_MEMORY
;
756 *smb_fname_out
= smb_fname
;
758 TALLOC_FREE(dirpath
);
762 /****************************************************************************
763 Check a filename - possibly calling check_reduced_name.
764 This is called by every routine before it allows an operation on a filename.
765 It does any final confirmation necessary to ensure that the filename is
766 a valid one for the user to access.
767 ****************************************************************************/
769 NTSTATUS
check_name(connection_struct
*conn
, const char *name
)
771 if (IS_VETO_PATH(conn
, name
)) {
772 /* Is it not dot or dot dot. */
773 if (!((name
[0] == '.') && (!name
[1] ||
774 (name
[1] == '.' && !name
[2])))) {
775 DEBUG(5,("check_name: file path name %s vetoed\n",
777 return map_nt_error_from_unix(ENOENT
);
781 if (!lp_widelinks(SNUM(conn
)) || !lp_symlinks(SNUM(conn
))) {
782 NTSTATUS status
= check_reduced_name(conn
,name
);
783 if (!NT_STATUS_IS_OK(status
)) {
784 DEBUG(5,("check_name: name %s failed with %s\n",name
,
793 /****************************************************************************
794 Check if two filenames are equal.
795 This needs to be careful about whether we are case sensitive.
796 ****************************************************************************/
798 static bool fname_equal(const char *name1
, const char *name2
,
801 /* Normal filename handling */
802 if (case_sensitive
) {
803 return(strcmp(name1
,name2
) == 0);
806 return(strequal(name1
,name2
));
809 /****************************************************************************
810 Scan a directory to find a filename, matching without case sensitivity.
811 If the name looks like a mangled name then try via the mangling functions
812 ****************************************************************************/
814 static int get_real_filename_full_scan(connection_struct
*conn
,
815 const char *path
, const char *name
,
817 TALLOC_CTX
*mem_ctx
, char **found_name
)
819 struct smb_Dir
*cur_dir
;
821 char *unmangled_name
= NULL
;
824 /* handle null paths */
825 if ((path
== NULL
) || (*path
== 0)) {
829 /* If we have a case-sensitive filesystem, it doesn't do us any
830 * good to search for a name. If a case variation of the name was
831 * there, then the original stat(2) would have found it.
833 if (!mangled
&& !(conn
->fs_capabilities
& FILE_CASE_SENSITIVE_SEARCH
)) {
839 * The incoming name can be mangled, and if we de-mangle it
840 * here it will not compare correctly against the filename (name2)
841 * read from the directory and then mangled by the name_to_8_3()
842 * call. We need to mangle both names or neither.
845 * Fix for bug found by Dina Fine. If in case sensitive mode then
846 * the mangle cache is no good (3 letter extension could be wrong
847 * case - so don't demangle in this case - leave as mangled and
848 * allow the mangling of the directory entry read (which is done
849 * case insensitively) to match instead. This will lead to more
850 * false positive matches but we fail completely without it. JRA.
853 if (mangled
&& !conn
->case_sensitive
) {
854 mangled
= !mangle_lookup_name_from_8_3(talloc_tos(), name
,
858 /* Name is now unmangled. */
859 name
= unmangled_name
;
863 /* open the directory */
864 if (!(cur_dir
= OpenDir(talloc_tos(), conn
, path
, NULL
, 0))) {
865 DEBUG(3,("scan dir didn't open dir [%s]\n",path
));
866 TALLOC_FREE(unmangled_name
);
870 /* now scan for matching names */
872 while ((dname
= ReadDirName(cur_dir
, &curpos
, NULL
))) {
874 /* Is it dot or dot dot. */
875 if (ISDOT(dname
) || ISDOTDOT(dname
)) {
880 * At this point dname is the unmangled name.
881 * name is either mangled or not, depending on the state
882 * of the "mangled" variable. JRA.
886 * Check mangled name against mangled name, or unmangled name
887 * against unmangled name.
890 if ((mangled
&& mangled_equal(name
,dname
,conn
->params
)) ||
891 fname_equal(name
, dname
, conn
->case_sensitive
)) {
892 /* we've found the file, change it's name and return */
893 *found_name
= talloc_strdup(mem_ctx
, dname
);
894 TALLOC_FREE(unmangled_name
);
895 TALLOC_FREE(cur_dir
);
904 TALLOC_FREE(unmangled_name
);
905 TALLOC_FREE(cur_dir
);
910 /****************************************************************************
911 Wrapper around the vfs get_real_filename and the full directory scan
913 ****************************************************************************/
915 int get_real_filename(connection_struct
*conn
, const char *path
,
916 const char *name
, TALLOC_CTX
*mem_ctx
,
922 mangled
= mangle_is_mangled(name
, conn
->params
);
925 return get_real_filename_full_scan(conn
, path
, name
, mangled
,
926 mem_ctx
, found_name
);
929 /* Try the vfs first to take advantage of case-insensitive stat. */
930 ret
= SMB_VFS_GET_REAL_FILENAME(conn
, path
, name
, mem_ctx
, found_name
);
933 * If the case-insensitive stat was successful, or returned an error
934 * other than EOPNOTSUPP then there is no need to fall back on the
935 * full directory scan.
937 if (ret
== 0 || (ret
== -1 && errno
!= EOPNOTSUPP
)) {
941 return get_real_filename_full_scan(conn
, path
, name
, mangled
, mem_ctx
,
945 static NTSTATUS
build_stream_path(TALLOC_CTX
*mem_ctx
,
946 connection_struct
*conn
,
947 const char *orig_path
,
948 struct smb_filename
*smb_fname
)
952 unsigned int i
, num_streams
;
953 struct stream_struct
*streams
= NULL
;
955 status
= get_full_smb_filename(mem_ctx
, smb_fname
, &result
);
956 if (!NT_STATUS_IS_OK(status
)) {
957 return NT_STATUS_NO_MEMORY
;
960 if (SMB_VFS_STAT(conn
, result
, &smb_fname
->st
) == 0) {
964 if (errno
!= ENOENT
) {
965 status
= map_nt_error_from_unix(errno
);
966 DEBUG(10, ("vfs_stat failed: %s\n", nt_errstr(status
)));
970 /* Fall back to a case-insensitive scan of all streams on the file. */
971 status
= SMB_VFS_STREAMINFO(conn
, NULL
, smb_fname
->base_name
, mem_ctx
,
972 &num_streams
, &streams
);
974 if (NT_STATUS_EQUAL(status
, NT_STATUS_OBJECT_NAME_NOT_FOUND
)) {
975 SET_STAT_INVALID(smb_fname
->st
);
979 if (!NT_STATUS_IS_OK(status
)) {
980 DEBUG(10, ("vfs_streaminfo failed: %s\n", nt_errstr(status
)));
984 for (i
=0; i
<num_streams
; i
++) {
985 DEBUG(10, ("comparing [%s] and [%s]: ",
986 smb_fname
->stream_name
, streams
[i
].name
));
987 if (fname_equal(smb_fname
->stream_name
, streams
[i
].name
,
988 conn
->case_sensitive
)) {
989 DEBUGADD(10, ("equal\n"));
992 DEBUGADD(10, ("not equal\n"));
995 /* Couldn't find the stream. */
996 if (i
== num_streams
) {
997 SET_STAT_INVALID(smb_fname
->st
);
998 TALLOC_FREE(streams
);
1002 DEBUG(10, ("case insensitive stream. requested: %s, actual: %s\n",
1003 smb_fname
->stream_name
, streams
[i
].name
));
1006 TALLOC_FREE(smb_fname
->stream_name
);
1007 smb_fname
->stream_name
= talloc_strdup(mem_ctx
, streams
[i
].name
);
1009 TALLOC_FREE(result
);
1010 status
= get_full_smb_filename(mem_ctx
, smb_fname
, &result
);
1011 if (!NT_STATUS_IS_OK(status
)) {
1012 status
= NT_STATUS_NO_MEMORY
;
1016 SET_STAT_INVALID(smb_fname
->st
);
1018 if (SMB_VFS_STAT(conn
, result
, &smb_fname
->st
) == 0) {
1019 stat_cache_add(orig_path
, result
, conn
->case_sensitive
);
1022 TALLOC_FREE(streams
);
1023 return NT_STATUS_OK
;
1026 TALLOC_FREE(result
);
1027 TALLOC_FREE(streams
);