diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-08-15 07:27:34 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-08-15 07:27:34 +0000 |
commit | 127655cc888ac40332d4e8e5b94aab03f5120aae (patch) | |
tree | 871cd3070589cbfbb9bc939125cd3b4d78923eef /source3/include | |
parent | 37d5ba8eae030ef852ca64181a5f8e5dbdc52079 (diff) | |
download | samba-127655cc888ac40332d4e8e5b94aab03f5120aae.tar.gz samba-127655cc888ac40332d4e8e5b94aab03f5120aae.tar.bz2 samba-127655cc888ac40332d4e8e5b94aab03f5120aae.zip |
this checkin gets rid of the global Files[] array and makes it local
in files.c
it should now be faily easy to expand the default MAX_OPEN_FILES to
many thousands.
(This used to be commit b088c804f98908eb02f05ab2f2e8a61691a0a582)
Diffstat (limited to 'source3/include')
-rw-r--r-- | source3/include/local.h | 15 | ||||
-rw-r--r-- | source3/include/proto.h | 49 | ||||
-rw-r--r-- | source3/include/smb.h | 37 |
3 files changed, 59 insertions, 42 deletions
diff --git a/source3/include/local.h b/source3/include/local.h index fb67babcda..af12f83551 100644 --- a/source3/include/local.h +++ b/source3/include/local.h @@ -29,6 +29,10 @@ /* to a maximum of 8 if old smb clients break because of long printer names. */ #define MAXPRINTERLEN 15 +/* max number of directories open at once */ +/* note that with the new directory code this no longer requires a + file handle per directory, but large numbers do use more memory */ +#define MAX_OPEN_DIRECTORIES 64 /* define what facility to use for syslog */ #ifndef SYSLOG_FACILITY @@ -40,18 +44,13 @@ MAX_CONNECTIONS services, but any number of machines may connect at one time. */ #define MAX_CONNECTIONS 127 -#define MAX_OPEN_FILES 100 - -/* max number of directories open at once */ -/* note that with the new directory code this no longer requires a - file handle per directory, but large numbers do use more memory */ -#define MAX_OPEN_DIRECTORIES 64 -#define MAX_FNUMS (MAX_OPEN_FILES+MAX_OPEN_DIRECTORIES) +/* this must be larger than the sum of the open files and directories */ +#define PIPE_HANDLE_OFFSET 0x7000 /* Default size of shared memory used for share mode locking */ #ifndef SHMEM_SIZE -#define SHMEM_SIZE (1024*(MAX_OPEN_FILES+MAX_OPEN_DIRECTORIES)) +#define SHMEM_SIZE (1024*1024) #endif /* the max number of simultanous connections to the server by all clients */ diff --git a/source3/include/proto.h b/source3/include/proto.h index 49d078b78a..9587828ea9 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -474,12 +474,12 @@ char *smb_errstr(char *inbuf); BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout, int lock_num); void process_blocking_lock_queue(time_t t); -BOOL is_locked(int fnum,connection_struct *conn, +BOOL is_locked(files_struct *fsp,connection_struct *conn, uint32 count,uint32 offset, int lock_type); -BOOL do_lock(int fnum,connection_struct *conn, +BOOL do_lock(files_struct *fsp,connection_struct *conn, uint32 count,uint32 offset,int lock_type, int *eclass,uint32 *ecode); -BOOL do_unlock(int fnum,connection_struct *conn, +BOOL do_unlock(files_struct *fsp,connection_struct *conn, uint32 count,uint32 offset,int *eclass,uint32 *ecode); BOOL locking_init(int read_only); BOOL locking_end(void); @@ -490,9 +490,9 @@ BOOL unlock_share_entry(connection_struct *conn, int get_share_modes(connection_struct *conn, 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); +void del_share_mode(int token, files_struct *fsp); +BOOL set_share_mode(int token, files_struct *fsp, uint16 port, uint16 op_type); +BOOL remove_share_oplock(files_struct *fsp, int token); int share_mode_forall(void (*fn)(share_mode_entry *, char *)); void share_status(FILE *f); @@ -1941,6 +1941,20 @@ void DirCacheAdd( char *path, char *name, char *dname, int snum ); char *DirCacheCheck( char *path, char *name, int snum ); void DirCacheFlush(int snum); +/*The following definitions come from smbd/files.c */ + +files_struct *find_free_file(void ); +file_fd_struct *fd_get_already_open(struct stat *sbuf); +file_fd_struct *fd_get_new(void); +void file_close_conn(connection_struct *conn); +void file_init(void); +files_struct *file_fsp(int fnum); +void file_close_user(int vuid); +files_struct *file_find_dit(int dev, int inode, struct timeval *tval); +files_struct *file_find_print(void); +void file_sync_all(connection_struct *conn); +void file_free(files_struct *fsp); + /*The following definitions come from smbd/groupname.c */ void load_groupname_map(void); @@ -1979,7 +1993,7 @@ int reply_ntcancel(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize); int reply_nttranss(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize); -void remove_pending_change_notify_requests_by_fid(int fnum); +void remove_pending_change_notify_requests_by_fid(files_struct *fsp); void remove_pending_change_notify_requests_by_mid(int mid); void process_pending_change_notify_queue(time_t t); int reply_nttrans(connection_struct *conn, @@ -2114,22 +2128,23 @@ int file_utime(connection_struct *conn, char *fname, struct utimbuf *times); BOOL set_filetime(connection_struct *conn, char *fname, time_t mtime); BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, BOOL *bad_path); BOOL check_name(char *name,connection_struct *conn); -void sync_file(connection_struct *conn, int fnum); -void close_file(int fnum, BOOL normal_close); -void close_directory(int fnum); -int open_directory(int fnum,connection_struct *conn, +void fd_add_to_uid_cache(file_fd_struct *fd_ptr, uid_t u); +void sync_file(connection_struct *conn, files_struct *fsp); +void close_file(files_struct *fsp, BOOL normal_close); +void close_directory(files_struct *fsp); +int open_directory(files_struct *fsp,connection_struct *conn, char *fname, int smb_ofun, int unixmode, int *action); BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op); int check_share_mode( share_mode_entry *share, int deny_mode, char *fname, BOOL fcbopen, int *flags); -void open_file_shared(int fnum,connection_struct *conn,char *fname,int share_mode,int ofun, +void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int share_mode,int ofun, int mode,int oplock_request, int *Access,int *action); -int seek_file(int fnum,uint32 pos); -int read_file(int fnum,char *data,uint32 pos,int n); -int write_file(int fnum,char *data,int n); +int seek_file(files_struct *fsp,uint32 pos); +int read_file(files_struct *fsp,char *data,uint32 pos,int n); +int write_file(files_struct *fsp,char *data,int n); BOOL become_service(connection_struct *conn,BOOL do_chdir); int find_service(char *service); -int cached_error_packet(char *inbuf,char *outbuf,int fnum,int line); +int cached_error_packet(char *inbuf,char *outbuf,files_struct *fsp,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); @@ -2139,7 +2154,7 @@ BOOL receive_next_smb(int smbfd, int oplockfd, char *inbuf, int bufsize, int tim BOOL snum_used(int snum); BOOL reload_services(BOOL test); connection_struct *make_connection(char *service,char *user,char *password, int pwlen, char *dev,uint16 vuid, int *ecode); -int find_free_file(void ); +BOOL attempt_close_oplocked_file(files_struct *fsp); int reply_corep(char *outbuf); int reply_coreplus(char *outbuf); int reply_lanman1(char *outbuf); diff --git a/source3/include/smb.h b/source3/include/smb.h index fa5d496ceb..801e134435 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -575,6 +575,7 @@ struct current_user typedef struct { + int fnum; connection_struct *conn; file_fd_struct *fd_ptr; int pos; @@ -599,6 +600,10 @@ typedef struct char *fsp_name; } files_struct; +/* this macro should always be used to extract an fnum (smb_fid) from + a packet to ensure chaining works correctly */ +#define GETFSP(buf,where) (chain_fsp?chain_fsp:file_fsp(SVAL(buf,where))) + /* Domain controller authentication protocol info */ struct dcinfo @@ -695,9 +700,9 @@ struct share_ops { BOOL (*lock_entry)(connection_struct *, uint32 , uint32 , int *); BOOL (*unlock_entry)(connection_struct *, uint32 , uint32 , int ); int (*get_entries)(connection_struct *, int , uint32 , uint32 , share_mode_entry **); - void (*del_entry)(int , int ); - BOOL (*set_entry)(int , int , uint16 , uint16 ); - BOOL (*remove_oplock)(int , int); + void (*del_entry)(int , files_struct *); + BOOL (*set_entry)(int, files_struct *, uint16 , uint16 ); + BOOL (*remove_oplock)(files_struct *, int); int (*forall)(void (*)(share_mode_entry *, char *)); void (*status)(FILE *); }; @@ -858,22 +863,21 @@ struct parm_struct #endif /* LOCKING_VERSION */ /* these are useful macros for checking validity of handles */ -#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_FNUMS)) -#define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open && !Files[fnum].is_directory) +#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory) #define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS)) -#define OPEN_CNUM(conn) ((conn) && (conn)->open) +#define OPEN_CONN(conn) ((conn) && (conn)->open) #define IS_IPC(conn) ((conn) && (conn)->ipc) #define IS_PRINT(conn) ((conn) && (conn)->printer) -#define FNUM_OK(fnum,c) (OPEN_FNUM(fnum) && (c)==Files[fnum].conn) +#define FNUM_OK(fsp,c) (OPEN_FSP(fsp) && (c)==(fsp)->conn) -#define CHECK_FNUM(fnum,conn) if (!FNUM_OK(fnum,conn)) \ +#define CHECK_FSP(fsp,conn) if (!FNUM_OK(fsp,conn)) \ return(ERROR(ERRDOS,ERRbadfid)) -#define CHECK_READ(fnum) if (!Files[fnum].can_read) \ +#define CHECK_READ(fsp) if (!(fsp)->can_read) \ return(ERROR(ERRDOS,ERRbadaccess)) -#define CHECK_WRITE(fnum) if (!Files[fnum].can_write) \ +#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \ return(ERROR(ERRDOS,ERRbadaccess)) -#define CHECK_ERROR(fnum) if (HAS_CACHED_ERROR(fnum)) \ - return(CACHED_ERROR(fnum)) +#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \ + return(CACHED_ERROR(fsp)) /* translates a connection number into a service number */ #define SNUM(conn) ((conn)?(conn)->service:-1) @@ -883,7 +887,7 @@ struct parm_struct #define PRINTCAP (lp_printcapname()) #define PRINTCOMMAND(snum) (lp_printcommand(snum)) #define PRINTERNAME(snum) (lp_printername(snum)) -#define CAN_WRITE(conn) (OPEN_CNUM(conn) && !conn->read_only) +#define CAN_WRITE(conn) (OPEN_CONN(conn) && !conn->read_only) #define VALID_SNUM(snum) (lp_snum_ok(snum)) #define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum)) #define GUEST_ONLY(snum) (VALID_SNUM(snum) && lp_guest_only(snum)) @@ -1432,11 +1436,10 @@ enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1}; #define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \ w->wr_discard = True, -1) /* Macro to test if an error has been cached for this fnum */ -#define HAS_CACHED_ERROR(fnum) (Files[(fnum)].open && \ - Files[(fnum)].wbmpx_ptr && \ - Files[(fnum)].wbmpx_ptr->wr_discard) +#define HAS_CACHED_ERROR(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \ + (fsp)->wbmpx_ptr->wr_discard) /* Macro to turn the cached error into an error packet */ -#define CACHED_ERROR(fnum) cached_error_packet(inbuf,outbuf,fnum,__LINE__) +#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__) /* these are the datagram types */ #define DGRAM_DIRECT_UNIQUE 0x10 |