diff options
author | Simo Sorce <idra@samba.org> | 2010-04-23 14:26:33 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2010-04-23 14:26:33 -0700 |
commit | 168b86c3847a5b575eef36cc2308802cbd25bb4a (patch) | |
tree | 28546e3b7bb429a06bfbba51b3cbcefe2b59be33 /source3 | |
parent | 2bbb8c917e372ceeb1e144259d9d2b0eab7cc212 (diff) | |
download | samba-168b86c3847a5b575eef36cc2308802cbd25bb4a.tar.gz samba-168b86c3847a5b575eef36cc2308802cbd25bb4a.tar.bz2 samba-168b86c3847a5b575eef36cc2308802cbd25bb4a.zip |
s3-smbd: group print relate data in own structure
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/smb.h | 10 | ||||
-rw-r--r-- | source3/modules/onefs_open.c | 4 | ||||
-rw-r--r-- | source3/printing/printfsp.c | 24 | ||||
-rw-r--r-- | source3/smbd/fileio.c | 7 | ||||
-rw-r--r-- | source3/smbd/files.c | 10 | ||||
-rw-r--r-- | source3/smbd/open.c | 4 | ||||
-rw-r--r-- | source3/smbd/reply.c | 7 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 7 |
8 files changed, 52 insertions, 21 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h index 19e45edf70..780d79acb3 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -411,13 +411,16 @@ struct notify_change_buf { struct notify_change_request *requests; }; +struct print_file_data { + uint16 rap_jobid; +}; + typedef struct files_struct { struct files_struct *next, *prev; int fnum; struct connection_struct *conn; struct fd_handle *fh; unsigned int num_smb_operations; - uint16 rap_print_jobid; struct file_id file_id; uint64_t initial_allocation_size; /* Faked up initial allocation on disk. */ mode_t mode; @@ -446,7 +449,6 @@ typedef struct files_struct { bool can_lock; bool can_read; bool can_write; - bool print_file; bool modified; bool is_directory; bool aio_write_behind; @@ -472,6 +474,10 @@ typedef struct files_struct { struct byte_range_lock *brlock_rec; struct dptr_struct *dptr; + + /* if not NULL, means this is a print file */ + struct print_file_data *print_file; + } files_struct; #include "ntquotas.h" diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c index e97fe9e38a..dd4c24555f 100644 --- a/source3/modules/onefs_open.c +++ b/source3/modules/onefs_open.c @@ -313,7 +313,7 @@ static NTSTATUS onefs_open_file(files_struct *fsp, fsp->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ? True : False; } - fsp->print_file = False; + fsp->print_file = NULL; fsp->modified = False; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = False; @@ -1627,7 +1627,7 @@ static NTSTATUS onefs_open_directory(connection_struct *conn, * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted, */ fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES; - fsp->print_file = False; + fsp->print_file = NULL; fsp->modified = False; fsp->oplock_type = NO_OPLOCK; fsp->sent_oplock_break = NO_BREAK_SENT; diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c index 5382b734f3..e8907488c4 100644 --- a/source3/printing/printfsp.c +++ b/source3/printing/printfsp.c @@ -29,6 +29,7 @@ NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn, const char *fname, uint16_t current_vuid, files_struct *fsp) { + const char *svcname = lp_const_servicename(SNUM(conn)); int jobid; fstring name; NTSTATUS status; @@ -49,23 +50,29 @@ NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn, return status; } + fsp->print_file = talloc(fsp, struct print_file_data); + if (!fsp->print_file) { + status = map_nt_error_from_unix(ENOMEM); + return status; + } + /* Convert to RAP id. */ - fsp->rap_print_jobid = pjobid_to_rap(lp_const_servicename(SNUM(conn)), jobid); - if (fsp->rap_print_jobid == 0) { + fsp->print_file->rap_jobid = pjobid_to_rap(svcname, jobid); + if (fsp->print_file->rap_jobid == 0) { /* We need to delete the entry in the tdb. */ - pjob_delete(lp_const_servicename(SNUM(conn)), jobid); + pjob_delete(svcname, jobid); return NT_STATUS_ACCESS_DENIED; /* No errno around here */ } status = create_synthetic_smb_fname(fsp, - print_job_fname(lp_const_servicename(SNUM(conn)), jobid), NULL, + print_job_fname(svcname, jobid), NULL, NULL, &fsp->fsp_name); if (!NT_STATUS_IS_OK(status)) { - pjob_delete(lp_const_servicename(SNUM(conn)), jobid); + pjob_delete(svcname, jobid); return status; } /* setup a full fsp */ - fsp->fh->fd = print_job_fd(lp_const_servicename(SNUM(conn)),jobid); + fsp->fh->fd = print_job_fd(svcname, jobid); GetTimeOfDay(&fsp->open_time); fsp->vuid = current_vuid; fsp->fh->pos = -1; @@ -73,7 +80,6 @@ NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn, fsp->can_read = False; fsp->access_mask = FILE_GENERIC_WRITE; fsp->can_write = True; - fsp->print_file = True; fsp->modified = False; fsp->oplock_type = NO_OPLOCK; fsp->sent_oplock_break = NO_BREAK_SENT; @@ -106,9 +112,9 @@ void print_fsp_end(files_struct *fsp, enum file_close_type close_type) TALLOC_FREE(fsp->fsp_name); } - if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) { + if (!rap_to_pjobid(fsp->print_file->rap_jobid, NULL, &jobid)) { DEBUG(3,("print_fsp_end: Unable to convert RAP jobid %u to print jobid.\n", - (unsigned int)fsp->rap_print_jobid )); + (unsigned int)fsp->print_file->rap_jobid )); return; } diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 1c27fef09b..da72e5a5f0 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -293,9 +293,10 @@ ssize_t write_file(struct smb_request *req, if (fsp->print_file) { uint32 jobid; - if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) { - DEBUG(3,("write_file: Unable to map RAP jobid %u to jobid.\n", - (unsigned int)fsp->rap_print_jobid )); + if (!rap_to_pjobid(fsp->print_file->rap_jobid, NULL, &jobid)) { + DEBUG(3, ("write_file: " + "Unable to map RAP jobid %u to jobid.\n", + (unsigned int)fsp->print_file->rap_jobid)); errno = EBADF; return -1; } diff --git a/source3/smbd/files.c b/source3/smbd/files.c index a2a7dabea5..43956e3903 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -589,10 +589,18 @@ NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from, } else { to->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ? True : False; } - to->print_file = from->print_file; to->modified = from->modified; to->is_directory = from->is_directory; to->aio_write_behind = from->aio_write_behind; + + if (from->print_file) { + to->print_file = talloc(to, struct print_file_data); + if (!to->print_file) return NT_STATUS_NO_MEMORY; + to->print_file->rap_jobid = from->print_file->rap_jobid; + } else { + to->print_file = NULL; + } + return fsp_set_smb_fname(to, from->fsp_name); } diff --git a/source3/smbd/open.c b/source3/smbd/open.c index f49aca8429..19bd0c2d97 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -615,7 +615,7 @@ static NTSTATUS open_file(files_struct *fsp, fsp->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ? True : False; } - fsp->print_file = False; + fsp->print_file = NULL; fsp->modified = False; fsp->sent_oplock_break = NO_BREAK_SENT; fsp->is_directory = False; @@ -2620,7 +2620,7 @@ static NTSTATUS open_directory(connection_struct *conn, * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted, */ fsp->access_mask = access_mask | FILE_READ_ATTRIBUTES; - fsp->print_file = False; + fsp->print_file = NULL; fsp->modified = False; fsp->oplock_type = NO_OPLOCK; fsp->sent_oplock_break = NO_BREAK_SENT; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 0355cb7083..56c067f4dc 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -924,7 +924,12 @@ void reply_ioctl(struct smb_request *req) END_PROFILE(SMBioctl); return; } - SSVAL(p,0,fsp->rap_print_jobid); /* Job number */ + /* Job number */ + if (fsp->print_file) { + SSVAL(p, 0, fsp->print_file->rap_jobid); + } else { + SSVAL(p, 0, 0); + } srvstr_push((char *)req->outbuf, req->flags2, p+2, global_myname(), 15, STR_TERMINATE|STR_ASCII); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 991b6058e0..4dff67347b 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -8150,7 +8150,12 @@ static void call_trans2ioctl(connection_struct *conn, /* NOTE - THIS IS ASCII ONLY AT THE MOMENT - NOT SURE IF OS/2 CAN ACCEPT THIS IN UNICODE. JRA. */ - SSVAL(pdata,0,fsp->rap_print_jobid); /* Job number */ + /* Job number */ + if (fsp->print_file) { + SSVAL(pdata, 0, fsp->print_file->rap_jobid); + } else { + SSVAL(pdata, 0, 0); + } srvstr_push(pdata, req->flags2, pdata + 2, global_myname(), 15, STR_ASCII|STR_TERMINATE); /* Our NetBIOS name */ |