/*
SSSD
Mmap Cache Common header
Copyright (C) Simo Sorce <ssorce@redhat.com> 2011
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MMAP_CACHE_H_
#define _MMAP_CACHE_H_
#include "util/murmurhash3.h"
/* NOTE: all the code here assumes that writing a uint32_t nto mmapped
* memory is an atomic operation and can't be split in multiple
* non-atomic operations */
/* align macros */
/* ^^ 8 bits per byte so we need just elems/8 bytes to represent all blocks */
/*
* 40 seem a good compromise for slot size
* 4 blocks are enough for the average passwd entry of 42 bytes
* passwd records have 84 bytes of overhead, 160 - 82 = 78 bytes
* 3 blocks can contain a very minimal entry, 120 - 82 = 38 bytes
*
* 3 blocks are enough for groups w/o users (private user groups)
* group records have 68 bytes of overhead, 120 - 66 = 54 bytes
*/
#pragma pack(1)
struct sss_mc_header {
};
struct sss_mc_rec {
/* next1 is related to hash1 */
/* next2 is related to hash2 */
char data[0];
};
struct sss_mc_pwd_data {
* string is zero terminated ordered as follows:
* name, passwd, gecos, dir, shell */
};
struct sss_mc_grp_data {
* string is zero terminated ordered as follows:
* name, passwd, member1, member2, ... */
};
struct sss_mc_initgr_data {
* string with name and unique_name is stored
* after gids */
};
#pragma pack()
#endif /* _MMAP_CACHE_H_ */