diff options
author | Andrew Tridgell <tridge@samba.org> | 1997-10-20 08:46:00 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1997-10-20 08:46:00 +0000 |
commit | 3e670e4057321911c6674b8abe3c0bdcd684fd09 (patch) | |
tree | 7cafae87caec23475f42da2a0961dd939ec5f905 /source3/include | |
parent | f4b4b3e6e35916dc5e280542f5f914e40b25dd21 (diff) | |
download | samba-3e670e4057321911c6674b8abe3c0bdcd684fd09.tar.gz samba-3e670e4057321911c6674b8abe3c0bdcd684fd09.tar.bz2 samba-3e670e4057321911c6674b8abe3c0bdcd684fd09.zip |
a major share modes reorganisation.
The shares modes code is now split into separate files. The shared
memory implementation is in locking_shm.c. The slow implementation is
in locking_slow.c
It is all controlled by a struct share_ops structure that has function
pointers to the implementation of all the functions needed by a share
modes implementation. An initialisation function sets up this
structure. This will make adding new implementations easy and clean.
This also allowed me to get rid of the ugly code in smbstatus. Now
status.c links to the locking code and calls methods in share_ops.
I also renamed some things and generally organised things in a much
cleaner fashion. Defines and structures specific to each
implementation have been moved to the appropriate file and out of
smb.h.
(This used to be commit 65ab9adaa0d356b8041ed8a507ea52117f2a284e)
Diffstat (limited to 'source3/include')
-rw-r--r-- | source3/include/proto.h | 39 | ||||
-rw-r--r-- | source3/include/smb.h | 69 |
2 files changed, 36 insertions, 72 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 224aaa5a79..024917a0d8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -305,22 +305,25 @@ int lp_minor_announce_version(void); BOOL is_locked(int fnum,int cnum,uint32 count,uint32 offset); BOOL do_lock(int fnum,int cnum,uint32 count,uint32 offset,int *eclass,uint32 *ecode); 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); -BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok); -BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token 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, uint16 port, uint16 op_type); -BOOL remove_share_oplock(int fnum, share_lock_token token); -BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok); -BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token 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, uint16 port, uint16 op_type); -BOOL remove_share_oplock(int fnum, share_lock_token token); +BOOL locking_init(void); +BOOL locking_end(void); +BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, int *ptok); +BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, int token); +int get_share_modes(int cnum, int token, uint32 dev, uint32 inode, + share_mode_entry **shares); +void del_share_mode(int token, int fnum); +BOOL set_share_mode(int token, int fnum, uint16 port, uint16 op_type); +BOOL remove_share_oplock(int fnum, int token); +int share_mode_forall(void (*fn)(share_mode_entry *, char *)); +void share_status(FILE *f); + +/*The following definitions come from locking_shm.c */ + +struct share_ops *locking_shm_init(void); + +/*The following definitions come from locking_slow.c */ + +struct share_ops *locking_slow_init(void); /*The following definitions come from lsaparse.c */ @@ -778,7 +781,7 @@ BOOL check_name(char *name,int cnum); void sync_file(int fnum); void close_file(int fnum, BOOL normal_close); BOOL check_file_sharing(int cnum,char *fname); -int check_share_mode( min_share_mode_entry *share, int deny_mode, char *fname, +int check_share_mode( share_mode_entry *share, int deny_mode, char *fname, BOOL fcbopen, int *flags); void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun, int mode,int oplock_request, int *Access,int *action); @@ -791,7 +794,7 @@ int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line); int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line); int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int line); BOOL oplock_break(uint32 dev, uint32 inode, struct timeval *tval); -BOOL request_oplock_break(min_share_mode_entry *share_entry, +BOOL request_oplock_break(share_mode_entry *share_entry, uint32 dev, uint32 inode); BOOL snum_used(int snum); BOOL reload_services(BOOL test); diff --git a/source3/include/smb.h b/source3/include/smb.h index 0d10bd5895..ff6cc7eb25 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1195,29 +1195,6 @@ struct interface struct in_addr nmask; }; -/* share mode record pointed to in shared memory hash bucket */ -typedef struct -{ - 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; - uint16 op_port; - uint16 op_type; - int share_mode; - struct timeval time; -} share_mode_entry; - /* struct returned by get_share_modes */ typedef struct { @@ -1226,14 +1203,26 @@ typedef struct uint16 op_type; int share_mode; struct timeval time; -} min_share_mode_entry; +} 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()) +/* each implementation of the share mode code needs + to support the following operations */ +struct share_ops { + BOOL (*stop_mgmt)(void); + BOOL (*lock_entry)(int , uint32 , uint32 , int *); + BOOL (*unlock_entry)(int , uint32 , uint32 , int ); + BOOL (*get_entries)(int , int , uint32 , uint32 , share_mode_entry **); + void (*del_entry)(int , int ); + BOOL (*set_entry)(int , int , uint16 , uint16 ); + BOOL (*remove_oplock)(int , int); + int (*forall)(void (*)(share_mode_entry *, char *)); + void (*status)(FILE *); +}; + /* this is used for smbstatus */ struct connect_record { @@ -1252,34 +1241,6 @@ struct connect_record #define LOCKING_VERSION 4 #endif /* LOCKING_VERSION */ -#if !defined(FAST_SHARE_MODES) -/* - * Defines for slow share modes. - */ - -/* - * Locking file header lengths & offsets. - */ -#define SMF_VERSION_OFFSET 0 -#define SMF_NUM_ENTRIES_OFFSET 4 -#define SMF_FILENAME_LEN_OFFSET 8 -#define SMF_HEADER_LENGTH 10 - -#define SMF_ENTRY_LENGTH 20 - -/* - * Share mode record offsets. - */ - -#define SME_SEC_OFFSET 0 -#define SME_USEC_OFFSET 4 -#define SME_SHAREMODE_OFFSET 8 -#define SME_PID_OFFSET 12 -#define SME_PORT_OFFSET 16 -#define SME_OPLOCK_TYPE_OFFSET 18 - -#endif /* FAST_SHARE_MODES */ - /* these are useful macros for checking validity of handles */ #define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES)) #define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open) |