1/* 2 * $Id: cnid_cdb_private.h,v 1.7 2009-11-20 17:22:11 didg Exp $ 3 */ 4 5#ifndef LIBATALK_CDB_PRIVATE_H 6#define LIBATALK_CDB_PRIVATE_H 1 7 8#ifdef HAVE_CONFIG_H 9#include "config.h" 10#endif /* HAVE_CONFIG_H */ 11 12#include <netatalk/endian.h> 13 14#ifdef HAVE_UNISTD_H 15#include <unistd.h> 16#endif /* HAVE_UNISTD_H */ 17#include <stdlib.h> 18#include <string.h> 19#include <errno.h> 20#ifdef HAVE_FCNTL_H 21#include <fcntl.h> 22#endif /* HAVE_FCNTL_H */ 23#include <sys/param.h> 24#include <sys/stat.h> 25#ifdef HAVE_SYS_TIME_H 26#include <sys/time.h> 27#endif /* HAVE_SYS_TIME_H */ 28#ifdef HAVE_TIME_H 29#include <time.h> 30#endif 31#include <sys/cdefs.h> 32#include <db.h> 33 34#include <atalk/logger.h> 35#include <atalk/adouble.h> 36#include <atalk/cnid_private.h> 37#include <atalk/cnid.h> 38#include <atalk/util.h> 39#include "cnid_cdb.h" 40 41/* record structure 42 cnid 4 43 dev 8 44 inode 8 45 type/last cnid 4 Not used 46 did 4 47 name strlen(name) +1 48 49primary key 50cnid 51secondary keys 52dev/inode 53did/name 54 55*/ 56 57typedef struct cnid_record { /* helper for debug don't use */ 58 unsigned int cnid; 59 dev_t dev; 60 ino_t inode; 61 unsigned int type; 62 unsigned int did; 63 char name[50]; 64} cnid_record; 65 66typedef struct CNID_private { 67 u_int32_t magic; 68 DB *db_cnid; 69 DB *db_didname; 70 DB *db_devino; 71 DB_ENV *dbenv; 72 int lockfd, flags; 73 char lock_file[MAXPATHLEN + 1]; 74} CNID_private; 75 76/* XXX stuff below is outdate */ 77/* on-disk data format (in network byte order where appropriate) -- 78 * db_cnid: (key: cnid) 79 * name size (in bytes) 80 * dev 4 81 * ino 4 82 * did 4 83 * unix name strlen(name) + 1 84 * 85 * db_didname: (key: did/unix name) 86 * -- this also caches the bits of .AppleDouble used by FPGetFilDirParam 87 * so that we don't have to open the header file. 88 * NOTE: FPCatSearch has to search through all of the directories as 89 * this stuff doesn't get entered until needed. 90 * if the entire volume is in the database, though, we can use 91 * cursor operations to make this faster. 92 * 93 * version number is stored with did/name key of 0/0 94 * 95 * cnid 4 96 * modfiller 4 (dates only use 4 bytes right now, but we leave space 97 * moddate 4 for 8. moddate is also used to keep this info 98 * createfiller 4 up-to-date.) 99 * createdate 4 100 * backfiller 4 101 * backupdate 4 102 * accfiller 4 (unused) 103 * accdate 4 (unused) 104 * AFP info 4 (stores a couple permission bits as well) 105 * finder info 32 106 * prodos info 8 107 * rforkfiller 4 108 * rforklen 4 109 * macname 32 (nul-terminated) 110 * shortname 12 (nul-terminated) 111 * longname longnamelen (nul-terminated) 112 * --------------- 113 * 132 bytes + longnamelen 114 * 115 * db_devino: (key: dev/ino) 116 * -- this is only used for consistency checks and isn't 1-1 117 * cnid 4 118 * 119 * these correspond to the different path types. longname is for the 120 * 255 unicode character names (path type == ?), macname is for the 121 * 32-character names (path type == 2), and shortname is for the 122 * 8+3-character names (path type == 1). 123 * 124 * db_longname: (key: did/longname) 125 * name namelen = strlen(name) + 1 126 * 127 * db_macname: (key: did/macname) 128 * name namelen = strlen(name) + 1 129 * 130 * db_shortname: (key: did/shortname) 131 * name namelen = strlen(name) + 1 132 */ 133 134/* construct db_cnid data. NOTE: this is not re-entrant. */ 135extern unsigned char *make_cnid_data (u_int32_t flags, const struct stat *,const cnid_t , 136 const char *, const size_t ); 137 138#endif /* atalk/cnid/cnid_private.h */ 139