fsp->open is no longer needed (if an fsp pointer is valid, then it's open :-).
NB for Luke, this patch also did not apply to TNG. TNG is not yet
identical w.r.t file serving with HEAD. This makes it impossible for
me to help maintain TNG. Please fix asap.
lib/substitute.c: Removed unused variable (pidstr).
Jeremy.
/*The following definitions come from lib/substitute.c */
+void standard_sub_basic(char *str);
void standard_sub_conn(connection_struct *conn, char *str);
void standard_sub_snum(int snum, char *str);
-void standard_sub_basic(char *str);
void standard_sub_vuser(char *str, user_struct *vuser);
void standard_sub_vsnum(char *str, user_struct *vuser, int snum);
char *myhostname(void);
char *lock_path(char *name);
char *parent_dirname(const char *path);
+int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6);
/*The following definitions come from lib/util_array.c */
/*The following definitions come from nmbd/nmbd_workgroupdb.c */
struct work_record *find_workgroup_on_subnet(struct subnet_record *subrec,
- fstring name);
+ const char *name);
struct work_record *create_workgroup_on_subnet(struct subnet_record *subrec,
fstring name, int ttl);
void update_workgroup_ttl(struct work_record *work, int ttl);
void sysv_printer_fn(void (*fn)(char *, char *));
int sysv_printername_ok(char *name);
+/*The following definitions come from printing/printfsp.c */
+
+files_struct *print_fsp_open(connection_struct *conn,char *jobname);
+void print_fsp_end(files_struct *fsp);
+
/*The following definitions come from printing/printing.c */
BOOL print_backend_init(void);
BOOL print_queue_pause(int snum);
BOOL print_queue_resume(int snum);
BOOL print_queue_purge(int snum);
-files_struct *print_fsp_open(connection_struct *conn,char *jobname);
-void print_fsp_end(files_struct *fsp);
/*The following definitions come from profile/profile.c */
void file_init(void);
void file_close_user(int vuid);
files_struct *file_find_dit(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval);
+files_struct *file_find_fsp(files_struct *orig_fsp);
files_struct *file_find_di_first(SMB_DEV_T dev, SMB_INO_T inode);
files_struct *file_find_di_next(files_struct *start_fsp);
files_struct *file_find_print(void);
int oplock_type;
int sent_oplock_break;
unsigned int num_posix_locks;
- BOOL open;
BOOL can_lock;
BOOL can_read;
BOOL can_write;
#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n))
/* these are useful macros for checking validity of handles */
-#define OPEN_FSP(fsp) ((fsp) && (fsp)->open && !(fsp)->is_directory)
+#define OPEN_FSP(fsp) ((fsp) && !(fsp)->is_directory)
#define OPEN_CONN(conn) ((conn) && (conn)->open)
#define IS_IPC(conn) ((conn) && (conn)->ipc)
#define IS_PRINT(conn) ((conn) && (conn)->printer)
#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(fsp) ((fsp)->open && (fsp)->wbmpx_ptr && \
+#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \
(fsp)->wbmpx_ptr->wr_discard)
/* Macro to turn the cached error into an error packet */
#define CACHED_ERROR(fsp) cached_error_packet(inbuf,outbuf,fsp,__LINE__)
static void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str)
{
char *p, *s, *home;
- fstring pidstr;
struct passwd *pass;
for (s=str; (p=strchr(s, '%'));s=p) {
fsp->vuid = current_user.vuid;
fsp->size = 0;
fsp->pos = -1;
- fsp->open = True;
fsp->can_lock = True;
fsp->can_read = False;
fsp->can_write = True;
flush_write_cache(fsp, CLOSE_FLUSH);
- fsp->open = False;
fsp->is_directory = False;
+ fsp->stat_open = False;
conn->num_files_open--;
if(fsp->wbmpx_ptr) {
for (fsp=Files;fsp;fsp=next) {
next = fsp->next;
- if (fsp->conn == conn && fsp->open) {
+ if (fsp->conn == conn) {
close_file(fsp,False);
}
}
for (fsp=Files;fsp;fsp=next) {
next=fsp->next;
- if ((fsp->vuid == vuid) && fsp->open) {
+ if (fsp->vuid == vuid) {
close_file(fsp,False);
}
}
files_struct *fsp;
for (fsp=Files;fsp;fsp=fsp->next,count++) {
- if (fsp->open &&
- fsp->fd != -1 &&
+ if (fsp->fd != -1 &&
fsp->dev == dev &&
fsp->inode == inode &&
(tval ? (fsp->open_time.tv_sec == tval->tv_sec) : True ) &&
return NULL;
}
+/****************************************************************************
+ Check if an fsp still exists.
+****************************************************************************/
+
+files_struct *file_find_fsp(files_struct *orig_fsp)
+{
+ files_struct *fsp;
+
+ for (fsp=Files;fsp;fsp=fsp->next) {
+ if (fsp == orig_fsp)
+ return fsp;
+ }
+
+ return NULL;
+}
+
/****************************************************************************
Find the first fsp given a device and inode.
****************************************************************************/
files_struct *fsp;
for (fsp=Files;fsp;fsp=fsp->next) {
- if (fsp->open &&
- fsp->fd != -1 &&
+ if ( fsp->fd != -1 &&
fsp->dev == dev &&
fsp->inode == inode )
return fsp;
files_struct *fsp;
for (fsp = start_fsp->next;fsp;fsp=fsp->next) {
- if (fsp->open &&
- fsp->fd != -1 &&
+ if ( fsp->fd != -1 &&
fsp->dev == start_fsp->dev &&
fsp->inode == start_fsp->inode )
return fsp;
files_struct *fsp;
for (fsp=Files;fsp;fsp=fsp->next) {
- if (fsp->open && fsp->print_file) return fsp;
+ if (fsp->print_file) return fsp;
}
return NULL;
for (fsp=Files;fsp;fsp=next) {
next=fsp->next;
- if (fsp->open && (conn == fsp->conn) && (fsp->fd != -1)) {
+ if ((conn == fsp->conn) && (fsp->fd != -1)) {
conn->vfs_ops.fsync(fsp->fd);
}
}
if(!fsp)
return(ERROR(ERRDOS,ERRbadfid));
- if((!fsp->open) || (!fsp->is_directory) || (conn != fsp->conn))
+ if((!fsp->is_directory) || (conn != fsp->conn))
return(ERROR(ERRDOS,ERRbadfid));
/*
int accmode = (flags & O_ACCMODE);
SMB_STRUCT_STAT sbuf;
- fsp->open = False;
- fsp->fd = 0;
+ fsp->fd = -1;
fsp->oplock_type = NO_OPLOCK;
errno = EPERM;
fsp->vuid = current_user.vuid;
fsp->size = 0;
fsp->pos = -1;
- fsp->open = True;
fsp->can_lock = True;
fsp->can_read = ((flags & O_WRONLY)==0);
fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
SMB_INO_T inode = 0;
int num_share_modes = 0;
BOOL all_current_opens_are_level_II = False;
+ BOOL fsp_open = False;
files_struct *fsp = NULL;
int open_mode=0;
uint16 port = 0;
if(!fsp)
return NULL;
- fsp->open = False;
fsp->fd = -1;
DEBUG(10,("open_file_shared: fname = %s, share_mode = %x, ofun = %x, mode = %o, oplock request = %d\n",
DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X mode=0%o\n",
flags,flags2,(int)mode));
- fsp->open = open_file(fsp,conn,fname,flags|(flags2&~(O_TRUNC)),mode);
+ fsp_open = open_file(fsp,conn,fname,flags|(flags2&~(O_TRUNC)),mode);
- if (!fsp->open && (flags == O_RDWR) && (errno != ENOENT) && fcbopen) {
- if((fsp->open = open_file(fsp,conn,fname,O_RDONLY,mode)) == True)
+ if (!fsp_open && (flags == O_RDWR) && (errno != ENOENT) && fcbopen) {
+ if((fsp_open = open_file(fsp,conn,fname,O_RDONLY,mode)) == True)
flags = O_RDONLY;
}
- if (!fsp->open) {
+ if (!fsp_open) {
if(file_existed)
unlock_share_entry(conn, dev, inode);
file_free(fsp);
fsp->vuid = current_user.vuid;
fsp->size = 0;
fsp->pos = -1;
- fsp->open = True;
fsp->can_lock = False;
fsp->can_read = False;
fsp->can_write = False;
fsp->vuid = current_user.vuid;
fsp->size = 0;
fsp->pos = -1;
- fsp->open = True;
fsp->can_lock = True;
fsp->can_read = False;
fsp->can_write = False;
DEBUG(5,("attempt_close_oplocked_file: checking file %s.\n", fsp->fsp_name));
- if (fsp->open && EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !fsp->sent_oplock_break && (fsp->fd != -1)) {
+ if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !fsp->sent_oplock_break && (fsp->fd != -1)) {
/* Try and break the oplock. */
if (oplock_break(fsp->dev, fsp->inode, &fsp->open_time, True)) {
- if(!fsp->open) /* Did the oplock break close the file ? */
+ if(file_find_fsp(fsp) == NULL) /* Did the oplock break close the file ? */
return True;
}
}
* We can only use CHECK_FSP if we know it's not a directory.
*/
- if(!fsp || !fsp->open || (fsp->conn != conn))
+ if(!fsp || (fsp->conn != conn))
return(ERROR(ERRDOS,ERRbadfid));
if(HAS_CACHED_ERROR(fsp)) {
DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QFILEINFO: level = %d\n", info_level));
- if(fsp && fsp->open && (fsp->is_directory || fsp->stat_open)) {
+ if(fsp && (fsp->is_directory || fsp->stat_open)) {
/*
* This is actually a QFILEINFO on a directory
* handle (returned from an NT SMB). NT5.0 seems
fsp = file_fsp(params,0);
info_level = SVAL(params,2);
- if(fsp && fsp->open && (fsp->is_directory || fsp->stat_open)) {
+ if(fsp && (fsp->is_directory || fsp->stat_open)) {
/*
* This is actually a SETFILEINFO on a directory
* handle (returned from an NT SMB). NT5.0 seems