From aa864415c5183c948fe9ae221023d40265c38013 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Tue, 20 May 1997 00:32:51 +0000 Subject: dir.c: Fixed double slash issue. includes.h: Changed to ifdef FAST_SHARE_MODES. ipc.c: Changed lp_workgroup() to myworkgroup. loadparm.c: Added new shared mem parameters. Added Luke's fix. locking.c: Rewrite to do share modes better (both fast and slow modes). nameannounce.c: Changed lp_workgroup() to myworkgroup. Added Luke's fix. nameconf.c: Changed lp_workgroup() to myworkgroup. namedbname.c: Improved debug. namedbserver.c: Changed lp_workgroup() to myworkgroup. namedbsubnet.c: Added Luke's fix - rewritten somewhat. namedbwork.c: Changed lp_workgroup() to myworkgroup. nameelect.c: Added Luke's fix - rewritten somewhat. nameresp.c: Stoped shadowing global. nameserv.c: Added Luke's fix - Improved debug. nameservreply.c: Improved debug. namework.c: Changed lp_workgroup() to myworkgroup. nmbd.c: Added Luke's fix - Changed lp_workgroup() to myworkgroup. pipes.c: Changed lp_workgroup() to myworkgroup. proto.h: Added Luke's fix, added smb_shm_ proto's. reply.c: Changed lp_workgroup() to myworkgroup. server.c: Rewrite to do share modes better (both fast and slow modes). shmem.c: Rewrite to do share modes better (both fast and slow modes). smb.h: Rewrite to do share modes better (both fast and slow modes). status.c: Rewrite to do share modes better (both fast and slow modes). trans2.c: Fixed double slash issue. util.c: Tidied up, created myworkgroup. Jeremy Allison (jallison@whistle.com). (This used to be commit 2a1711eaaf08bb6776770cd3c96b3010f431a677) --- source3/include/includes.h | 3 ++- source3/include/proto.h | 25 ++++++++++++++--------- source3/include/smb.h | 50 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 57 insertions(+), 21 deletions(-) (limited to 'source3/include') diff --git a/source3/include/includes.h b/source3/include/includes.h index e1ed3a5816..265e838be0 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -481,6 +481,7 @@ char *mktemp(char *); /* No standard include */ #ifdef FreeBSD +#include #include #include #include @@ -970,7 +971,7 @@ typedef int mode_t; end of the platform specific sections ********************************************************************/ -#if defined(USE_MMAP) || FAST_SHARE_MODES +#if defined(USE_MMAP) || defined(FAST_SHARE_MODES) #include #endif diff --git a/source3/include/proto.h b/source3/include/proto.h index 973b1a15f3..1fa8c1d95e 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -149,6 +149,7 @@ char *lp_socket_address(void); char *lp_nis_home_map_name(void); BOOL lp_wins_support(void); BOOL lp_wins_proxy(void); +BOOL lp_local_master(void); BOOL lp_domain_master(void); BOOL lp_domain_logons(void); BOOL lp_preferred_master(void); @@ -176,6 +177,8 @@ int lp_maxpacket(void); int lp_keepalive(void); int lp_passwordlevel(void); int lp_readsize(void); +int lp_shmem_size(void); +int lp_shmem_hash_size(void); int lp_deadtime(void); int lp_maxprotocol(void); int lp_security(void); @@ -266,12 +269,12 @@ BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ec BOOL do_unlock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); BOOL start_share_mode_mgmt(void); BOOL stop_share_mode_mgmt(void); -int get_share_mode_by_fnum(int cnum,int fnum,int *pid); -int get_share_mode_byname(int cnum,char *fname,int *pid); -int get_share_mode(int cnum,struct stat *sbuf,int *pid); -void del_share_mode(int fnum); -BOOL set_share_mode(int fnum,int mode); -void clean_share_modes(void); +BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *); +BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token); +int get_share_modes(int cnum, share_lock_token token, uint32 dev, uint32 inode, + min_share_mode_entry **old_shares); +void del_share_mode(share_lock_token token, int fnum); +BOOL set_share_mode(share_lock_token token, int fnum); /*The following definitions come from mangle.c */ @@ -309,7 +312,7 @@ void do_announce_host(int command, char *to_name , int to_type , struct in_addr to_ip, time_t announce_interval, char *server_name, int server_type, char *server_comment); -void remove_my_servers(void); +void announce_my_servers_removed(void); void announce_server(struct subnet_record *d, struct work_record *work, char *name, char *comment, time_t ttl, int server_type); void announce_host(time_t t); @@ -394,7 +397,7 @@ void expire_servers(time_t t); struct subnet_record *find_subnet(struct in_addr bcast_ip); struct subnet_record *find_req_subnet(struct in_addr ip, BOOL bcast); struct subnet_record *find_subnet_all(struct in_addr bcast_ip); -void add_subnet_interfaces(void); +void add_workgroup_to_subnet( struct subnet_record *d, char *group); void add_my_subnets(char *group); void write_browse_list(time_t t); @@ -406,7 +409,6 @@ struct work_record *remove_workgroup(struct subnet_record *d, struct work_record *find_workgroupstruct(struct subnet_record *d, fstring name, BOOL add); void dump_workgroups(void); -int check_work_servertype(const char *work_name, int type_mask); /*The following definitions come from nameelect.c */ @@ -724,6 +726,11 @@ BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off); void * smb_shm_offset2addr(smb_shm_offset_t offset); BOOL smb_shm_lock(void); BOOL smb_shm_unlock(void); +smb_shm_offset_t smb_shm_alloc(int size); +smb_shm_offset_t smb_shm_addr2offset(void *addr); +smb_shm_offset_t smb_shm_get_userdef_off(void); +BOOL smb_shm_lock_hash_entry( unsigned int entry); +BOOL smb_shm_unlock_hash_entry( unsigned int entry ); BOOL smb_shm_get_usage(int *bytes_free, int *bytes_used, int *bytes_overhead); diff --git a/source3/include/smb.h b/source3/include/smb.h index 7cd2f5b0fe..e0c08183db 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -36,11 +36,16 @@ #define BUFFER_SIZE (0xFFFF) #define SAFETY_MARGIN 1024 -/* size of shared memory used for share mode locking */ +/* Default size of shared memory used for share mode locking */ #ifndef SHMEM_SIZE #define SHMEM_SIZE 102400 #endif +/* Default number of hash buckets used in shared memory share mode */ +#ifndef SHMEM_HASH_SIZE +#define SHMEM_HASH_SIZE 113 +#endif + #define NMB_PORT 137 #define DGRAM_PORT 138 #define SMB_PORT 139 @@ -295,8 +300,8 @@ typedef struct typedef struct { uint16 ref_count; - int32 dev; - int32 inode; + uint32 dev; + uint32 inode; int fd; int fd_readonly; int fd_writeonly; @@ -320,7 +325,6 @@ typedef struct BOOL can_read; BOOL can_write; BOOL share_mode; - BOOL share_pending; BOOL print_file; BOOL modified; char *name; @@ -420,19 +424,40 @@ struct interface struct in_addr nmask; }; -/* share mode record in shared memory */ +/* share mode record pointed to in shared memory hash bucket */ typedef struct { - smb_shm_offset_t next_offset; /* offset of next record in list in shared mem */ + smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */ int locking_version; + int32 st_dev; + int32 st_ino; + int num_share_mode_entries; + smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */ + char file_name[1]; +} share_mode_record; + +/* share mode entry pointed to by share_mode_record struct */ +typedef struct +{ + smb_shm_offset_t next_share_mode_entry; + int pid; int share_mode; struct timeval time; +} share_mode_entry; + +/* struct returned by get_share_modes */ +typedef struct +{ int pid; - dev_t st_dev; - ino_t st_ino; - char file_name[1]; /* dynamically allocated with correct size */ -} share_mode_record; + int share_mode; + struct timeval time; +} min_share_mode_entry; + +/* Token returned by lock_share_entry (actually ignored by FAST_SHARE_MODES code) */ +typedef int share_lock_token; +/* Conversion to hash entry index from device and inode numbers. */ +#define HASH_ENTRY(dev,ino) ((( (uint32)(dev) )* ( (uint32)(ino) )) % lp_shmem_hash_size()) /* this is used for smbstatus */ struct connect_record @@ -798,12 +823,15 @@ char *Strstr(char *s, char *p); #define SV_TYPE_DOMAIN_ENUM 0x80000000 #define SV_TYPE_ALL 0xFFFFFFFF -/* What server type are we currently - JHT Says we ARE 4.20 */ +/* what server type are we currently - JHT Says we ARE 4.20 */ +/* this was set by JHT in liaison with Jeremy Allison early 1997 */ +/* setting to 4.20 at same time as announcing ourselves as NT Server */ /* History: */ /* Version 4.0 - never made public */ /* Version 4.10 - New to 1.9.16p2, lost in space 1.9.16p3 to 1.9.16p9 */ /* - Reappeared in 1.9.16p11 with fixed smbd services */ /* Version 4.20 - To indicate that nmbd and browsing now works better */ + #define MAJOR_VERSION 0x04 #define MINOR_VERSION 0x02 -- cgit