OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright (c) 2012 Your File System, Inc. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * - Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * - Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * - Neither the name of Secure Endpoints Inc. nor the names of its contributors 00014 * may be used to endorse or promote products derived from this software without 00015 * specific prior written permission from Secure Endpoints, Inc. and 00016 * Your File System, Inc. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00020 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00021 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00022 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00026 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 #ifndef _CM_EACCES_H_ 00032 #define _CM_EACCES_H_ 00033 00034 #include <osi.h> 00035 #include "cm_scache.h" 00036 00037 #define CM_EACCES_MAGIC ('E' | 'A' <<8 | 'C'<<16 | 'C'<<24) 00038 00039 /* 00040 * Structure to hold EACCES error info for FID,User pairs 00041 */ 00042 00043 typedef struct cm_eacces { 00044 struct osi_queue q; /* fid hash table or free list */ 00045 afs_uint32 magic; 00046 struct osi_queue parentq; 00047 struct osi_queue userq; 00048 cm_fid_t fid; 00049 cm_fid_t parentFid; 00050 cm_user_t *userp; 00051 time_t errorTime; 00052 } cm_eacces_t; 00053 00054 #define parentq_to_cm_eacces_t(q) ((q) ? (cm_eacces_t *)((char *) (q) - offsetof(cm_eacces_t, parentq)) : NULL) 00055 #define userq_to_cm_eacces_t(q) ((q) ? (cm_eacces_t *)((char *) (q) - offsetof(cm_eacces_t, userq)) : NULL) 00056 00057 #define CM_EACCES_FID_HASH(fidp) (opr_jhash(&(fidp)->cell, 4, 0) & (cm_eaccesFidHashTableSize - 1)) 00058 00059 #define CM_EACCES_PARENT_HASH(fidp) (opr_jhash(&(fidp)->cell, 4, 0) & (cm_eaccesParentHashTableSize - 1)) 00060 00061 #define CM_EACCES_USER_HASH(userp) (opr_jhash((const uint32_t *)&userp, sizeof(cm_user_t *)/4, 0) & (cm_eaccesUserHashTableSize - 1)) 00062 00063 extern void cm_EAccesInitCache(void); 00064 00065 extern cm_eacces_t * cm_EAccesFindEntry(cm_user_t* userp, cm_fid_t *fidp); 00066 00067 extern afs_uint32 cm_EAccesAddEntry(cm_user_t* userp, cm_fid_t *fidp, cm_fid_t *parentFidp); 00068 00069 extern void cm_EAccesClearParentEntries(cm_fid_t *parentFip); 00070 00071 extern void cm_EAccesClearUserEntries(cm_user_t *userp, afs_uint32 CellID); 00072 00073 extern void cm_EAccesClearOutdatedEntries(void); 00074 00075 00076 /* 00077 * The EACCES cache works by storing EACCES events by the FID and User 00078 * for which the event occurred, when it occurred and the FID of the parent 00079 * directory. By definition, the parent FID of a volume root directory 00080 * is itself. 00081 * 00082 * Entries are removed from the cache under the following circumstances: 00083 * 1. When the parent FID's callback expires or is replaced. 00084 * 2. When the parent FID's cm_scache object is recycled. 00085 * 3. When the user's tokens expire or are replaced. 00086 * 00087 * Entries are not removed when the FID's cm_scache object is recycled. 00088 */ 00089 #endif /* _CM_EACCES_H_ */