github.com/avfs/avfs@v0.33.1-0.20240303173310-c6ba67c33eb7/idm/memidm/memidm_types.go (about) 1 // 2 // Copyright 2020 The AVFS authors 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 package memidm 18 19 import ( 20 "sync" 21 22 "github.com/avfs/avfs" 23 ) 24 25 const ( 26 // minUid is the minimum uid for a user. 27 minUid = 1000 28 29 // minGid is the minimum gid for a group. 30 minGid = 1000 31 ) 32 33 // MemIdm implements an in memory identity manager using the avfs.IdentityMgr interface. 34 type MemIdm struct { 35 adminGroup *MemGroup // adminGroup is the Administrator Group. 36 adminUser *MemUser // adminUser is the Administrator User. 37 groupsByName groupsByName // groupsByName is the groups map by Name. 38 groupsById groupsById // groupsById is the groups map by Id. 39 usersByName usersByName // usersByName is the users map by Name. 40 usersById usersById // usersById is users map by Id. 41 maxGid int // maxGid is the current maximum Gid. 42 maxUid int // maxUid is the current maximum Uid. 43 grpMu sync.RWMutex // grpMu is the groups mutex. 44 usrMu sync.RWMutex // usrMu is the users mutex. 45 avfs.FeaturesFn // FeaturesFn provides features functions to a file system or an identity manager. 46 avfs.OSTypeFn // OSTypeFn provides OS type functions to a file system or an identity manager. 47 } 48 49 // groupsByName is the map of groups by group name. 50 type groupsByName map[string]*MemGroup 51 52 // groupsById is the map of the groups by group id. 53 type groupsById map[int]*MemGroup 54 55 // usersByName is the map of the users by username. 56 type usersByName map[string]*MemUser 57 58 // usersById is the map of the users by user id. 59 type usersById map[int]*MemUser 60 61 // MemUser is the implementation of avfs.UserReader. 62 type MemUser struct { 63 name string 64 uid int 65 gid int 66 } 67 68 // MemGroup is the implementation of avfs.GroupReader. 69 type MemGroup struct { 70 name string 71 gid int 72 } 73 74 // Options defines the initialization options of MemIdm. 75 type Options struct { 76 OSType avfs.OSType // OSType defines the operating system type. 77 }