da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * smb_com_search
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * smb_com_find, smb_com_find_close
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * smb_find_unique
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * These commands are used for directory searching. They share the same
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * message formats, defined below:
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Client Request Description
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ---------------------------------- ---------------------------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR WordCount; Count of parameter words = 2
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * USHORT MaxCount; Number of dir. entries to return
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * USHORT SearchAttributes;
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * USHORT ByteCount; Count of data bytes; min = 5
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR BufferFormat1; 0x04 -- ASCII
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR FileName[]; File name, may be null
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR BufferFormat2; 0x05 -- Variable block
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * USHORT ResumeKeyLength; Length of resume key, may be 0
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR ResumeKey[]; Resume key
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * FileName specifies the file to be sought. SearchAttributes indicates
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * the attributes that the file must have. If SearchAttributes is
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * zero then only normal files are returned. If the system file, hidden or
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * directory attributes are specified then the search is inclusive - both the
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * specified type(s) of files and normal files are returned. If the volume
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * label attribute is specified then the search is exclusive, and only the
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * volume label entry is returned.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * MaxCount specifies the number of directory entries to be returned.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Server Response Description
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ---------------------------------- ---------------------------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR WordCount; Count of parameter words = 1
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * USHORT Count; Number of entries returned
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * USHORT ByteCount; Count of data bytes; min = 3
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR BufferFormat; 0x05 -- Variable block
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * USHORT DataLength; Length of data
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR DirectoryInformationData[]; Data
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The response will contain one or more directory entries as determined by
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * the Count field. No more than MaxCount entries will be returned. Only
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * entries that match the sought FileName and SearchAttributes combination
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * will be returned.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ResumeKey must be null (length = 0) on the initial search request.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Subsequent search requests intended to continue a search must contain
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * the ResumeKey field extracted from the last directory entry of the
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * previous response. ResumeKey is self-contained, for calls containing
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * a non-zero ResumeKey neither the SearchAttributes or FileName fields
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * will be valid in the request. ResumeKey has the following format:
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Resume Key Field Description
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ---------------------------------- ---------------------------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR Reserved; bit 7 - consumer use
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * bits 5,6 - system use (must preserve)
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * bits 0-4 - server use (must preserve)
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR FileName[11]; Name of the returned file
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR ReservedForServer[5]; Client must not modify
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * byte 0 - uniquely identifies find
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * through find_close
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * bytes 1-4 - available for server use
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * (must be non-zero)
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR ReservedForConsumer[4]; Server must not modify
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * FileName is 8.3 format, with the three character extension left
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * justified into FileName[9-11].
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * There may be multiple matching entries in response to a single request
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * as wildcards are supported in the last component of FileName of the
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * initial request.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Returned directory entries in the DirectoryInformationData field of the
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * response each have the following format:
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Directory Information Field Description
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ---------------------------------- ---------------------------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * SMB_RESUME_KEY ResumeKey; Described above
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR FileAttributes; Attributes of the found file
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * SMB_TIME LastWriteTime; Time file was last written
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * SMB_DATE LastWriteDate; Date file was last written
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ULONG FileSize; Size of the file
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * UCHAR FileName[13]; ASCII, space-filled null terminated
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * FileName must conform to 8.3 rules, and is padded after the extension
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * with 0x20 characters if necessary.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * As can be seen from the above structure, these commands cannot return
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * long filenames, and cannot return UNICODE filenames.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Files which have a size greater than 2^32 bytes should have the least
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * significant 32 bits of their size returned in FileSize.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * smb_com_search
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * --------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * If the client is prior to the LANMAN1.0 dialect, the returned FileName
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * should be uppercased.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * If the client has negotiated a dialect prior to the LANMAN1.0 dialect,
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * or if bit0 of the Flags2 SMB header field of the request is clear,
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * the returned FileName should be uppercased.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * SMB_COM_SEARCH terminates when either the requested maximum number of
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * entries that match the named file are found, or the end of directory is
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * reached without the maximum number of matches being found. A response
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * containing no entries indicates that no matching entries were found
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * between the starting point of the search and the end of directory.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The find, find_close and find_unique protocols may be used in place of
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * the core "search" protocol when LANMAN 1.0 dialect has been negotiated.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * smb_com_find
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The find protocol is used to match the find OS/2 system call.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The format of the find protocol is the same as the core "search" protocol.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The difference is that the directory is logically Opened with a find protocol
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * and logically closed with the find close protocol.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * As is true of a failing open, if a find request (find "first" request where
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * resume_key is null) fails (no entries are found), no find close protocol is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * expected.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * If no global characters are present, a "find unique" protocol should be used
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * (only one entry is expected and find close need not be sent).
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * A find request will terminate when either the requested maximum number of
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * entries that match the named file are found, or the end of directory is
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * reached without the maximum number of matches being found. A response
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * containing no entries indicates that no matching entries were found between
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * the starting point of the search and the end of directory.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * If a find requests more data than can be placed in a message of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * max-xmit-size for the TID specified, the server will return only the number
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * of entries which will fit.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * smb_com_find_close
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * ------------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The find close protocol is used to match the find close OS/2 system call.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Whereas the first find protocol logically opens the directory, subsequent
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * find protocols presenting a resume_key further "read" the directory, the
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * find close protocol "closes" the directory allowing the server to free any
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * resources held in support of the directory search.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * In our implementation this translates to closing the odir.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * smb_com_find_unique
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * -------------------
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The format of the find unique protocol is the same as the core "search"
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * protocol. The difference is that the directory is logically opened, any
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * matching entries returned, and then the directory is logically closed.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * The resume search key key will be returned as in the find protocol and
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * search protocol however it may NOT be returned to continue the search.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * Only one buffer of entries is expected and find close need not be sent.
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * If a find unique requests more data than can be placed in a message of the
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * max-xmit-size for the TID specified, the server will abort the virtual
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego * circuit to the consumer.
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wrightstatic void smb_name83(const char *, char *, size_t);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego/* *** smb_com_search *** */
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego DTRACE_SMB_1(op__Search__start, smb_request_t *, sr);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego DTRACE_SMB_1(op__Search__done, smb_request_t *, sr);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_t *pn;
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego ((sr->smb_flg2 & SMB_FLAGS2_KNOWS_LONG_NAMES) == 0)) {
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego /* We only handle 8.3 name here */
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego if (smbsr_decode_vwv(sr, "ww", &maxcount, &sattr) != 0)
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States pn = &sr->arg.dirop.fqi.fq_path;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smbsr_decode_data(sr, "%Abw", sr, &pn->pn_path, &type, &key_len);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_init(sr, pn, pn->pn_path);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_pathname_validate(sr, pn) ||
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_is_stream_name(pn->pn_path)) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smbsr_warn(sr, NT_STATUS_NO_MORE_FILES,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_NO_MORE_FILES);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States }
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego /* Volume information only */
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego if ((sattr == FILE_ATTRIBUTE_VOLUME) && (key_len != 21)) {
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego (void) strncpy(name, tree->t_volume, sizeof (name));
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego (void) smb_mbc_encodef(&sr->reply, "bwwbwb11c5.lb8.13c",
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States 1, 0, VAR_BCC, 5, 0, 0, pn->pn_path+1,
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego rc = (sr->reply.chain_offset - sr->cur_reply_offset) - 8;
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego (void) smb_mbc_poke(&sr->reply, sr->cur_reply_offset, "bwwbw",
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross status = smb_odir_openpath(sr, pn->pn_path, sattr, 0, &od);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego &resume_char, &index, &odid, &client_key) != 0) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if ((od->d_flags & SMB_ODIR_FLAG_WILDCARDS) == 0) {
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego (void) smb_mbc_encodef(&sr->reply, "bwwbw", 1, 0, VAR_BCC, 5, 0);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego rc = smb_odir_read_fileinfo(sr, od, &fileinfo, &eos);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (void) strlcpy(fileinfo.fi_shortname, fileinfo.fi_name,
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright smb_name83(fileinfo.fi_shortname, name83, SMB_SHORTNAMELEN);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (void) smb_mbc_encodef(&sr->reply, "b11c.wwlbYl13c",
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai smb_time_gmt_to_local(sr, fileinfo.fi_mtime.tv_sec),
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego smb_odir_save_cookie(od, index, fileinfo.fi_cookie);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego rc = (sr->reply.chain_offset - sr->cur_reply_offset) - 8;
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego if (smb_mbc_poke(&sr->reply, sr->cur_reply_offset, "bwwbw",
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego/* *** smb_com_find *** */
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_t *pn;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States pn = &sr->arg.dirop.fqi.fq_path;
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States rc = smbsr_decode_data(sr, "%Abw", sr, &pn->pn_path, &type, &key_len);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_init(sr, pn, pn->pn_path);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_pathname_validate(sr, pn))
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (smb_is_stream_name(pn->pn_path)) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_OBJECT_NAME_INVALID,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_INVALID_NAME);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States }
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross status = smb_odir_openpath(sr, pn->pn_path, sattr, 0, &od);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego &resume_char, &index, &odid, &client_key) != 0) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if ((od->d_flags & SMB_ODIR_FLAG_WILDCARDS) == 0) {
3db3f65c6274eb042354801a308c8e9bc4994553amw (void) smb_mbc_encodef(&sr->reply, "bwwbw", 1, 0, VAR_BCC, 5, 0);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego rc = smb_odir_read_fileinfo(sr, od, &fileinfo, &eos);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (void) strlcpy(fileinfo.fi_shortname, fileinfo.fi_name,
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright smb_name83(fileinfo.fi_shortname, name83, SMB_SHORTNAMELEN);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (void) smb_mbc_encodef(&sr->reply, "b11c.wwlbYl13c",
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai smb_time_gmt_to_local(sr, fileinfo.fi_mtime.tv_sec),
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego smb_odir_save_cookie(od, index, fileinfo.fi_cookie);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = (MBC_LENGTH(&sr->reply) - sr->cur_reply_offset) - 8;
3db3f65c6274eb042354801a308c8e9bc4994553amw if (smb_mbc_poke(&sr->reply, sr->cur_reply_offset, "bwwbw",
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego/* *** smb_com_find_close *** */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw rc = smbsr_decode_data(sr, "%Abw", sr, &path, &type, &key_len);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego &resume_char, &index, &odid, &client_key) != 0) {
7b59d02d2a384be9a08087b14defadd214b3c1ddjb if (smbsr_encode_result(sr, 1, 3, "bwwbw", 1, 0, 3, 5, 0))
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego/* *** smb_com_find_unique *** */
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego DTRACE_SMB_1(op__FindUnique__start, smb_request_t *, sr);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego DTRACE_SMB_1(op__FindUnique__done, smb_request_t *, sr);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_t *pn;
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego if (smbsr_decode_vwv(sr, "ww", &maxcount, &sattr) != 0)
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States pn = &sr->arg.dirop.fqi.fq_path;
2c2961f8403049d948b9f3e6c35d6488b6b7e1aajose borrego vdb = kmem_alloc(sizeof (smb_vdb_t), KM_SLEEP);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if ((smbsr_decode_data(sr, "%AV", sr, &pn->pn_path, vdb) != 0) ||
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smb_pathname_init(sr, pn, pn->pn_path);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (!smb_pathname_validate(sr, pn))
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States if (smb_is_stream_name(pn->pn_path)) {
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States smbsr_error(sr, NT_STATUS_OBJECT_NAME_INVALID,
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States ERRDOS, ERROR_INVALID_NAME);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States return (SDRC_ERROR);
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States }
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego (void) smb_mbc_encodef(&sr->reply, "bwwbw", 1, 0, VAR_BCC, 5, 0);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross status = smb_odir_openpath(sr, pn->pn_path, sattr, 0, &od);
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego rc = smb_odir_read_fileinfo(sr, od, &fileinfo, &eos);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (void) strlcpy(fileinfo.fi_shortname, fileinfo.fi_name,
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright smb_name83(fileinfo.fi_shortname, name83, SMB_SHORTNAMELEN);
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (void) smb_mbc_encodef(&sr->reply, "b11c.wwlbYl13c",
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai smb_time_gmt_to_local(sr, fileinfo.fi_mtime.tv_sec),
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego rc = (MBC_LENGTH(&sr->reply) - sr->cur_reply_offset) - 8;
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego if (smb_mbc_poke(&sr->reply, sr->cur_reply_offset,
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * smb_name83
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * Format the filename for inclusion in the resume key. The filename
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * returned in the resume key is 11 bytes:
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * - up to 8 bytes of filename, space padded to 8 bytes
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * - up to 3 bytes of ext, space padded to 3 bytes
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * The name passed to smb_name83 should be a shortname or a name that
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * doesn't require mangling.
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * "fname.txt" -> "FNAME TXT"
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * "fname.tx" -> "FNAME TX "
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * "filename" -> "FILENAME "
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * "filename.txt" -> "FILENAMETXT"
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * "FILE~1.TXT" -> "FILE~1 TXT"
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wrightsmb_name83(const char *name, char *buf, size_t buflen)
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright const char *p;
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright ASSERT(name && buf && (buflen >= SMB_NAME83_BUFLEN));
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright /* Process "." and ".." up front */
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright if ((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0)) {
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright /* Process basename */
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright (i < SMB_NAME83_BASELEN) && (*p != '\0') && (*p != '.'); ++i)
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright /* Process the extension from the last dot in name */
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright for (i = 0; (i < SMB_NAME83_EXTLEN) && (*p != '\0'); ++i)