OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/WINNT/afsd/cm_vnodeops.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 #ifndef OPENAFS_WINNT_AFSD_CM_VNODEOPS_H
00011 #define OPENAFS_WINNT_AFSD_CM_VNODEOPS_H 1
00012 
00013 extern unsigned int cm_mountRootGen;
00014 
00015 extern int cm_enableServerLocks;
00016 
00017 extern int cm_followBackupPath;
00018 
00019 /* parms for attribute setting call */
00020 typedef struct cm_attr {
00021     int         mask;
00022     time_t      clientModTime;
00023     osi_hyper_t length;
00024     int         unixModeBits;
00025     long        owner;
00026     long        group;
00027 } cm_attr_t;
00028 
00029 #define CM_ATTRMASK_CLIENTMODTIME       1       /* set if field is valid */
00030 #define CM_ATTRMASK_LENGTH              2       /* field is valid */
00031 #define CM_ATTRMASK_UNIXMODEBITS        4       /* field is valid */
00032 #define CM_ATTRMASK_OWNER               8       /* field is valid */
00033 #define CM_ATTRMASK_GROUP               0x10    /* field is valid */
00034 
00035 /* type of rock for lookup's searches */
00036 typedef struct cm_lookupSearch {
00037     cm_fid_t      fid;
00038     fschar_t     *searchNamep;
00039     normchar_t   *nsearchNamep;
00040     int           found;
00041     int           LCfound, UCfound, NCfound, ExactFound;
00042     int           caseFold;
00043     int           hasTilde;
00044 } cm_lookupSearch_t;
00045 
00046 #include "cm_dir.h"
00047 
00048 typedef int (*cm_DirFuncp_t)(struct cm_scache *, struct cm_dirEntry *, void *,
00049                              osi_hyper_t *entryOffsetp);
00050 
00051 /* Special path syntax for direct references to volumes
00052 
00053    The syntax: @vol:<cellname>{%,#}<volume> can be used to refer to a
00054    specific volume in a specific cell, where:
00055 
00056    <cellname> : name of the cell
00057    <volume>   : volume name or ID
00058  */
00059 #define CM_PREFIX_VOL "@vol:"
00060 #define CM_PREFIX_VOL_CCH 5
00061 
00062 /* Maximum number of expanded components in a path */
00063 #define MAX_FID_COUNT 512
00064 
00065 /* arrays */
00066 
00067 extern fschar_t cm_foldUpper[];
00068 
00069 /* functions */
00070 
00071 extern int cm_NoneLower(normchar_t *s);
00072 
00073 extern int cm_NoneUpper(normchar_t *s);
00074 
00075 extern int cm_stricmp(const char *, const char *);
00076 
00077 extern long cm_ReadMountPoint(cm_scache_t *scp, cm_user_t *userp,
00078                               cm_req_t *reqp);
00079 
00080 extern long cm_EvaluateVolumeReference(clientchar_t * namep, long flags, cm_user_t * userp,
00081                                        cm_req_t *reqp, cm_scache_t ** outpScpp);
00082 
00083 #ifdef DEBUG_REFCOUNT
00084 extern long cm_NameIDbg(cm_scache_t *rootSCachep, clientchar_t *pathp, long flags,
00085                         cm_user_t *userp, clientchar_t *tidPathp, cm_req_t *reqp,
00086                         cm_scache_t **outScpp, char *, long);
00087 
00088 extern long cm_LookupDbg(cm_scache_t *dscp, clientchar_t *namep, long flags,
00089                          cm_user_t *userp, cm_req_t *reqp, cm_scache_t **outpScpp,
00090                          char *, long);
00091 
00092 #define cm_Lookup(a,b,c,d,e,f)  cm_LookupDbg(a,b,c,d,e,f,__FILE__,__LINE__)
00093 #define cm_NameI(a,b,c,d,e,f,g) cm_NameIDbg(a,b,c,d,e,f,g,__FILE__,__LINE__)
00094 #else
00095 extern long cm_NameI(cm_scache_t *rootSCachep, clientchar_t *pathp, long flags,
00096                      cm_user_t *userp, clientchar_t *tidPathp, cm_req_t *reqp,
00097                      cm_scache_t **outScpp);
00098 extern long cm_Lookup(cm_scache_t *dscp, clientchar_t *namep, long flags,
00099                       cm_user_t *userp, cm_req_t *reqp, cm_scache_t **outpScpp);
00100 #endif
00101 
00102 extern long cm_LookupInternal(cm_scache_t *dscp, clientchar_t *namep, long flags,
00103                               cm_user_t *userp, cm_req_t *reqp,
00104                               cm_scache_t **outpScpp);
00105 
00106 extern afs_int32 cm_TryBulkStat(cm_scache_t *dscp, osi_hyper_t *offsetp,
00107                                 cm_user_t *userp, cm_req_t *reqp);
00108 
00109 extern long cm_SetAttr(cm_scache_t *scp, cm_attr_t *attrp, cm_user_t *userp,
00110                        cm_req_t *reqp);
00111 
00112 extern long cm_Create(cm_scache_t *scp, clientchar_t *namep, long flags,
00113                       cm_attr_t *attrp, cm_scache_t **scpp,
00114                       cm_user_t *userp, cm_req_t *reqp);
00115 
00116 extern long cm_FSync(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp, afs_uint32 locked);
00117 
00118 extern void cm_StatusFromAttr(struct AFSStoreStatus *statusp,
00119                               struct cm_scache *scp, struct cm_attr *attrp);
00120 
00121 extern long cm_Unlink(cm_scache_t *dscp, fschar_t *fnamep,
00122                       clientchar_t *cnamep,
00123                       cm_user_t *userp, cm_req_t *reqp);
00124 
00125 extern long cm_ApplyDir(cm_scache_t *scp, cm_DirFuncp_t funcp, void *parmp,
00126                         osi_hyper_t *startOffsetp, cm_user_t *userp, cm_req_t *reqp,
00127                         cm_scache_t **retscp);
00128 
00129 extern long cm_MakeDir(cm_scache_t *dscp, clientchar_t *lastNamep, long flags,
00130                        cm_attr_t *attrp, cm_user_t *userp, cm_req_t *reqp,
00131                        cm_scache_t **scpp);
00132 
00133 extern long cm_RemoveDir(cm_scache_t *dscp, fschar_t *lastNamep, clientchar_t *originalNamep,
00134                          cm_user_t *userp, cm_req_t *reqp);
00135 
00136 extern long cm_Rename(cm_scache_t *oldDscp,
00137                       fschar_t *oldLastNamep, clientchar_t *normalizedOldNamep,
00138                       cm_scache_t *newDscp, clientchar_t *newLastNamep,
00139                       cm_user_t *userp, cm_req_t *reqp);
00140 
00141 extern long cm_HandleLink(cm_scache_t *linkScp, struct cm_user *userp,
00142                           cm_req_t *reqp);
00143 
00144 extern long cm_Link(cm_scache_t *dscp, clientchar_t *namep, cm_scache_t *sscp,
00145                     long flags, cm_user_t *userp, cm_req_t *reqp);
00146 
00147 extern long cm_SymLink(cm_scache_t *dscp, clientchar_t *namep, fschar_t *contentsp,
00148                        long flags, cm_attr_t *attrp, cm_user_t *userp, cm_req_t *reqp,
00149                        cm_scache_t **scpp);
00150 
00151 extern long cm_AssembleLink(cm_scache_t *linkScp, fschar_t *pathSuffixp,
00152                             cm_scache_t **newRootScpp, cm_space_t **newSpaceBufferp,
00153                             cm_user_t *userp, cm_req_t *reqp);
00154 
00155 extern int cm_ExpandSysName(cm_req_t *reqp, clientchar_t *inp, clientchar_t *outp, long outSizeCch,
00156                             unsigned int sysNameIndex);
00157 
00158 extern long cm_Open(cm_scache_t *scp, int type, cm_user_t *userp);
00159 
00160 extern long cm_CheckOpen(cm_scache_t *scp, int openMode, int trunc,
00161                          cm_user_t *userp, cm_req_t *reqp);
00162 
00163 /*
00164  * Combinations of file opening access bits for AFS.
00165  * We don't insist on write rights to open the file with FILE_WRITE_ATTRIBUTES,
00166  * because we want to enable the owner to set/clear the READONLY flag.
00167  * The RPC will fail if you can't modify the attributes, anyway.
00168  */
00169 #define AFS_ACCESS_READ (FILE_GENERIC_READ & ~SYNCHRONIZE)
00170 #define AFS_ACCESS_WRITE ((FILE_GENERIC_WRITE & ~(READ_CONTROL | SYNCHRONIZE)) \
00171                                 & ~FILE_WRITE_ATTRIBUTES)
00172 #define AFS_ACCESS_EXECUTE (FILE_GENERIC_EXECUTE & ~SYNCHRONIZE)
00173 
00174 typedef struct cm_lock_data {
00175     cm_key_t key;
00176     unsigned int sLockType;
00177     LARGE_INTEGER LOffset, LLength;
00178 } cm_lock_data_t;
00179 
00180 extern long cm_CheckNTOpen(cm_scache_t *scp,
00181                            unsigned int desiredAccess,
00182                            unsigned int shareAccess,
00183                            unsigned int createDisp,
00184                            afs_offs_t process_id,
00185                            afs_offs_t handle_id,
00186                            cm_user_t *userp, cm_req_t *reqp,
00187                            cm_lock_data_t ** ldpp);
00188 
00189 extern long cm_CheckNTOpenDone(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp,
00190                                cm_lock_data_t ** ldpp);
00191 
00192 extern long cm_CheckNTDelete(cm_scache_t *dscp, cm_scache_t *scp,
00193                              cm_user_t *userp, cm_req_t *reqp);
00194 
00195 extern long cm_EvaluateSymLink(cm_scache_t *dscp, cm_scache_t *linkScp,
00196                                cm_scache_t **outScpp, cm_user_t *userp,
00197                                cm_req_t *reqp);
00198 
00199 extern long cm_FollowMountPoint(cm_scache_t *scp, cm_scache_t *dscp, cm_user_t *userp,
00200                                 cm_req_t *reqp, cm_scache_t **outScpp);
00201 
00202 
00203 extern long cm_Lock(cm_scache_t *scp, unsigned char sLockType,
00204                     LARGE_INTEGER LOffset, LARGE_INTEGER LLength, cm_key_t key,
00205                     int allowWait, cm_user_t *userp, cm_req_t *reqp,
00206                     cm_file_lock_t **lockpp);
00207 
00208 extern long cm_UnlockByKey(cm_scache_t * scp,
00209                            cm_key_t key,
00210                            afs_uint32 flags,
00211                            cm_user_t * userp,
00212                            cm_req_t * reqp);
00213 
00214 #define CM_UNLOCK_FLAG_BY_FID           0x0001
00215 #define CM_UNLOCK_FLAG_MATCH_RANGE      0x0002
00216 
00217 extern long cm_Unlock(cm_scache_t *scp, unsigned char sLockType,
00218                       LARGE_INTEGER LOffset, LARGE_INTEGER LLength, cm_key_t key,
00219                       afs_uint32 flags, cm_user_t *userp, cm_req_t *reqp);
00220 
00221 extern long cm_LockCheckRead(cm_scache_t *scp,
00222                              LARGE_INTEGER LOffset,
00223                              LARGE_INTEGER LLength,
00224                              cm_key_t key);
00225 
00226 extern long cm_LockCheckWrite(cm_scache_t *scp,
00227                               LARGE_INTEGER LOffset,
00228                               LARGE_INTEGER LLength,
00229                               cm_key_t key);
00230 
00231 extern void cm_CheckLocks(void);
00232 
00233 extern void cm_ReleaseAllLocks(void);
00234 
00235 extern void cm_LockMarkSCacheLost(cm_scache_t * scp);
00236 
00237 extern long cm_RetryLock(cm_file_lock_t *oldFileLock, int client_is_dead);
00238 
00239 #define CM_SESSION_SMB      0xffff
00240 #define CM_SESSION_IFS      0xfffe
00241 #define CM_SESSION_CMINT    0xfffd
00242 #define CM_SESSION_RESERVED 0xfff0
00243 
00244 extern cm_key_t cm_GenerateKey(afs_uint16 session_id, afs_offs_t process_id, afs_uint64 file_id);
00245 
00246 extern int cm_KeyEquals(cm_key_t * k1, cm_key_t * k2, int flags);
00247 
00248 extern int cm_IsSpaceAvailable(cm_fid_t * fidp, osi_hyper_t *sizep, cm_user_t *userp, cm_req_t *reqp);
00249 
00250 #define MAX_SYMLINK_COUNT 64
00251 
00252 /* make this big enough so that one buffer of dir pages won't overflow.  We'll
00253  * check anyway, but we want to minimize the chance that we have to leave stuff
00254  * unstat'd.
00255  */
00256 #define CM_BULKMAX              (3 * AFSCBMAX)
00257 
00258 /* rock for bulk stat calls */
00259 typedef struct cm_bulkStat {
00260     cm_user_t *userp;
00261     osi_hyper_t bufOffset;      /* only do it for things in this buffer page */
00262 
00263     /* info for the actual call */
00264     int counter;                        /* next free slot */
00265     AFSFid fids[CM_BULKMAX];
00266     AFSFetchStatus stats[CM_BULKMAX];
00267     AFSCallBack callbacks[CM_BULKMAX];
00268 } cm_bulkStat_t;
00269 
00270 extern afs_int32 cm_TryBulkStatRPC(cm_scache_t *dscp, cm_bulkStat_t *bbp,
00271                                    cm_user_t *userp, cm_req_t *reqp);
00272 
00273 #endif /*  OPENAFS_WINNT_AFSD_CM_VNODEOPS_H */
 All Data Structures Files Functions Variables