struct smb_filename documentation?
tprouty at samba.org
Mon Nov 30 16:06:35 MST 2009
On Nov 29, 2009, at 11:37 PM, Olivier Sessink wrote:
> Hi all,
> what do the fields of struct smb_filename mean? smb.h could use some
> comments on this one.
> char *base_name; -> the full path? or just the filename without
> directory components?
> char *stream_name; -> ?
> char *original_lcomp; -> ?
> SMB_STRUCT_STAT st; -> I suppose this can be used if VALID_STAT()
> returns true ? And when is it set?
The smb_filename struct was added to simplify stream handling and fix
some correctness bugs. Previously char *s were passed around for
filenames, which meant that everytime you wanted to know if you were
dealing with a stream or a file, you had to re-parse the char * to see
if it contains a ':'. It turns out it much cleaner to parse the name
once when its fresh off the wire in one place. See
filename_convert()/unix_convert(). The initial commit explains some
base_name should be the path relative to the current working directory
including directory components, but not the stream if one was
stream_name is everything following the ':' if one was specified by
the client, otherwise it is NULL.
original_lcomp is used in a few special casees in the rename path, and
was the result of refactoring some legacy code. It would likely be
possible to refactor parts of the rename path to eliminate the need
for this field.
st is the stat of the smb_filename (base_name + stream_name) and is
typically set during unix_convert() when resolving the path if the
file existed and during create_file() if it didn't. All standard stat
functions such as VALID_STAT() can be used on it.
More information about the samba-technical