23 #include <linux/in6.h>
24 #include <linux/slab.h>
31 #ifdef CONFIG_CIFS_SMB2
35 #define CIFS_MAGIC_NUMBER 0xFF534D42
40 #define MAX_UID_INFO 16
41 #define MAX_SES_INFO 2
42 #define MAX_TCON_INFO 4
44 #define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
45 #define MAX_SERVER_SIZE 15
46 #define MAX_SHARE_SIZE 80
47 #define MAX_USERNAME_SIZE 256
48 #define MAX_PASSWORD_SIZE 512
50 #define CIFS_MIN_RCV_POOL 4
52 #define MAX_REOPEN_ATT 5
56 #define CIFS_DEF_ACTIMEO (1 * HZ)
61 #define CIFS_MAX_ACTIMEO (1 << 30)
67 #define CIFS_MAX_REQ 32767
69 #define RFC1001_NAME_LEN 15
70 #define RFC1001_NAME_LEN_WITH_NULL (RFC1001_NAME_LEN + 1)
73 #define SERVER_NAME_LENGTH 40
74 #define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1)
82 #define SMB_ECHO_INTERVAL (60 * HZ)
86 #ifndef XATTR_DOS_ATTRIB
87 #define XATTR_DOS_ATTRIB "user.DOSATTRIB"
266 FILE_ALL_INFO *,
bool *);
269 struct cifs_fid *, FILE_ALL_INFO *);
273 u64 *uniqueid, FILE_ALL_INFO *);
311 const char *,
const char *,
391 #define HEADER_SIZE(server) (server->vals->header_size)
392 #define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
456 #define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \
457 CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \
458 CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \
459 CIFS_MOUNT_UNX_EMUL | CIFS_MOUNT_NO_BRL | \
460 CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_OVERR_UID | \
461 CIFS_MOUNT_OVERR_GID | CIFS_MOUNT_DYNPERM | \
462 CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \
463 CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \
464 CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO | \
465 CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID)
467 #define CIFS_MS_MASK (MS_RDONLY | MS_MANDLOCK | MS_NOEXEC | MS_NOSUID | \
468 MS_NODEV | MS_SYNCHRONOUS)
476 static inline unsigned int
477 get_rfc1002_length(
void *
buf)
483 inc_rfc1001_len(
void *
buf,
int count)
485 be32_add_cpu((
__be32 *)buf, count);
518 #ifdef CONFIG_CIFS_SMB2
561 #ifdef CONFIG_CIFS_FSCACHE
564 #ifdef CONFIG_CIFS_STATS2
568 #ifdef CONFIG_CIFS_SMB2
569 unsigned int max_read;
570 unsigned int max_write;
574 static inline unsigned int
598 server->
ops->add_credits(server, add, optype);
604 server->
ops->set_credits(server, val);
610 return server->
ops->get_next_mid(server);
626 #define CIFS_MAX_WSIZE ((1<<24) - 1 - sizeof(WRITE_REQ) + 4)
627 #define CIFS_MAX_RSIZE ((1<<24) - sizeof(READ_RSP) + 4)
634 #define CIFS_MAX_RFC1002_WSIZE ((1<<17) - 1 - sizeof(WRITE_REQ) + 4)
635 #define CIFS_MAX_RFC1002_RSIZE ((1<<17) - 1 - sizeof(READ_RSP) + 4)
642 #define CIFS_DEFAULT_IOSIZE (1024 * 1024)
655 #define CIFS_DEFAULT_NON_POSIX_RSIZE (60 * 1024)
656 #define CIFS_DEFAULT_NON_POSIX_WSIZE (65536)
718 #ifdef CONFIG_CIFS_SMB2
724 #define CIFS_SES_NT4 1
725 #define CIFS_SES_OS2 2
726 #define CIFS_SES_W9X 4
730 #define CIFS_SES_LANMAN 8
753 #ifdef CONFIG_CIFS_STATS
779 #ifdef CONFIG_CIFS_SMB2
786 #ifdef CONFIG_CIFS_STATS2
787 unsigned long long time_writes;
788 unsigned long long time_reads;
789 unsigned long long time_opens;
790 unsigned long long time_deletes;
791 unsigned long long time_closes;
792 unsigned long long time_mkdirs;
793 unsigned long long time_rmdirs;
794 unsigned long long time_renames;
795 unsigned long long time_t2renames;
796 unsigned long long time_ffirst;
797 unsigned long long time_fnext;
798 unsigned long long time_fclose;
816 #ifdef CONFIG_CIFS_SMB2
818 bool bad_network_name:1;
821 __u32 maximal_access;
822 __u32 vol_serial_number;
825 #ifdef CONFIG_CIFS_FSCACHE
843 #define TCON_LINK_MASTER 0
844 #define TCON_LINK_PENDING 1
845 #define TCON_LINK_IN_TREE 2
864 if (tlink && !IS_ERR(tlink))
872 #define CIFS_OPLOCK_NO_CHANGE 0xfe
916 #ifdef CONFIG_CIFS_SMB2
917 __u64 persistent_fid;
952 #ifdef CONFIG_CIFS_SMB2
953 __u64 persistent_fid;
1011 cifsFileInfo_get_locked(
struct cifsFileInfo *cifs_file)
1038 #ifdef CONFIG_CIFS_SMB2
1041 #ifdef CONFIG_CIFS_FSCACHE
1059 static inline char CIFS_DIR_SEP(
const struct cifs_sb_info *cifs_sb)
1068 convert_delimiter(
char *
path,
char delim)
1081 for (i = 0; path[
i] !=
'\0'; i++) {
1082 if (path[i] == old_delim)
1087 static inline char *
1091 if (!vol->
ops->build_path_to_root)
1093 return vol->
ops->build_path_to_root(vol, cifs_sb, tcon);
1096 #ifdef CONFIG_CIFS_STATS
1097 #define cifs_stats_inc atomic_inc
1103 spin_lock(&tcon->stat_lock);
1104 tcon->bytes_written +=
bytes;
1105 spin_unlock(&tcon->stat_lock);
1112 spin_lock(&tcon->stat_lock);
1113 tcon->bytes_read +=
bytes;
1114 spin_unlock(&tcon->stat_lock);
1118 #define cifs_stats_inc(field) do {} while (0)
1119 #define cifs_stats_bytes_written(tcon, bytes) do {} while (0)
1120 #define cifs_stats_bytes_read(tcon, bytes) do {} while (0)
1158 #ifdef CONFIG_CIFS_STATS2
1159 unsigned long when_sent;
1160 unsigned long when_received;
1175 #ifdef CONFIG_CIFS_STATS2
1187 static inline void cifs_num_waiters_inc(
struct TCP_Server_Info *server)
1192 static inline void cifs_num_waiters_dec(
struct TCP_Server_Info *server)
1209 static inline void cifs_num_waiters_inc(
struct TCP_Server_Info *server)
1213 static inline void cifs_num_waiters_dec(
struct TCP_Server_Info *server)
1250 #define CIFS_FATTR_DFS_REFERRAL 0x1
1251 #define CIFS_FATTR_DELETE_PENDING 0x2
1252 #define CIFS_FATTR_NEED_REVAL 0x4
1253 #define CIFS_FATTR_INO_COLLISION 0x8
1283 int number_of_items)
1286 if ((number_of_items == 0) || (param ==
NULL))
1288 for (i = 0; i < number_of_items; i++) {
1289 kfree(param[i].path_name);
1296 #define MID_REQUEST_ALLOCATED 1
1297 #define MID_REQUEST_SUBMITTED 2
1298 #define MID_RESPONSE_RECEIVED 4
1299 #define MID_RETRY_NEEDED 8
1300 #define MID_RESPONSE_MALFORMED 0x10
1301 #define MID_SHUTDOWN 0x20
1304 #define CIFS_NO_BUFFER 0
1305 #define CIFS_SMALL_BUFFER 1
1306 #define CIFS_LARGE_BUFFER 2
1307 #define CIFS_IOVEC 4
1310 #define CIFS_BLOCKING_OP 1
1311 #define CIFS_ASYNC_OP 2
1312 #define CIFS_TIMEOUT_MASK 0x003
1313 #define CIFS_LOG_ERROR 0x010
1314 #define CIFS_LARGE_BUF_OP 0x020
1315 #define CIFS_NO_RESP 0x040
1318 #define CIFS_ECHO_OP 0x080
1319 #define CIFS_OBREAK_OP 0x0100
1320 #define CIFS_NEG_OP 0x0200
1321 #define CIFS_OP_MASK 0x0380
1324 #define CIFSSEC_MAY_SIGN 0x00001
1325 #define CIFSSEC_MAY_NTLM 0x00002
1326 #define CIFSSEC_MAY_NTLMV2 0x00004
1327 #define CIFSSEC_MAY_KRB5 0x00008
1328 #ifdef CONFIG_CIFS_WEAK_PW_HASH
1329 #define CIFSSEC_MAY_LANMAN 0x00010
1330 #define CIFSSEC_MAY_PLNTXT 0x00020
1332 #define CIFSSEC_MAY_LANMAN 0
1333 #define CIFSSEC_MAY_PLNTXT 0
1335 #define CIFSSEC_MAY_SEAL 0x00040
1336 #define CIFSSEC_MAY_NTLMSSP 0x00080
1338 #define CIFSSEC_MUST_SIGN 0x01001
1342 #define CIFSSEC_MUST_NTLM 0x02002
1343 #define CIFSSEC_MUST_NTLMV2 0x04004
1344 #define CIFSSEC_MUST_KRB5 0x08008
1345 #ifdef CONFIG_CIFS_WEAK_PW_HASH
1346 #define CIFSSEC_MUST_LANMAN 0x10010
1347 #define CIFSSEC_MUST_PLNTXT 0x20020
1348 #ifdef CONFIG_CIFS_UPCALL
1349 #define CIFSSEC_MASK 0xBF0BF
1351 #define CIFSSEC_MASK 0xB70B7
1354 #define CIFSSEC_MUST_LANMAN 0
1355 #define CIFSSEC_MUST_PLNTXT 0
1356 #ifdef CONFIG_CIFS_UPCALL
1357 #define CIFSSEC_MASK 0x8F08F
1359 #define CIFSSEC_MASK 0x87087
1362 #define CIFSSEC_MUST_SEAL 0x40040
1363 #define CIFSSEC_MUST_NTLMSSP 0x80080
1365 #define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_NTLMSSP)
1366 #define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)
1367 #define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)
1374 #define UID_HASH (16)
1403 #ifdef DECLARE_GLOBALS_HERE
1404 #define GLOBAL_EXTERN
1406 #define GLOBAL_EXTERN extern
1435 #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL
1461 #ifdef CONFIG_CIFS_STATS2
1480 #ifdef CONFIG_CIFS_ACL
1499 #define SMB1_VERSION_STRING "1.0"
1502 #define SMB20_VERSION_STRING "2.0"
1505 #define SMB21_VERSION_STRING "2.1"
1508 #define SMB30_VERSION_STRING "3.0"