2 * Copyright (c) 2012 Your File System, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * - Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * - Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * - Neither the name of Secure Endpoints Inc. nor the names of its contributors
14 * may be used to endorse or promote products derived from this software without
15 * specific prior written permission from Secure Endpoints, Inc. and
16 * Your File System, Inc.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #include "cm_scache.h"
37 #define CM_EACCES_MAGIC ('E' | 'A' <<8 | 'C'<<16 | 'C'<<24)
40 * Structure to hold EACCES error info for FID,User pairs
43 typedef struct cm_eacces {
44 struct osi_queue q; /* fid hash table or free list */
46 struct osi_queue parentq;
47 struct osi_queue userq;
54 #define parentq_to_cm_eacces_t(q) ((q) ? (cm_eacces_t *)((char *) (q) - offsetof(cm_eacces_t, parentq)) : NULL)
55 #define userq_to_cm_eacces_t(q) ((q) ? (cm_eacces_t *)((char *) (q) - offsetof(cm_eacces_t, userq)) : NULL)
57 #define CM_EACCES_FID_HASH(fidp) (opr_jhash(&(fidp)->cell, 4, 0) & (cm_eaccesFidHashTableSize - 1))
59 #define CM_EACCES_PARENT_HASH(fidp) (opr_jhash(&(fidp)->cell, 4, 0) & (cm_eaccesParentHashTableSize - 1))
61 #define CM_EACCES_USER_HASH(userp) (opr_jhash((const uint32_t *)&userp, sizeof(cm_user_t *)/4, 0) & (cm_eaccesUserHashTableSize - 1))
63 extern void cm_EAccesInitCache(void);
65 extern cm_eacces_t * cm_EAccesFindEntry(cm_user_t* userp, cm_fid_t *fidp);
67 extern afs_uint32 cm_EAccesAddEntry(cm_user_t* userp, cm_fid_t *fidp, cm_fid_t *parentFidp);
69 extern void cm_EAccesClearParentEntries(cm_fid_t *parentFip);
71 extern void cm_EAccesClearUserEntries(cm_user_t *userp, afs_uint32 CellID);
73 extern void cm_EAccesClearOutdatedEntries(void);
77 * The EACCES cache works by storing EACCES events by the FID and User
78 * for which the event occurred, when it occurred and the FID of the parent
79 * directory. By definition, the parent FID of a volume root directory
82 * Entries are removed from the cache under the following circumstances:
83 * 1. When the parent FID's callback expires or is replaced.
84 * 2. When the parent FID's cm_scache object is recycled.
85 * 3. When the user's tokens expire or are replaced.
87 * Entries are not removed when the FID's cm_scache object is recycled.
89 #endif /* _CM_EACCES_H_ */