Print this page
NEX-19025 CIFS gets confused with filenames containing enhanced Unicode
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
and: (fix build, check-rtime)
NEX-4083 Upstream changes from illumos 5917 and 5995
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-2460 libfksmbd should not link with libsmb
re #6854 FindFirstFile,FindFirstFileEx,... are not working correctly on Nexenta CIFS-shares


 125  *  0   no-match
 126  * -1   no-match, error (illseq, too many wildcards in pattern, ...)
 127  *
 128  * Note that both the pattern and the string are in multi-byte form.
 129  *
 130  * The implementation of this is quite tricky.  First note that it
 131  * can call itself recursively, though it limits the recursion depth.
 132  * Each switch case in the while loop can basically do one of three
 133  * things: (a) return "Yes, match", (b) return "not a match", or
 134  * continue processing the match pattern.  The cases for wildcards
 135  * that may match a variable number of characters ('*' and '<') do
 136  * recursive calls, looking for a match of the remaining pattern,
 137  * starting at the current and later positions in the string.
 138  */
 139 static int
 140 smb_match_private(const char *pat, const char *str, struct match_priv *priv)
 141 {
 142         const char      *limit;
 143         char            pc;             /* current pattern char */
 144         int             rc;
 145         smb_wchar_t     wcpat, wcstr;   /* current wchar in pat, str */
 146         int             nbpat, nbstr;   /* multi-byte length of it */
 147 
 148         if (priv->depth >= SMB_MATCH_DEPTH_MAX)
 149                 return (-1);
 150 
 151         /*
 152          * Advance over one multi-byte char, used in cases like
 153          * '?' or '>' where "match one character" needs to be
 154          * interpreted as "match one multi-byte sequence".
 155          *
 156          * This macro needs to consume the semicolon following
 157          * each place it appears, so this is carefully written
 158          * as an if/else with a missing semicolon at the end.
 159          */
 160 #define ADVANCE(str) \
 161         if ((nbstr = smb_mbtowc(NULL, str, MTS_MB_CHAR_MAX)) < 1) \
 162                 return (-1); \
 163         else \
 164                 str += nbstr    /* no ; */
 165 




 125  *  0   no-match
 126  * -1   no-match, error (illseq, too many wildcards in pattern, ...)
 127  *
 128  * Note that both the pattern and the string are in multi-byte form.
 129  *
 130  * The implementation of this is quite tricky.  First note that it
 131  * can call itself recursively, though it limits the recursion depth.
 132  * Each switch case in the while loop can basically do one of three
 133  * things: (a) return "Yes, match", (b) return "not a match", or
 134  * continue processing the match pattern.  The cases for wildcards
 135  * that may match a variable number of characters ('*' and '<') do
 136  * recursive calls, looking for a match of the remaining pattern,
 137  * starting at the current and later positions in the string.
 138  */
 139 static int
 140 smb_match_private(const char *pat, const char *str, struct match_priv *priv)
 141 {
 142         const char      *limit;
 143         char            pc;             /* current pattern char */
 144         int             rc;
 145         uint32_t        wcpat, wcstr;   /* current wchar in pat, str */
 146         int             nbpat, nbstr;   /* multi-byte length of it */
 147 
 148         if (priv->depth >= SMB_MATCH_DEPTH_MAX)
 149                 return (-1);
 150 
 151         /*
 152          * Advance over one multi-byte char, used in cases like
 153          * '?' or '>' where "match one character" needs to be
 154          * interpreted as "match one multi-byte sequence".
 155          *
 156          * This macro needs to consume the semicolon following
 157          * each place it appears, so this is carefully written
 158          * as an if/else with a missing semicolon at the end.
 159          */
 160 #define ADVANCE(str) \
 161         if ((nbstr = smb_mbtowc(NULL, str, MTS_MB_CHAR_MAX)) < 1) \
 162                 return (-1); \
 163         else \
 164                 str += nbstr    /* no ; */
 165