/*1* fs/cifs/cifsglob.h2*3* Copyright (C) International Business Machines Corp., 2002,20084* Author(s): Steve French ([email protected])5* Jeremy Allison ([email protected])6*7* This library is free software; you can redistribute it and/or modify8* it under the terms of the GNU Lesser General Public License as published9* by the Free Software Foundation; either version 2.1 of the License, or10* (at your option) any later version.11*12* This library is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See15* the GNU Lesser General Public License for more details.16*17*/18#ifndef _CIFS_GLOB_H19#define _CIFS_GLOB_H2021#include <linux/in.h>22#include <linux/in6.h>23#include <linux/slab.h>24#include <linux/workqueue.h>25#include "cifs_fs_sb.h"26#include "cifsacl.h"27#include <crypto/internal/hash.h>28#include <linux/scatterlist.h>2930/*31* The sizes of various internal tables and strings32*/33#define MAX_UID_INFO 1634#define MAX_SES_INFO 235#define MAX_TCON_INFO 43637#define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)38#define MAX_SERVER_SIZE 1539#define MAX_SHARE_SIZE 8040#define MAX_USERNAME_SIZE 256 /* reasonable maximum for current servers */41#define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */4243#define CIFS_MIN_RCV_POOL 44445/*46* default attribute cache timeout (jiffies)47*/48#define CIFS_DEF_ACTIMEO (1 * HZ)4950/*51* max attribute cache timeout (jiffies) - 2^3052*/53#define CIFS_MAX_ACTIMEO (1 << 30)5455/*56* MAX_REQ is the maximum number of requests that WE will send57* on one socket concurrently. It also matches the most common58* value of max multiplex returned by servers. We may59* eventually want to use the negotiated value (in case60* future servers can handle more) when we are more confident that61* we will not have problems oveloading the socket with pending62* write data.63*/64#define CIFS_MAX_REQ 506566#define RFC1001_NAME_LEN 1567#define RFC1001_NAME_LEN_WITH_NULL (RFC1001_NAME_LEN + 1)6869/* currently length of NIP6_FMT */70#define SERVER_NAME_LENGTH 4071#define SERVER_NAME_LEN_WITH_NULL (SERVER_NAME_LENGTH + 1)7273/* used to define string lengths for reversing unicode strings */74/* (256+1)*2 = 514 */75/* (max path length + 1 for null) * 2 for unicode */76#define MAX_NAME 5147778#include "cifspdu.h"7980#ifndef XATTR_DOS_ATTRIB81#define XATTR_DOS_ATTRIB "user.DOSATTRIB"82#endif8384/*85* CIFS vfs client Status information (based on what we know.)86*/8788/* associated with each tcp and smb session */89enum statusEnum {90CifsNew = 0,91CifsGood,92CifsExiting,93CifsNeedReconnect,94CifsNeedNegotiate95};9697enum securityEnum {98LANMAN = 0, /* Legacy LANMAN auth */99NTLM, /* Legacy NTLM012 auth with NTLM hash */100NTLMv2, /* Legacy NTLM auth with NTLMv2 hash */101RawNTLMSSP, /* NTLMSSP without SPNEGO, NTLMv2 hash */102/* NTLMSSP, */ /* can use rawNTLMSSP instead of NTLMSSP via SPNEGO */103Kerberos, /* Kerberos via SPNEGO */104};105106enum protocolEnum {107TCP = 0,108SCTP109/* Netbios frames protocol not supported at this time */110};111112struct session_key {113unsigned int len;114char *response;115};116117/* crypto security descriptor definition */118struct sdesc {119struct shash_desc shash;120char ctx[];121};122123/* crypto hashing related structure/fields, not specific to a sec mech */124struct cifs_secmech {125struct crypto_shash *hmacmd5; /* hmac-md5 hash function */126struct crypto_shash *md5; /* md5 hash function */127struct sdesc *sdeschmacmd5; /* ctxt to generate ntlmv2 hash, CR1 */128struct sdesc *sdescmd5; /* ctxt to generate cifs/smb signature */129};130131/* per smb session structure/fields */132struct ntlmssp_auth {133__u32 client_flags; /* sent by client in type 1 ntlmsssp exchange */134__u32 server_flags; /* sent by server in type 2 ntlmssp exchange */135unsigned char ciphertext[CIFS_CPHTXT_SIZE]; /* sent to server */136char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlmssp */137};138139struct cifs_cred {140int uid;141int gid;142int mode;143int cecount;144struct cifs_sid osid;145struct cifs_sid gsid;146struct cifs_ntace *ntaces;147struct cifs_ace *aces;148};149150/*151*****************************************************************152* Except the CIFS PDUs themselves all the153* globally interesting structs should go here154*****************************************************************155*/156157struct smb_vol {158char *username;159char *password;160char *domainname;161char *UNC;162char *UNCip;163char *iocharset; /* local code page for mapping to and from Unicode */164char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */165char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */166uid_t cred_uid;167uid_t linux_uid;168gid_t linux_gid;169mode_t file_mode;170mode_t dir_mode;171unsigned secFlg;172bool retry:1;173bool intr:1;174bool setuids:1;175bool override_uid:1;176bool override_gid:1;177bool dynperm:1;178bool noperm:1;179bool no_psx_acl:1; /* set if posix acl support should be disabled */180bool cifs_acl:1;181bool no_xattr:1; /* set if xattr (EA) support should be disabled*/182bool server_ino:1; /* use inode numbers from server ie UniqueId */183bool direct_io:1;184bool strict_io:1; /* strict cache behavior */185bool remap:1; /* set to remap seven reserved chars in filenames */186bool posix_paths:1; /* unset to not ask for posix pathnames. */187bool no_linux_ext:1;188bool sfu_emul:1;189bool nullauth:1; /* attempt to authenticate with null user */190bool nocase:1; /* request case insensitive filenames */191bool nobrl:1; /* disable sending byte range locks to srv */192bool mand_lock:1; /* send mandatory not posix byte range lock reqs */193bool seal:1; /* request transport encryption on share */194bool nodfs:1; /* Do not request DFS, even if available */195bool local_lease:1; /* check leases only on local system, not remote */196bool noblocksnd:1;197bool noautotune:1;198bool nostrictsync:1; /* do not force expensive SMBflush on every sync */199bool fsc:1; /* enable fscache */200bool mfsymlinks:1; /* use Minshall+French Symlinks */201bool multiuser:1;202bool rwpidforward:1; /* pid forward for read/write operations */203unsigned int rsize;204unsigned int wsize;205bool sockopt_tcp_nodelay:1;206unsigned short int port;207unsigned long actimeo; /* attribute cache timeout (jiffies) */208char *prepath;209struct sockaddr_storage srcaddr; /* allow binding to a local IP */210struct nls_table *local_nls;211};212213#define CIFS_MOUNT_MASK (CIFS_MOUNT_NO_PERM | CIFS_MOUNT_SET_UID | \214CIFS_MOUNT_SERVER_INUM | CIFS_MOUNT_DIRECT_IO | \215CIFS_MOUNT_NO_XATTR | CIFS_MOUNT_MAP_SPECIAL_CHR | \216CIFS_MOUNT_UNX_EMUL | CIFS_MOUNT_NO_BRL | \217CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_OVERR_UID | \218CIFS_MOUNT_OVERR_GID | CIFS_MOUNT_DYNPERM | \219CIFS_MOUNT_NOPOSIXBRL | CIFS_MOUNT_NOSSYNC | \220CIFS_MOUNT_FSCACHE | CIFS_MOUNT_MF_SYMLINKS | \221CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO)222223#define CIFS_MS_MASK (MS_RDONLY | MS_MANDLOCK | MS_NOEXEC | MS_NOSUID | \224MS_NODEV | MS_SYNCHRONOUS)225226struct cifs_mnt_data {227struct cifs_sb_info *cifs_sb;228struct smb_vol *vol;229int flags;230};231232struct TCP_Server_Info {233struct list_head tcp_ses_list;234struct list_head smb_ses_list;235int srv_count; /* reference counter */236/* 15 character server name + 0x20 16th byte indicating type = srv */237char server_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];238enum statusEnum tcpStatus; /* what we think the status is */239char *hostname; /* hostname portion of UNC string */240struct socket *ssocket;241struct sockaddr_storage dstaddr;242struct sockaddr_storage srcaddr; /* locally bind to this IP */243#ifdef CONFIG_NET_NS244struct net *net;245#endif246wait_queue_head_t response_q;247wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/248struct list_head pending_mid_q;249bool noblocksnd; /* use blocking sendmsg */250bool noautotune; /* do not autotune send buf sizes */251bool tcp_nodelay;252atomic_t inFlight; /* number of requests on the wire to server */253struct mutex srv_mutex;254struct task_struct *tsk;255char server_GUID[16];256char sec_mode;257bool session_estab; /* mark when very first sess is established */258u16 dialect; /* dialect index that server chose */259enum securityEnum secType;260unsigned int maxReq; /* Clients should submit no more */261/* than maxReq distinct unanswered SMBs to the server when using */262/* multiplexed reads or writes */263unsigned int maxBuf; /* maxBuf specifies the maximum */264/* message size the server can send or receive for non-raw SMBs */265/* maxBuf is returned by SMB NegotiateProtocol so maxBuf is only 0 */266/* when socket is setup (and during reconnect) before NegProt sent */267unsigned int max_rw; /* maxRw specifies the maximum */268/* message size the server can send or receive for */269/* SMB_COM_WRITE_RAW or SMB_COM_READ_RAW. */270unsigned int max_vcs; /* maximum number of smb sessions, at least271those that can be specified uniquely with272vcnumbers */273int capabilities; /* allow selective disabling of caps by smb sess */274int timeAdj; /* Adjust for difference in server time zone in sec */275__u16 CurrentMid; /* multiplex id - rotating counter */276char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */277/* 16th byte of RFC1001 workstation name is always null */278char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];279__u32 sequence_number; /* for signing, protected by srv_mutex */280struct session_key session_key;281unsigned long lstrp; /* when we got last response from this server */282struct cifs_secmech secmech; /* crypto sec mech functs, descriptors */283/* extended security flavors that server supports */284bool sec_ntlmssp; /* supports NTLMSSP */285bool sec_kerberosu2u; /* supports U2U Kerberos */286bool sec_kerberos; /* supports plain Kerberos */287bool sec_mskerberos; /* supports legacy MS Kerberos */288struct delayed_work echo; /* echo ping workqueue job */289#ifdef CONFIG_CIFS_FSCACHE290struct fscache_cookie *fscache; /* client index cache cookie */291#endif292#ifdef CONFIG_CIFS_STATS2293atomic_t inSend; /* requests trying to send */294atomic_t num_waiters; /* blocked waiting to get in sendrecv */295#endif296};297298/*299* Macros to allow the TCP_Server_Info->net field and related code to drop out300* when CONFIG_NET_NS isn't set.301*/302303#ifdef CONFIG_NET_NS304305static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)306{307return srv->net;308}309310static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)311{312srv->net = net;313}314315#else316317static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv)318{319return &init_net;320}321322static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net)323{324}325326#endif327328/*329* Session structure. One of these for each uid session with a particular host330*/331struct cifs_ses {332struct list_head smb_ses_list;333struct list_head tcon_list;334struct mutex session_mutex;335struct TCP_Server_Info *server; /* pointer to server info */336int ses_count; /* reference counter */337enum statusEnum status;338unsigned overrideSecFlg; /* if non-zero override global sec flags */339__u16 ipc_tid; /* special tid for connection to IPC share */340__u16 flags;341__u16 vcnum;342char *serverOS; /* name of operating system underlying server */343char *serverNOS; /* name of network operating system of server */344char *serverDomain; /* security realm of server */345int Suid; /* remote smb uid */346uid_t linux_uid; /* overriding owner of files on the mount */347uid_t cred_uid; /* owner of credentials */348int capabilities;349char serverName[SERVER_NAME_LEN_WITH_NULL * 2]; /* BB make bigger for350TCP names - will ipv6 and sctp addresses fit? */351char *user_name; /* must not be null except during init of sess352and after mount option parsing we fill it */353char *domainName;354char *password;355struct session_key auth_key;356struct ntlmssp_auth *ntlmssp; /* ciphertext, flags, server challenge */357bool need_reconnect:1; /* connection reset, uid now invalid */358};359/* no more than one of the following three session flags may be set */360#define CIFS_SES_NT4 1361#define CIFS_SES_OS2 2362#define CIFS_SES_W9X 4363/* following flag is set for old servers such as OS2 (and Win95?)364which do not negotiate NTLM or POSIX dialects, but instead365negotiate one of the older LANMAN dialects */366#define CIFS_SES_LANMAN 8367/*368* there is one of these for each connection to a resource on a particular369* session370*/371struct cifs_tcon {372struct list_head tcon_list;373int tc_count;374struct list_head openFileList;375struct cifs_ses *ses; /* pointer to session associated with */376char treeName[MAX_TREE_SIZE + 1]; /* UNC name of resource in ASCII */377char *nativeFileSystem;378char *password; /* for share-level security */379__u16 tid; /* The 2 byte tree id */380__u16 Flags; /* optional support bits */381enum statusEnum tidStatus;382#ifdef CONFIG_CIFS_STATS383atomic_t num_smbs_sent;384atomic_t num_writes;385atomic_t num_reads;386atomic_t num_flushes;387atomic_t num_oplock_brks;388atomic_t num_opens;389atomic_t num_closes;390atomic_t num_deletes;391atomic_t num_mkdirs;392atomic_t num_posixopens;393atomic_t num_posixmkdirs;394atomic_t num_rmdirs;395atomic_t num_renames;396atomic_t num_t2renames;397atomic_t num_ffirst;398atomic_t num_fnext;399atomic_t num_fclose;400atomic_t num_hardlinks;401atomic_t num_symlinks;402atomic_t num_locks;403atomic_t num_acl_get;404atomic_t num_acl_set;405#ifdef CONFIG_CIFS_STATS2406unsigned long long time_writes;407unsigned long long time_reads;408unsigned long long time_opens;409unsigned long long time_deletes;410unsigned long long time_closes;411unsigned long long time_mkdirs;412unsigned long long time_rmdirs;413unsigned long long time_renames;414unsigned long long time_t2renames;415unsigned long long time_ffirst;416unsigned long long time_fnext;417unsigned long long time_fclose;418#endif /* CONFIG_CIFS_STATS2 */419__u64 bytes_read;420__u64 bytes_written;421spinlock_t stat_lock;422#endif /* CONFIG_CIFS_STATS */423FILE_SYSTEM_DEVICE_INFO fsDevInfo;424FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */425FILE_SYSTEM_UNIX_INFO fsUnixInfo;426bool ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */427bool retry:1;428bool nocase:1;429bool seal:1; /* transport encryption for this mounted share */430bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol431for this mount even if server would support */432bool local_lease:1; /* check leases (only) on local system not remote */433bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */434bool need_reconnect:1; /* connection reset, tid now invalid */435#ifdef CONFIG_CIFS_FSCACHE436u64 resource_id; /* server resource id */437struct fscache_cookie *fscache; /* cookie for share */438#endif439/* BB add field for back pointer to sb struct(s)? */440};441442/*443* This is a refcounted and timestamped container for a tcon pointer. The444* container holds a tcon reference. It is considered safe to free one of445* these when the tl_count goes to 0. The tl_time is the time of the last446* "get" on the container.447*/448struct tcon_link {449struct rb_node tl_rbnode;450uid_t tl_uid;451unsigned long tl_flags;452#define TCON_LINK_MASTER 0453#define TCON_LINK_PENDING 1454#define TCON_LINK_IN_TREE 2455unsigned long tl_time;456atomic_t tl_count;457struct cifs_tcon *tl_tcon;458};459460extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);461462static inline struct cifs_tcon *463tlink_tcon(struct tcon_link *tlink)464{465return tlink->tl_tcon;466}467468extern void cifs_put_tlink(struct tcon_link *tlink);469470static inline struct tcon_link *471cifs_get_tlink(struct tcon_link *tlink)472{473if (tlink && !IS_ERR(tlink))474atomic_inc(&tlink->tl_count);475return tlink;476}477478/* This function is always expected to succeed */479extern struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);480481/*482* This info hangs off the cifsFileInfo structure, pointed to by llist.483* This is used to track byte stream locks on the file484*/485struct cifsLockInfo {486struct list_head llist; /* pointer to next cifsLockInfo */487__u64 offset;488__u64 length;489__u8 type;490};491492/*493* One of these for each open instance of a file494*/495struct cifs_search_info {496loff_t index_of_last_entry;497__u16 entries_in_buffer;498__u16 info_level;499__u32 resume_key;500char *ntwrk_buf_start;501char *srch_entries_start;502char *last_entry;503char *presume_name;504unsigned int resume_name_len;505bool endOfSearch:1;506bool emptyDir:1;507bool unicode:1;508bool smallBuf:1; /* so we know which buf_release function to call */509};510511struct cifsFileInfo {512struct list_head tlist; /* pointer to next fid owned by tcon */513struct list_head flist; /* next fid (file instance) for this inode */514unsigned int uid; /* allows finding which FileInfo structure */515__u32 pid; /* process id who opened file */516__u16 netfid; /* file id from remote */517/* BB add lock scope info here if needed */ ;518/* lock scope id (0 if none) */519struct dentry *dentry;520unsigned int f_flags;521struct tcon_link *tlink;522struct mutex lock_mutex;523struct list_head llist; /* list of byte range locks we have. */524bool invalidHandle:1; /* file closed via session abend */525bool oplock_break_cancelled:1;526int count; /* refcount protected by cifs_file_list_lock */527struct mutex fh_mutex; /* prevents reopen race after dead ses*/528struct cifs_search_info srch_inf;529struct work_struct oplock_break; /* work for oplock breaks */530};531532struct cifs_io_parms {533__u16 netfid;534__u32 pid;535__u64 offset;536unsigned int length;537struct cifs_tcon *tcon;538};539540/*541* Take a reference on the file private data. Must be called with542* cifs_file_list_lock held.543*/544static inline void cifsFileInfo_get(struct cifsFileInfo *cifs_file)545{546++cifs_file->count;547}548549void cifsFileInfo_put(struct cifsFileInfo *cifs_file);550551/*552* One of these for each file inode553*/554555struct cifsInodeInfo {556struct list_head lockList;557/* BB add in lists for dirty pages i.e. write caching info for oplock */558struct list_head openFileList;559__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */560bool clientCanCacheRead; /* read oplock */561bool clientCanCacheAll; /* read and writebehind oplock */562bool delete_pending; /* DELETE_ON_CLOSE is set */563bool invalid_mapping; /* pagecache is invalid */564unsigned long time; /* jiffies of last update of inode */565u64 server_eof; /* current file size on server */566u64 uniqueid; /* server inode number */567u64 createtime; /* creation time on server */568#ifdef CONFIG_CIFS_FSCACHE569struct fscache_cookie *fscache;570#endif571struct inode vfs_inode;572};573574static inline struct cifsInodeInfo *575CIFS_I(struct inode *inode)576{577return container_of(inode, struct cifsInodeInfo, vfs_inode);578}579580static inline struct cifs_sb_info *581CIFS_SB(struct super_block *sb)582{583return sb->s_fs_info;584}585586static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)587{588if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)589return '/';590else591return '\\';592}593594static inline void595convert_delimiter(char *path, char delim)596{597int i;598char old_delim;599600if (path == NULL)601return;602603if (delim == '/')604old_delim = '\\';605else606old_delim = '/';607608for (i = 0; path[i] != '\0'; i++) {609if (path[i] == old_delim)610path[i] = delim;611}612}613614#ifdef CONFIG_CIFS_STATS615#define cifs_stats_inc atomic_inc616617static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,618unsigned int bytes)619{620if (bytes) {621spin_lock(&tcon->stat_lock);622tcon->bytes_written += bytes;623spin_unlock(&tcon->stat_lock);624}625}626627static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon,628unsigned int bytes)629{630spin_lock(&tcon->stat_lock);631tcon->bytes_read += bytes;632spin_unlock(&tcon->stat_lock);633}634#else635636#define cifs_stats_inc(field) do {} while (0)637#define cifs_stats_bytes_written(tcon, bytes) do {} while (0)638#define cifs_stats_bytes_read(tcon, bytes) do {} while (0)639640#endif641642struct mid_q_entry;643644/*645* This is the prototype for the mid callback function. When creating one,646* take special care to avoid deadlocks. Things to bear in mind:647*648* - it will be called by cifsd, with no locks held649* - the mid will be removed from any lists650*/651typedef void (mid_callback_t)(struct mid_q_entry *mid);652653/* one of these for every pending CIFS request to the server */654struct mid_q_entry {655struct list_head qhead; /* mids waiting on reply from this server */656__u16 mid; /* multiplex id */657__u16 pid; /* process id */658__u32 sequence_number; /* for CIFS signing */659unsigned long when_alloc; /* when mid was created */660#ifdef CONFIG_CIFS_STATS2661unsigned long when_sent; /* time when smb send finished */662unsigned long when_received; /* when demux complete (taken off wire) */663#endif664mid_callback_t *callback; /* call completion callback */665void *callback_data; /* general purpose pointer for callback */666struct smb_hdr *resp_buf; /* response buffer */667int midState; /* wish this were enum but can not pass to wait_event */668__u8 command; /* smb command code */669bool largeBuf:1; /* if valid response, is pointer to large buf */670bool multiRsp:1; /* multiple trans2 responses for one request */671bool multiEnd:1; /* both received */672};673674struct oplock_q_entry {675struct list_head qhead;676struct inode *pinode;677struct cifs_tcon *tcon;678__u16 netfid;679};680681/* for pending dnotify requests */682struct dir_notify_req {683struct list_head lhead;684__le16 Pid;685__le16 PidHigh;686__u16 Mid;687__u16 Tid;688__u16 Uid;689__u16 netfid;690__u32 filter; /* CompletionFilter (for multishot) */691int multishot;692struct file *pfile;693};694695struct dfs_info3_param {696int flags; /* DFSREF_REFERRAL_SERVER, DFSREF_STORAGE_SERVER*/697int path_consumed;698int server_type;699int ref_flag;700char *path_name;701char *node_name;702};703704/*705* common struct for holding inode info when searching for or updating an706* inode with new info707*/708709#define CIFS_FATTR_DFS_REFERRAL 0x1710#define CIFS_FATTR_DELETE_PENDING 0x2711#define CIFS_FATTR_NEED_REVAL 0x4712#define CIFS_FATTR_INO_COLLISION 0x8713714struct cifs_fattr {715u32 cf_flags;716u32 cf_cifsattrs;717u64 cf_uniqueid;718u64 cf_eof;719u64 cf_bytes;720u64 cf_createtime;721uid_t cf_uid;722gid_t cf_gid;723umode_t cf_mode;724dev_t cf_rdev;725unsigned int cf_nlink;726unsigned int cf_dtype;727struct timespec cf_atime;728struct timespec cf_mtime;729struct timespec cf_ctime;730};731732static inline void free_dfs_info_param(struct dfs_info3_param *param)733{734if (param) {735kfree(param->path_name);736kfree(param->node_name);737kfree(param);738}739}740741static inline void free_dfs_info_array(struct dfs_info3_param *param,742int number_of_items)743{744int i;745if ((number_of_items == 0) || (param == NULL))746return;747for (i = 0; i < number_of_items; i++) {748kfree(param[i].path_name);749kfree(param[i].node_name);750}751kfree(param);752}753754#define MID_FREE 0755#define MID_REQUEST_ALLOCATED 1756#define MID_REQUEST_SUBMITTED 2757#define MID_RESPONSE_RECEIVED 4758#define MID_RETRY_NEEDED 8 /* session closed while this request out */759#define MID_RESPONSE_MALFORMED 0x10760#define MID_SHUTDOWN 0x20761762/* Types of response buffer returned from SendReceive2 */763#define CIFS_NO_BUFFER 0 /* Response buffer not returned */764#define CIFS_SMALL_BUFFER 1765#define CIFS_LARGE_BUFFER 2766#define CIFS_IOVEC 4 /* array of response buffers */767768/* Type of Request to SendReceive2 */769#define CIFS_BLOCKING_OP 1 /* operation can block */770#define CIFS_ASYNC_OP 2 /* do not wait for response */771#define CIFS_TIMEOUT_MASK 0x003 /* only one of above set in req */772#define CIFS_LOG_ERROR 0x010 /* log NT STATUS if non-zero */773#define CIFS_LARGE_BUF_OP 0x020 /* large request buffer */774#define CIFS_NO_RESP 0x040 /* no response buffer required */775776/* Security Flags: indicate type of session setup needed */777#define CIFSSEC_MAY_SIGN 0x00001778#define CIFSSEC_MAY_NTLM 0x00002779#define CIFSSEC_MAY_NTLMV2 0x00004780#define CIFSSEC_MAY_KRB5 0x00008781#ifdef CONFIG_CIFS_WEAK_PW_HASH782#define CIFSSEC_MAY_LANMAN 0x00010783#define CIFSSEC_MAY_PLNTXT 0x00020784#else785#define CIFSSEC_MAY_LANMAN 0786#define CIFSSEC_MAY_PLNTXT 0787#endif /* weak passwords */788#define CIFSSEC_MAY_SEAL 0x00040 /* not supported yet */789#define CIFSSEC_MAY_NTLMSSP 0x00080 /* raw ntlmssp with ntlmv2 */790791#define CIFSSEC_MUST_SIGN 0x01001792/* note that only one of the following can be set so the793result of setting MUST flags more than once will be to794require use of the stronger protocol */795#define CIFSSEC_MUST_NTLM 0x02002796#define CIFSSEC_MUST_NTLMV2 0x04004797#define CIFSSEC_MUST_KRB5 0x08008798#ifdef CONFIG_CIFS_WEAK_PW_HASH799#define CIFSSEC_MUST_LANMAN 0x10010800#define CIFSSEC_MUST_PLNTXT 0x20020801#ifdef CONFIG_CIFS_UPCALL802#define CIFSSEC_MASK 0xBF0BF /* allows weak security but also krb5 */803#else804#define CIFSSEC_MASK 0xB70B7 /* current flags supported if weak */805#endif /* UPCALL */806#else /* do not allow weak pw hash */807#ifdef CONFIG_CIFS_UPCALL808#define CIFSSEC_MASK 0x8F08F /* flags supported if no weak allowed */809#else810#define CIFSSEC_MASK 0x87087 /* flags supported if no weak allowed */811#endif /* UPCALL */812#endif /* WEAK_PW_HASH */813#define CIFSSEC_MUST_SEAL 0x40040 /* not supported yet */814#define CIFSSEC_MUST_NTLMSSP 0x80080 /* raw ntlmssp with ntlmv2 */815816#define CIFSSEC_DEF (CIFSSEC_MAY_SIGN | CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2)817#define CIFSSEC_MAX (CIFSSEC_MUST_SIGN | CIFSSEC_MUST_NTLMV2)818#define CIFSSEC_AUTH_MASK (CIFSSEC_MAY_NTLM | CIFSSEC_MAY_NTLMV2 | CIFSSEC_MAY_LANMAN | CIFSSEC_MAY_PLNTXT | CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP)819/*820*****************************************************************821* All constants go here822*****************************************************************823*/824825#define UID_HASH (16)826827/*828* Note that ONE module should define _DECLARE_GLOBALS_HERE to cause the829* following to be declared.830*/831832/****************************************************************************833* Locking notes. All updates to global variables and lists should be834* protected by spinlocks or semaphores.835*836* Spinlocks837* ---------838* GlobalMid_Lock protects:839* list operations on pending_mid_q and oplockQ840* updates to XID counters, multiplex id and SMB sequence numbers841* cifs_file_list_lock protects:842* list operations on tcp and SMB session lists and tCon lists843* f_owner.lock protects certain per file struct operations844* mapping->page_lock protects certain per page operations845*846* Semaphores847* ----------848* sesSem operations on smb session849* tconSem operations on tree connection850* fh_sem file handle reconnection operations851*852****************************************************************************/853854#ifdef DECLARE_GLOBALS_HERE855#define GLOBAL_EXTERN856#else857#define GLOBAL_EXTERN extern858#endif859860/*861* the list of TCP_Server_Info structures, ie each of the sockets862* connecting our client to a distinct server (ip address), is863* chained together by cifs_tcp_ses_list. The list of all our SMB864* sessions (and from that the tree connections) can be found865* by iterating over cifs_tcp_ses_list866*/867GLOBAL_EXTERN struct list_head cifs_tcp_ses_list;868869/*870* This lock protects the cifs_tcp_ses_list, the list of smb sessions per871* tcp session, and the list of tcon's per smb session. It also protects872* the reference counters for the server, smb session, and tcon. Finally,873* changes to the tcon->tidStatus should be done while holding this lock.874*/875GLOBAL_EXTERN spinlock_t cifs_tcp_ses_lock;876877/*878* This lock protects the cifs_file->llist and cifs_file->flist879* list operations, and updates to some flags (cifs_file->invalidHandle)880* It will be moved to either use the tcon->stat_lock or equivalent later.881* If cifs_tcp_ses_lock and the lock below are both needed to be held, then882* the cifs_tcp_ses_lock must be grabbed first and released last.883*/884GLOBAL_EXTERN spinlock_t cifs_file_list_lock;885886#ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */887/* Outstanding dir notify requests */888GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;889/* DirNotify response queue */890GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;891#endif /* was needed for dnotify, and will be needed for inotify when VFS fix */892893/*894* Global transaction id (XID) information895*/896GLOBAL_EXTERN unsigned int GlobalCurrentXid; /* protected by GlobalMid_Sem */897GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */898GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */899GLOBAL_EXTERN spinlock_t GlobalMid_Lock; /* protects above & list operations */900/* on midQ entries */901/*902* Global counters, updated atomically903*/904GLOBAL_EXTERN atomic_t sesInfoAllocCount;905GLOBAL_EXTERN atomic_t tconInfoAllocCount;906GLOBAL_EXTERN atomic_t tcpSesAllocCount;907GLOBAL_EXTERN atomic_t tcpSesReconnectCount;908GLOBAL_EXTERN atomic_t tconInfoReconnectCount;909910/* Various Debug counters */911GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */912#ifdef CONFIG_CIFS_STATS2913GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */914GLOBAL_EXTERN atomic_t totSmBufAllocCount;915#endif916GLOBAL_EXTERN atomic_t smBufAllocCount;917GLOBAL_EXTERN atomic_t midCount;918919/* Misc globals */920GLOBAL_EXTERN unsigned int multiuser_mount; /* if enabled allows new sessions921to be established on existing mount if we922have the uid/password or Kerberos credential923or equivalent for current user */924GLOBAL_EXTERN unsigned int oplockEnabled;925GLOBAL_EXTERN unsigned int lookupCacheEnabled;926GLOBAL_EXTERN unsigned int global_secflags; /* if on, session setup sent927with more secure ntlmssp2 challenge/resp */928GLOBAL_EXTERN unsigned int sign_CIFS_PDUs; /* enable smb packet signing */929GLOBAL_EXTERN unsigned int linuxExtEnabled;/*enable Linux/Unix CIFS extensions*/930GLOBAL_EXTERN unsigned int CIFSMaxBufSize; /* max size not including hdr */931GLOBAL_EXTERN unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */932GLOBAL_EXTERN unsigned int cifs_min_small; /* min size of small buf pool */933GLOBAL_EXTERN unsigned int cifs_max_pending; /* MAX requests at once to server*/934935/* reconnect after this many failed echo attempts */936GLOBAL_EXTERN unsigned short echo_retries;937938GLOBAL_EXTERN struct rb_root uidtree;939GLOBAL_EXTERN struct rb_root gidtree;940GLOBAL_EXTERN spinlock_t siduidlock;941GLOBAL_EXTERN spinlock_t sidgidlock;942943void cifs_oplock_break(struct work_struct *work);944void cifs_oplock_break_get(struct cifsFileInfo *cfile);945void cifs_oplock_break_put(struct cifsFileInfo *cfile);946947extern const struct slow_work_ops cifs_oplock_break_ops;948949#endif /* _CIFS_GLOB_H */950951952