summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-09-03 18:40:31 +0000
committerJeremy Allison <jra@samba.org>1998-09-03 18:40:31 +0000
commit7bb86c1b132bce31a006ea9768a54db7a45fe1a5 (patch)
tree1802e8e2741345e91187fc4b149016af75990971 /source3/smbd
parent4acd373e5bbd615141ceb5fb3c4a588a5b4581d7 (diff)
downloadsamba-7bb86c1b132bce31a006ea9768a54db7a45fe1a5.tar.gz
samba-7bb86c1b132bce31a006ea9768a54db7a45fe1a5.tar.bz2
samba-7bb86c1b132bce31a006ea9768a54db7a45fe1a5.zip
Ok - this is the 64 bit widening check in. It changes the configure
to check for stat64 and friends, and then changes much of Samba to use the data type SMB_OFF_T for file size information. stat/fstat/lstat/lseek/ftruncate have now become sys_stat etc. to hide the 64 bit calls if needed. Note that this still does not expose 64 bit functionality to the client, as the changes to the reply_xxx smb's are not yet done. This code change should make these changes possible. Still to do before full 64 bit-ness to the client: fcntl lock code. statfs code widening of dev_t and ino_t (now possible due to SMB_DEV_T and SMB_OFF_T types being in place). Let me know if wierd things happen after this check-in and I'll fix them :-). Jeremy. (This used to be commit 14500936c321d15995c963766aac67bf1f4e3824)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/connection.c8
-rw-r--r--source3/smbd/dir.c3
-rw-r--r--source3/smbd/fileio.c8
-rw-r--r--source3/smbd/groupname.c2
-rw-r--r--source3/smbd/nttrans.c12
-rw-r--r--source3/smbd/open.c4
-rw-r--r--source3/smbd/predict.c10
-rw-r--r--source3/smbd/quotas.c32
-rw-r--r--source3/smbd/reply.c54
-rw-r--r--source3/smbd/trans2.c201
10 files changed, 172 insertions, 162 deletions
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index 342a5f43bc..c3b6ba0199 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -88,7 +88,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
bzero((void *)&crec,sizeof(crec));
/* remove our mark */
- if (lseek(fd,i*sizeof(crec),SEEK_SET) != i*sizeof(crec) ||
+ if (sys_lseek(fd,i*sizeof(crec),SEEK_SET) != i*sizeof(crec) ||
write(fd, &crec,sizeof(crec)) != sizeof(crec)) {
DEBUG(2,("Couldn't update lock file %s (%s)\n",fname,strerror(errno)));
if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
@@ -159,14 +159,14 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
/* find a free spot */
for (i=0;i<max_connections;i++) {
if (i>=total_recs ||
- lseek(fd,i*sizeof(crec),SEEK_SET) != i*sizeof(crec) ||
+ sys_lseek(fd,i*sizeof(crec),SEEK_SET) != i*sizeof(crec) ||
read(fd,&crec,sizeof(crec)) != sizeof(crec)) {
if (foundi < 0) foundi = i;
break;
}
if (Clear && crec.pid && !process_exists(crec.pid)) {
- lseek(fd,i*sizeof(crec),SEEK_SET);
+ sys_lseek(fd,i*sizeof(crec),SEEK_SET);
bzero((void *)&crec,sizeof(crec));
write(fd, &crec,sizeof(crec));
if (foundi < 0) foundi = i;
@@ -206,7 +206,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
StrnCpy(crec.addr,client_addr(Client),sizeof(crec.addr)-1);
/* make our mark */
- if (lseek(fd,foundi*sizeof(crec),SEEK_SET) != foundi*sizeof(crec) ||
+ if (sys_lseek(fd,foundi*sizeof(crec),SEEK_SET) != foundi*sizeof(crec) ||
write(fd, &crec,sizeof(crec)) != sizeof(crec)) {
if (fcntl_lock(fd,F_SETLKW,0,1,F_UNLCK)==False) {
DEBUG(0,("ERROR: can't release lock on %s\n", fname));
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 7c81b826d1..73db295548 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -418,7 +418,8 @@ BOOL dir_check_ftype(connection_struct *conn,int mode,SMB_STRUCT_STAT *st,int di
/****************************************************************************
get a directory entry
****************************************************************************/
-BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,int *size,int *mode,time_t *date,BOOL check_descend)
+BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype,char *fname,
+ SMB_OFF_T *size,int *mode,time_t *date,BOOL check_descend)
{
char *dname;
BOOL found = False;
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 047c84f35f..6d6edf9d37 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -27,14 +27,14 @@ extern int DEBUGLEVEL;
/****************************************************************************
seek a file. Try to avoid the seek if possible
****************************************************************************/
-int seek_file(files_struct *fsp,uint32 pos)
+SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos)
{
- uint32 offset = 0;
+ SMB_OFF_T offset = 0;
if (fsp->print_file && lp_postscript(fsp->conn->service))
offset = 3;
- fsp->pos = (int)(lseek(fsp->fd_ptr->fd,pos+offset,SEEK_SET) - offset);
+ fsp->pos = (sys_lseek(fsp->fd_ptr->fd,pos+offset,SEEK_SET) - offset);
return(fsp->pos);
}
@@ -104,7 +104,7 @@ int write_file(files_struct *fsp,char *data,int n)
if (!fsp->modified) {
SMB_STRUCT_STAT st;
fsp->modified = True;
- if (fstat(fsp->fd_ptr->fd,&st) == 0) {
+ if (sys_fstat(fsp->fd_ptr->fd,&st) == 0) {
int dosmode = dos_mode(fsp->conn,fsp->fsp_name,&st);
if (MAP_ARCHIVE(fsp->conn) && !IS_DOS_ARCHIVE(dosmode)) {
file_chmod(fsp->conn,fsp->fsp_name,dosmode | aARCH,&st);
diff --git a/source3/smbd/groupname.c b/source3/smbd/groupname.c
index 6616d0d157..75af12a47a 100644
--- a/source3/smbd/groupname.c
+++ b/source3/smbd/groupname.c
@@ -82,7 +82,7 @@ void load_groupname_map(void)
if (!*groupname_map_file)
return;
- if(stat(groupname_map_file, &st) != 0) {
+ if(sys_stat(groupname_map_file, &st) != 0) {
DEBUG(0, ("load_groupname_map: Unable to stat file %s. Error was %s\n",
groupname_map_file, strerror(errno) ));
return;
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 9e507aa4d2..3fdee043dc 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -415,7 +415,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
int oplock_request = 0;
int unixmode, pnum = -1;
int fmode=0,mtime=0,rmode=0;
- off_t file_len = 0;
+ SMB_OFF_T file_len = 0;
SMB_STRUCT_STAT sbuf;
int smb_action = 0;
BOOL bad_path = False;
@@ -602,7 +602,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
return(ERROR(ERRDOS,ERRnoaccess));
}
} else {
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fsp,False);
restore_case_semantics(file_attributes);
return(ERROR(ERRDOS,ERRnoaccess));
@@ -660,12 +660,12 @@ int reply_ntcreate_and_X(connection_struct *conn,
p += 8;
SIVAL(p,0,fmode); /* File Attributes. */
p += 12;
-#if OFF_T_IS_64_BITS
+#ifdef LARGE_SMB_OFF_T
SIVAL(p,0, file_len & 0xFFFFFFFF);
SIVAL(p,4, file_len >> 32);
-#else /* OFF_T_IS_64_BITS */
+#else /* LARGE_SMB_OFF_T */
SIVAL(p,0,file_len);
-#endif /* OFF_T_IS_64_BITS */
+#endif /* LARGE_SMB_OFF_T */
p += 12;
SCVAL(p,0,fsp->is_directory ? 1 : 0);
@@ -809,7 +809,7 @@ static int call_nt_transact_create(connection_struct *conn,
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fsp,False);
restore_case_semantics(file_attributes);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 76e88c2e85..395de66a88 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -472,7 +472,7 @@ static void open_file(files_struct *fsp,connection_struct *conn,
{
if(sbuf == 0) {
/* Do the fstat */
- if(fstat(fd_ptr->fd, &statbuf) == -1) {
+ if(sys_fstat(fd_ptr->fd, &statbuf) == -1) {
/* Error - backout !! */
DEBUG(3,("Error doing fstat on fd %d, file %s (%s)\n",
fd_ptr->fd, fname,strerror(errno)));
@@ -576,7 +576,7 @@ static void truncate_unless_locked(files_struct *fsp, connection_struct *conn, i
unix_ERR_code = ERRlock;
}
else
- ftruncate(fsp->fd_ptr->fd,0);
+ sys_ftruncate(fsp->fd_ptr->fd,0);
}
}
diff --git a/source3/smbd/predict.c b/source3/smbd/predict.c
index 6e423c8eff..0deda0c0b6 100644
--- a/source3/smbd/predict.c
+++ b/source3/smbd/predict.c
@@ -27,11 +27,11 @@ extern int DEBUGLEVEL;
/* variables used by the read prediction module */
static int rp_fd = -1;
-static int rp_offset = 0;
+static SMB_OFF_T rp_offset = 0;
static int rp_length = 0;
static int rp_alloced = 0;
static int rp_predict_fd = -1;
-static int rp_predict_offset = 0;
+static SMB_OFF_T rp_predict_offset = 0;
static int rp_predict_length = 0;
static int rp_timeout = 5;
static time_t rp_time = 0;
@@ -42,7 +42,7 @@ extern time_t smb_last_time;
/****************************************************************************
handle read prediction on a file
****************************************************************************/
-int read_predict(int fd,int offset,char *buf,char **ptr,int num)
+int read_predict(int fd,SMB_OFF_T offset,char *buf,char **ptr,int num)
{
int ret = 0;
int possible = rp_length - (offset - rp_offset);
@@ -70,7 +70,7 @@ int read_predict(int fd,int offset,char *buf,char **ptr,int num)
/* Find the end of the file - ensure we don't
read predict beyond it. */
- if(fstat(fd,&rp_stat) < 0)
+ if(sys_fstat(fd,&rp_stat) < 0)
{
DEBUG(0,("read-prediction failed on fstat. Error was %s\n", strerror(errno)));
predict_skip = True;
@@ -134,7 +134,7 @@ void do_read_prediction(void)
}
}
- if (lseek(rp_fd,rp_offset,SEEK_SET) != rp_offset) {
+ if (sys_lseek(rp_fd,rp_offset,SEEK_SET) != rp_offset) {
rp_fd = -1;
rp_predict_fd = -1;
return;
diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c
index 7f1cd5ce79..b7a538e189 100644
--- a/source3/smbd/quotas.c
+++ b/source3/smbd/quotas.c
@@ -54,12 +54,12 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
SMB_STRUCT_STAT S;
FILE *fp;
struct mntent *mnt;
- int devno;
+ SMB_DEV_T devno;
int found;
/* find the block device file */
- if ( stat(path, &S) == -1 ) {
+ if ( sys_stat(path, &S) == -1 ) {
return(False) ;
}
@@ -69,7 +69,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
found = False ;
while ((mnt = getmntent(fp))) {
- if ( stat(mnt->mnt_dir,&S) == -1 )
+ if ( sys_stat(mnt->mnt_dir,&S) == -1 )
continue ;
if (S.st_dev == devno) {
found = True ;
@@ -136,15 +136,15 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
struct mntent *mnt;
FILE *fd;
SMB_STRUCT_STAT sbuf;
- dev_t devno ;
- static dev_t devno_cached = 0 ;
+ SMB_DEV_T devno ;
+ static SMB_DEV_T devno_cached = 0 ;
static pstring name;
struct q_request request ;
struct qf_header header ;
static int quota_default = 0 ;
int found ;
- if ( stat(path,&sbuf) == -1 )
+ if ( sys_stat(path,&sbuf) == -1 )
return(False) ;
devno = sbuf.st_dev ;
@@ -160,7 +160,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
while ((mnt = getmntent(fd)) != NULL) {
- if ( stat(mnt->mnt_dir,&sbuf) == -1 )
+ if ( sys_stat(mnt->mnt_dir,&sbuf) == -1 )
continue ;
if (sbuf.st_dev == devno) {
@@ -256,11 +256,11 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
#endif
FILE *fd;
SMB_STRUCT_STAT sbuf;
- dev_t devno ;
- static dev_t devno_cached = 0 ;
+ SMB_DEV_T devno ;
+ static SMB_DEV_T devno_cached = 0 ;
int found ;
- if ( stat(path,&sbuf) == -1 )
+ if ( sys_stat(path,&sbuf) == -1 )
return(False) ;
devno = sbuf.st_dev ;
@@ -273,7 +273,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
found = False ;
while (getmntent(fd, &mnt) == 0) {
- if ( stat(mnt.mnt_mountp,&sbuf) == -1 )
+ if ( sys_stat(mnt.mnt_mountp,&sbuf) == -1 )
continue ;
DEBUG(5,("disk_quotas: testing \"%s\" devno=%o\n",
mnt.mnt_mountp,sbuf.st_dev));
@@ -292,7 +292,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
found = False ;
while ((mnt = getmntent(fd)) != NULL) {
- if ( stat(mnt->mnt_dir,&sbuf) == -1 )
+ if ( sys_stat(mnt->mnt_dir,&sbuf) == -1 )
continue ;
DEBUG(5,("disk_quotas: testing \"%s\" devno=%o\n",
mnt->mnt_dir,sbuf.st_dev));
@@ -436,12 +436,12 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
SMB_STRUCT_STAT S;
FILE *fp;
struct mntent *mnt;
- int devno;
+ SMB_DEV_T devno;
int found;
/* find the block device file */
- if ( stat(path, &S) == -1 ) {
+ if ( sys_stat(path, &S) == -1 ) {
return(False) ;
}
@@ -451,7 +451,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
found = False ;
while ((mnt = getmntent(fp))) {
- if ( stat(mnt->mnt_dir,&S) == -1 )
+ if ( sys_stat(mnt->mnt_dir,&S) == -1 )
continue ;
if (S.st_dev == devno) {
found = True ;
@@ -575,7 +575,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
char dev_disk[256];
SMB_STRUCT_STAT S;
/* find the block device file */
- if ((stat(path, &S)<0) ||
+ if ((sys_stat(path, &S)<0) ||
(devnm(S_IFBLK, S.st_dev, dev_disk, 256, 0)<0)) return (False);
#endif
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index a3164bd67d..3665518ae6 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -809,7 +809,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
SMB_STRUCT_STAT sbuf;
BOOL ok = False;
int mode=0;
- uint32 size=0;
+ SMB_OFF_T size=0;
time_t mtime=0;
BOOL bad_path = False;
@@ -860,7 +860,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
put_dos_date3(outbuf,smb_vwv1,mtime & ~1);
else
put_dos_date3(outbuf,smb_vwv1,mtime);
- SIVAL(outbuf,smb_vwv3,size);
+ SIVAL(outbuf,smb_vwv3,(uint32)size);
if (Protocol >= PROTOCOL_NT1) {
char *p = strrchr(fname,'/');
@@ -870,7 +870,7 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
SSVAL(outbuf,smb_flg2,flg2 | 0x40); /* IS_LONG_NAME */
}
- DEBUG( 3, ( "getatr name=%s mode=%d size=%d\n", fname, mode, size ) );
+ DEBUG( 3, ( "getatr name=%s mode=%d size=%d\n", fname, mode, (uint32)size ) );
return(outsize);
}
@@ -953,7 +953,8 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
pstring mask;
pstring directory;
pstring fname;
- int size,mode;
+ SMB_OFF_T size;
+ int mode;
time_t date;
int dirtype;
int outsize = 0;
@@ -1244,7 +1245,7 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
int outsize = 0;
int fmode=0;
int share_mode;
- int size = 0;
+ SMB_OFF_T size = 0;
time_t mtime=0;
int unixmode;
int rmode=0;
@@ -1289,7 +1290,7 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fsp,False);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1311,7 +1312,7 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
put_dos_date3(outbuf,smb_vwv2,mtime & ~1);
else
put_dos_date3(outbuf,smb_vwv2,mtime);
- SIVAL(outbuf,smb_vwv4,size);
+ SIVAL(outbuf,smb_vwv4,(uint32)size);
SSVAL(outbuf,smb_vwv6,rmode);
if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
@@ -1344,7 +1345,8 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
#endif
int smb_ofun = SVAL(inbuf,smb_vwv8);
int unixmode;
- int size=0,fmode=0,mtime=0,rmode=0;
+ SMB_OFF_T size=0;
+ int fmode=0,mtime=0,rmode=0;
SMB_STRUCT_STAT sbuf;
int smb_action = 0;
BOOL bad_path = False;
@@ -1390,7 +1392,7 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fsp,False);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1436,7 +1438,7 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
put_dos_date3(outbuf,smb_vwv4,mtime & ~1);
else
put_dos_date3(outbuf,smb_vwv4,mtime);
- SIVAL(outbuf,smb_vwv6,size);
+ SIVAL(outbuf,smb_vwv6,(uint32)size);
SSVAL(outbuf,smb_vwv8,rmode);
SSVAL(outbuf,smb_vwv11,smb_action);
@@ -1767,7 +1769,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
int nread = 0;
uint32 startpos;
char *header = outbuf;
- int ret=0;
+ SMB_OFF_T ret=0;
int fd;
char *fname;
files_struct *fsp;
@@ -1781,7 +1783,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if(global_oplock_break)
{
_smb_setlen(header,0);
- transfer_file(0,Client,0,header,4,0);
+ transfer_file(0,Client,(SMB_OFF_T)0,header,4,0);
DEBUG(5,("readbraw - oplock break finished\n"));
return -1;
}
@@ -1799,7 +1801,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if (!FNUM_OK(fsp,conn) || !fsp->can_read) {
DEBUG(3,("fnum %d not open in readbraw - cache prime?\n",fsp->fnum));
_smb_setlen(header,0);
- transfer_file(0,Client,0,header,4,0);
+ transfer_file(0,Client,(SMB_OFF_T)0,header,4,0);
return(-1);
} else {
fd = fsp->fd_ptr->fd;
@@ -1809,12 +1811,12 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if (!is_locked(fsp,conn,maxcount,startpos, F_RDLCK))
{
- int size = fsp->size;
+ SMB_OFF_T size = fsp->size;
int sizeneeded = startpos + maxcount;
if (size < sizeneeded) {
SMB_STRUCT_STAT st;
- if (fstat(fsp->fd_ptr->fd,&st) == 0)
+ if (sys_fstat(fsp->fd_ptr->fd,&st) == 0)
size = st.st_size;
if (!fsp->can_write)
fsp->size = size;
@@ -1843,7 +1845,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if ((nread-predict) > 0)
seek_file(fsp,startpos + predict);
- ret = transfer_file(fd,Client,nread-predict,header,4+predict,
+ ret = transfer_file(fd,Client,(SMB_OFF_T)(nread-predict),header,4+predict,
startpos+predict);
}
@@ -2081,7 +2083,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
tcount,nwritten,numtowrite));
}
- nwritten = transfer_file(Client,fsp->fd_ptr->fd,numtowrite,NULL,0,
+ nwritten = transfer_file(Client,fsp->fd_ptr->fd,(SMB_OFF_T)numtowrite,NULL,0,
startpos+nwritten);
total_written += nwritten;
@@ -2193,7 +2195,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int dum_size,i
zero then the file size should be extended or
truncated to the size given in smb_vwv[2-3] */
if(numtowrite == 0)
- nwritten = set_filelen(fsp->fd_ptr->fd, startpos);
+ nwritten = set_filelen(fsp->fd_ptr->fd, (SMB_OFF_T)startpos);
else
nwritten = write_file(fsp,data,numtowrite);
@@ -2280,7 +2282,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
uint32 startpos;
- int32 res= -1;
+ SMB_OFF_T res= -1;
int mode,umode;
int outsize = 0;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@@ -2292,19 +2294,19 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
startpos = IVAL(inbuf,smb_vwv2);
switch (mode & 3)
- {
+ {
case 0: umode = SEEK_SET; break;
case 1: umode = SEEK_CUR; break;
case 2: umode = SEEK_END; break;
default:
umode = SEEK_SET; break;
- }
+ }
- res = lseek(fsp->fd_ptr->fd,startpos,umode);
+ res = sys_lseek(fsp->fd_ptr->fd,(SMB_OFF_T)startpos,umode);
fsp->pos = res;
outsize = set_message(outbuf,2,0,True);
- SIVALS(outbuf,smb_vwv0,res);
+ SIVALS(outbuf,smb_vwv0,(uint32)res);
DEBUG(3,("lseek fnum=%d ofs=%d mode=%d\n",
fsp->fnum, startpos, mode));
@@ -3330,7 +3332,7 @@ static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun,
}
if ((ofun&3) == 1) {
- lseek(fsp2->fd_ptr->fd,0,SEEK_END);
+ sys_lseek(fsp2->fd_ptr->fd,0,SEEK_END);
}
if (st.st_size)
@@ -3951,7 +3953,7 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_si
CHECK_ERROR(fsp);
/* Do an fstat on this file */
- if(fstat(fsp->fd_ptr->fd, &sbuf))
+ if(sys_fstat(fsp->fd_ptr->fd, &sbuf))
return(UNIXERROR(ERRDOS,ERRnoaccess));
mode = dos_mode(conn,fsp->fsp_name,&sbuf);
@@ -3969,7 +3971,7 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int dum_si
}
else
{
- SIVAL(outbuf,smb_vwv6,sbuf.st_size);
+ SIVAL(outbuf,smb_vwv6,(uint32)sbuf.st_size);
SIVAL(outbuf,smb_vwv8,ROUNDUP(sbuf.st_size,1024));
}
SSVAL(outbuf,smb_vwv10, mode);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 8871d568dd..dd1aa8f48b 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -200,7 +200,8 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf,
pstring fname;
int unixmode;
- int size=0,fmode=0,mtime=0,rmode;
+ SMB_OFF_T size=0;
+ int fmode=0,mtime=0,rmode;
SMB_INO_T inode = 0;
SMB_STRUCT_STAT sbuf;
int smb_action = 0;
@@ -247,7 +248,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf,
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fsp,False);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -270,7 +271,7 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf,
SSVAL(params,0,fsp->fnum);
SSVAL(params,2,fmode);
put_dos_date2(params,4, mtime);
- SIVAL(params,8, size);
+ SIVAL(params,8, (uint32)size);
SSVAL(params,12,rmode);
if (oplock_request && lp_fake_oplocks(SNUM(conn))) {
@@ -311,7 +312,8 @@ static int get_lanman2_dir_entry(connection_struct *conn,
uint32 reskey=0;
int prev_dirpos=0;
int mode=0;
- uint32 size=0,len;
+ SMB_OFF_T size = 0;
+ uint32 len;
uint32 mdate=0, adate=0, cdate=0;
char *nameptr;
BOOL isrootdir = (strequal(conn->dirpath,"./") ||
@@ -329,78 +331,78 @@ static int get_lanman2_dir_entry(connection_struct *conn,
p = strrchr(path_mask,'/');
if(p != NULL)
- {
- if(p[1] == '\0')
- pstrcpy(mask,"*.*");
- else
- pstrcpy(mask, p+1);
- }
+ {
+ if(p[1] == '\0')
+ pstrcpy(mask,"*.*");
+ else
+ pstrcpy(mask, p+1);
+ }
else
pstrcpy(mask, path_mask);
while (!found)
- {
- /* Needed if we run out of space */
- prev_dirpos = TellDir(conn->dirptr);
- dname = ReadDirName(conn->dirptr);
+ {
+ /* Needed if we run out of space */
+ prev_dirpos = TellDir(conn->dirptr);
+ dname = ReadDirName(conn->dirptr);
- /*
- * Due to bugs in NT client redirectors we are not using
- * resume keys any more - set them to zero.
- * Check out the related comments in findfirst/findnext.
- * JRA.
- */
+ /*
+ * Due to bugs in NT client redirectors we are not using
+ * resume keys any more - set them to zero.
+ * Check out the related comments in findfirst/findnext.
+ * JRA.
+ */
- reskey = 0;
+ reskey = 0;
- DEBUG(8,("get_lanman2_dir_entry:readdir on dirptr 0x%x now at offset %d\n",
- (unsigned)conn->dirptr,TellDir(conn->dirptr)));
+ DEBUG(8,("get_lanman2_dir_entry:readdir on dirptr 0x%x now at offset %d\n",
+ (unsigned)conn->dirptr,TellDir(conn->dirptr)));
- if (!dname)
- return(False);
+ if (!dname)
+ return(False);
- matched = False;
+ matched = False;
- pstrcpy(fname,dname);
+ pstrcpy(fname,dname);
- if(mask_match(fname, mask, case_sensitive, True))
- {
- BOOL isdots = (strequal(fname,"..") || strequal(fname,"."));
- if (dont_descend && !isdots)
- continue;
+ if(mask_match(fname, mask, case_sensitive, True))
+ {
+ BOOL isdots = (strequal(fname,"..") || strequal(fname,"."));
+ if (dont_descend && !isdots)
+ continue;
- if (isrootdir && isdots)
- continue;
-
- pstrcpy(pathreal,conn->dirpath);
- if(needslash)
- pstrcat(pathreal,"/");
- pstrcat(pathreal,dname);
- if (dos_stat(pathreal,&sbuf) != 0)
- {
- DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",pathreal,strerror(errno)));
- continue;
- }
-
- mode = dos_mode(conn,pathreal,&sbuf);
-
- if (!dir_check_ftype(conn,mode,&sbuf,dirtype)) {
- DEBUG(5,("[%s] attribs didn't match %x\n",fname,dirtype));
- continue;
- }
-
- size = sbuf.st_size;
- mdate = sbuf.st_mtime;
- adate = sbuf.st_atime;
- cdate = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
- if(mode & aDIR)
- size = 0;
-
- DEBUG(5,("get_lanman2_dir_entry found %s fname=%s\n",pathreal,fname));
+ if (isrootdir && isdots)
+ continue;
+
+ pstrcpy(pathreal,conn->dirpath);
+ if(needslash)
+ pstrcat(pathreal,"/");
+ pstrcat(pathreal,dname);
+ if (dos_stat(pathreal,&sbuf) != 0)
+ {
+ DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",pathreal,strerror(errno)));
+ continue;
+ }
+
+ mode = dos_mode(conn,pathreal,&sbuf);
+
+ if (!dir_check_ftype(conn,mode,&sbuf,dirtype)) {
+ DEBUG(5,("[%s] attribs didn't match %x\n",fname,dirtype));
+ continue;
+ }
+
+ size = sbuf.st_size;
+ mdate = sbuf.st_mtime;
+ adate = sbuf.st_atime;
+ cdate = get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn)));
+ if(mode & aDIR)
+ size = 0;
+
+ DEBUG(5,("get_lanman2_dir_entry found %s fname=%s\n",pathreal,fname));
- found = True;
- }
+ found = True;
}
+ }
name_map_mangle(fname,False,SNUM(conn));
@@ -410,7 +412,7 @@ static int get_lanman2_dir_entry(connection_struct *conn,
nt_extmode = mode ? mode : FILE_ATTRIBUTE_NORMAL;
switch (info_level)
- {
+ {
case 1:
if(requires_resume_key) {
SIVAL(p,0,reskey);
@@ -419,7 +421,7 @@ static int get_lanman2_dir_entry(connection_struct *conn,
put_dos_date2(p,l1_fdateCreation,cdate);
put_dos_date2(p,l1_fdateLastAccess,adate);
put_dos_date2(p,l1_fdateLastWrite,mdate);
- SIVAL(p,l1_cbFile,size);
+ SIVAL(p,l1_cbFile,(uint32)size);
SIVAL(p,l1_cbFileAlloc,ROUNDUP(size,1024));
SSVAL(p,l1_attrFile,mode);
SCVAL(p,l1_cchName,strlen(fname));
@@ -437,7 +439,7 @@ static int get_lanman2_dir_entry(connection_struct *conn,
put_dos_date2(p,l2_fdateCreation,cdate);
put_dos_date2(p,l2_fdateLastAccess,adate);
put_dos_date2(p,l2_fdateLastWrite,mdate);
- SIVAL(p,l2_cbFile,size);
+ SIVAL(p,l2_cbFile,(uint32)size);
SIVAL(p,l2_cbFileAlloc,ROUNDUP(size,1024));
SSVAL(p,l2_attrFile,mode);
SIVAL(p,l2_cbList,0); /* No extended attributes */
@@ -452,7 +454,7 @@ static int get_lanman2_dir_entry(connection_struct *conn,
put_dos_date2(p,4,cdate);
put_dos_date2(p,8,adate);
put_dos_date2(p,12,mdate);
- SIVAL(p,16,size);
+ SIVAL(p,16,(uint32)size);
SIVAL(p,20,ROUNDUP(size,1024));
SSVAL(p,24,mode);
SIVAL(p,26,4);
@@ -471,7 +473,7 @@ static int get_lanman2_dir_entry(connection_struct *conn,
put_dos_date2(p,4,cdate);
put_dos_date2(p,8,adate);
put_dos_date2(p,12,mdate);
- SIVAL(p,16,size);
+ SIVAL(p,16,(uint32)size);
SIVAL(p,20,ROUNDUP(size,1024));
SSVAL(p,24,mode);
CVAL(p,32) = strlen(fname);
@@ -1076,20 +1078,20 @@ static int call_trans2qfsinfo(connection_struct *conn,
pdata = *ppdata = Realloc(*ppdata, 1024); bzero(pdata,1024);
switch (info_level)
- {
+ {
case 1:
- {
- int dfree,dsize,bsize;
- data_len = 18;
- sys_disk_free(".",&bsize,&dfree,&dsize);
- SIVAL(pdata,l1_idFileSystem,st.st_dev);
- SIVAL(pdata,l1_cSectorUnit,bsize/512);
- SIVAL(pdata,l1_cUnit,dsize);
- SIVAL(pdata,l1_cUnitAvail,dfree);
- SSVAL(pdata,l1_cbSector,512);
- DEBUG(5,("call_trans2qfsinfo : bsize=%d, id=%x, cSectorUnit=%d, cUnit=%d, cUnitAvail=%d, cbSector=%d\n",
+ {
+ int dfree,dsize,bsize;
+ data_len = 18;
+ sys_disk_free(".",&bsize,&dfree,&dsize);
+ SIVAL(pdata,l1_idFileSystem,st.st_dev);
+ SIVAL(pdata,l1_cSectorUnit,bsize/512);
+ SIVAL(pdata,l1_cUnit,dsize);
+ SIVAL(pdata,l1_cUnitAvail,dfree);
+ SSVAL(pdata,l1_cbSector,512);
+ DEBUG(5,("call_trans2qfsinfo : bsize=%d, id=%x, cSectorUnit=%d, cUnit=%d, cUnitAvail=%d, cbSector=%d\n",
bsize, (unsigned)st.st_dev, bsize/512, dsize, dfree, 512));
- break;
+ break;
}
case 2:
{
@@ -1136,16 +1138,16 @@ static int call_trans2qfsinfo(connection_struct *conn,
vname));
break;
case SMB_QUERY_FS_SIZE_INFO:
- {
- int dfree,dsize,bsize;
- data_len = 24;
- sys_disk_free(".",&bsize,&dfree,&dsize);
- SIVAL(pdata,0,dsize);
- SIVAL(pdata,8,dfree);
- SIVAL(pdata,16,bsize/512);
- SIVAL(pdata,20,512);
- }
+ {
+ int dfree,dsize,bsize;
+ data_len = 24;
+ sys_disk_free(".",&bsize,&dfree,&dsize);
+ SIVAL(pdata,0,dsize);
+ SIVAL(pdata,8,dfree);
+ SIVAL(pdata,16,bsize/512);
+ SIVAL(pdata,20,512);
break;
+ }
case SMB_QUERY_FS_DEVICE_INFO:
data_len = 8;
SIVAL(pdata,0,0); /* dev type */
@@ -1153,7 +1155,7 @@ static int call_trans2qfsinfo(connection_struct *conn,
break;
default:
return(ERROR(ERRDOS,ERRunknownlevel));
- }
+ }
send_trans2_replies( outbuf, bufsize, params, 0, pdata, data_len);
@@ -1201,13 +1203,14 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
uint16 tran_call = SVAL(inbuf, smb_setup0);
uint16 info_level;
int mode=0;
- int size=0;
+ SMB_OFF_T size=0;
unsigned int data_size;
SMB_STRUCT_STAT sbuf;
pstring fname1;
char *fname;
char *p;
- int l,pos;
+ int l;
+ SMB_OFF_T pos;
BOOL bad_path = False;
if (tran_call == TRANSACT2_QFILEINFO) {
@@ -1218,11 +1221,11 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
CHECK_ERROR(fsp);
fname = fsp->fsp_name;
- if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
+ if (sys_fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
DEBUG(3,("fstat of fnum %d failed (%s)\n",fsp->fnum, strerror(errno)));
return(UNIXERROR(ERRDOS,ERRbadfid));
}
- pos = lseek(fsp->fd_ptr->fd,0,SEEK_CUR);
+ pos = sys_lseek(fsp->fd_ptr->fd,0,SEEK_CUR);
} else {
/* qpathinfo */
info_level = SVAL(params,0);
@@ -1278,7 +1281,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
put_dos_date2(pdata,l1_fdateCreation,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
put_dos_date2(pdata,l1_fdateLastAccess,sbuf.st_atime);
put_dos_date2(pdata,l1_fdateLastWrite,sbuf.st_mtime); /* write time */
- SIVAL(pdata,l1_cbFile,size);
+ SIVAL(pdata,l1_cbFile,(uint32)size);
SIVAL(pdata,l1_cbFileAlloc,ROUNDUP(size,1024));
SSVAL(pdata,l1_attrFile,mode);
SIVAL(pdata,l1_attrFile+2,4); /* this is what OS2 does */
@@ -1289,7 +1292,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
put_dos_date2(pdata,0,get_create_time(&sbuf,lp_fake_dir_create_times(SNUM(conn))));
put_dos_date2(pdata,4,sbuf.st_atime);
put_dos_date2(pdata,8,sbuf.st_mtime);
- SIVAL(pdata,12,size);
+ SIVAL(pdata,12,(uint32)size);
SIVAL(pdata,16,ROUNDUP(size,1024));
SIVAL(pdata,20,mode);
break;
@@ -1432,7 +1435,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
uint16 tran_call = SVAL(inbuf, smb_setup0);
uint16 info_level;
int mode=0;
- int size=0;
+ SMB_OFF_T size=0;
struct utimbuf tvs;
SMB_STRUCT_STAT st;
pstring fname1;
@@ -1453,7 +1456,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
fname = fsp->fsp_name;
fd = fsp->fd_ptr->fd;
- if(fstat(fd,&st)!=0) {
+ if(sys_fstat(fd,&st)!=0) {
DEBUG(3,("fstat of %s failed (%s)\n", fname, strerror(errno)));
return(ERROR(ERRDOS,ERRbadpath));
}
@@ -1581,7 +1584,11 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
DEBUG(6,("actime: %s " , ctime(&tvs.actime)));
DEBUG(6,("modtime: %s ", ctime(&tvs.modtime)));
+#ifdef LARGE_SMB_OFF_T
+ DEBUG(6,("size: %.0f ", (double)size));
+#else /* LARGE_SMB_OFF_T */
DEBUG(6,("size: %x " , size));
+#endif /* LARGE_SMB_OFF_T */
DEBUG(6,("mode: %x\n" , mode));
/* get some defaults (no modifications) if any info is zero. */