diff options
author | Jeremy Allison <jra@samba.org> | 2009-04-30 15:26:43 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-04-30 15:26:43 -0700 |
commit | 8cf78ff55312768d0b454b1d7e0560e04e6296da (patch) | |
tree | 0a2180f063e3bb9872c2565c92075dfb5dccac81 /source3/client | |
parent | ab4b8c9c0438bc5afca17e3ebf05dde6f98bc0aa (diff) | |
download | samba-8cf78ff55312768d0b454b1d7e0560e04e6296da.tar.gz samba-8cf78ff55312768d0b454b1d7e0560e04e6296da.tar.bz2 samba-8cf78ff55312768d0b454b1d7e0560e04e6296da.zip |
Get medieval on our ass about SMB1 file descriptors being 16 bits, not an int.
Convert all uses of cli_open(), cli_nt_createXXX to NTSTATUS versions.
This is smaller than it looks, it just fixes a lot of old code.
Next up, ensure all cli_XX functions return NTSTATUS.
Jeremy.
Diffstat (limited to 'source3/client')
-rw-r--r-- | source3/client/client.c | 38 | ||||
-rw-r--r-- | source3/client/clitar.c | 11 | ||||
-rw-r--r-- | source3/client/smbspool.c | 5 |
3 files changed, 27 insertions, 27 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 7dda981800..becb066153 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -535,12 +535,12 @@ static void display_finfo(file_info *finfo, const char *dir) dir_total += finfo->size; } else { char *afname = NULL; - int fnum; + uint16_t fnum; /* skip if this is . or .. */ if ( strequal(finfo->name,"..") || strequal(finfo->name,".") ) return; - /* create absolute filename for cli_nt_create() FIXME */ + /* create absolute filename for cli_ntcreate() FIXME */ afname = talloc_asprintf(ctx, "%s%s%s", dir, @@ -554,8 +554,9 @@ static void display_finfo(file_info *finfo, const char *dir) d_printf( "MODE:%s\n", attrib_string(finfo->mode)); d_printf( "SIZE:%.0f\n", (double)finfo->size); d_printf( "MTIME:%s", time_to_asc(t)); - fnum = cli_nt_create(finfo->cli, afname, CREATE_ACCESS_READ); - if (fnum == -1) { + if (!NT_STATUS_IS_OK(cli_ntcreate(finfo->cli, afname, 0, + CREATE_ACCESS_READ, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, 0x0, 0x0, &fnum))) { DEBUG( 0, ("display_finfo() Failed to open %s: %s\n", afname, cli_errstr( finfo->cli))); @@ -999,7 +1000,8 @@ static NTSTATUS writefile_sink(char *buf, size_t n, void *priv) static int do_get(const char *rname, const char *lname_in, bool reget) { TALLOC_CTX *ctx = talloc_tos(); - int handle = 0, fnum; + int handle = 0; + uint16_t fnum; bool newhandle = false; struct timeval tp_start; uint16 attr; @@ -1028,9 +1030,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget) GetTimeOfDay(&tp_start); - fnum = cli_open(targetcli, targetname, O_RDONLY, DENY_NONE); - - if (fnum == -1) { + if (!NT_STATUS_IS_OK(cli_open(targetcli, targetname, O_RDONLY, DENY_NONE, &fnum))) { d_printf("%s opening remote file %s\n",cli_errstr(cli),rname); return 1; } @@ -1618,7 +1618,7 @@ static int cmd_allinfo(void) static int do_put(const char *rname, const char *lname, bool reput) { TALLOC_CTX *ctx = talloc_tos(); - int fnum; + uint16_t fnum; XFILE *f; SMB_OFF_T start = 0; int rc = 0; @@ -1636,8 +1636,8 @@ static int do_put(const char *rname, const char *lname, bool reput) GetTimeOfDay(&tp_start); if (reput) { - fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE); - if (fnum >= 0) { + status = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum); + if (NT_STATUS_IS_OK(status)) { if (!cli_qfileinfo(targetcli, fnum, NULL, &start, NULL, NULL, NULL, NULL, NULL) && !cli_getattrE(targetcli, fnum, NULL, &start, NULL, NULL, NULL)) { d_printf("getattrib: %s\n",cli_errstr(cli)); @@ -1645,10 +1645,10 @@ static int do_put(const char *rname, const char *lname, bool reput) } } } else { - fnum = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE); + status = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum); } - if (fnum == -1) { + if (!NT_STATUS_IS_OK(status)) { d_printf("%s opening remote file %s\n",cli_errstr(targetcli),rname); return 1; } @@ -2207,7 +2207,7 @@ static int cmd_open(void) char *buf = NULL; char *targetname = NULL; struct cli_state *targetcli; - int fnum; + uint16_t fnum = (uint16_t)-1; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { d_printf("open <filename>\n"); @@ -2226,10 +2226,12 @@ static int cmd_open(void) return 1; } - fnum = cli_nt_create(targetcli, targetname, FILE_READ_DATA|FILE_WRITE_DATA); - if (fnum == -1) { - fnum = cli_nt_create(targetcli, targetname, FILE_READ_DATA); - if (fnum != -1) { + if (!NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetname, 0, + FILE_READ_DATA|FILE_WRITE_DATA, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) { + if (NT_STATUS_IS_OK(cli_ntcreate(targetcli, targetname, 0, + FILE_READ_DATA, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) { d_printf("open file %s: for read/write fnum %d\n", targetname, fnum); } else { d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli)); diff --git a/source3/client/clitar.c b/source3/client/clitar.c index fd375769e4..3cc1a25dbb 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -613,7 +613,7 @@ append one remote file to the tar file static void do_atar(const char *rname_in,char *lname,file_info *finfo1) { - int fnum = -1; + uint16_t fnum = (uint16_t)-1; uint64_t nread=0; char ftype; file_info2 finfo; @@ -660,9 +660,7 @@ static void do_atar(const char *rname_in,char *lname,file_info *finfo1) goto cleanup; } - fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE); - - if (fnum == -1) { + if (!NT_STATUS_IS_OK(cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum))) { DEBUG(0,("%s opening remote file %s (%s)\n", cli_errstr(cli),rname, client_get_cur_dir())); goto cleanup; @@ -998,13 +996,14 @@ static int skip_file(int skipsize) static int get_file(file_info2 finfo) { - int fnum = -1, pos = 0, dsize = 0, bpos = 0; + uint16_t fnum; + int pos = 0, dsize = 0, bpos = 0; uint64_t rsize = 0; DEBUG(5, ("get_file: file: %s, size %.0f\n", finfo.name, (double)finfo.size)); if (ensurepath(finfo.name) && - (fnum=cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == -1) { + (!NT_STATUS_IS_OK(cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE,&fnum)))) { DEBUG(0, ("abandoning restore\n")); return(False); } diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c index a276353a87..6b099dbc0b 100644 --- a/source3/client/smbspool.c +++ b/source3/client/smbspool.c @@ -553,7 +553,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */ char *title, /* I - Title/job name */ FILE * fp) { /* I - File to print */ - int fnum; /* File number */ + uint16_t fnum; /* File number */ int nbytes, /* Number of bytes read */ tbytes; /* Total bytes read */ char buffer[8192], /* Buffer for copy */ @@ -574,8 +574,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */ * Open the printer device... */ - fnum = cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); - if (fnum == -1) { + if (!NT_STATUS_IS_OK(cli_open(cli, title, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum))) { fprintf(stderr, "ERROR: %s opening remote spool %s\n", cli_errstr(cli), title); return (get_exit_code(cli, cli_nt_error(cli))); |