include/config.h.in: Added #undef STAT_STATVFS64.
include/includes.h: Added SMB_STRUCT_STATVFS type, Changed SMB_BIG_INTEGER to
SMB_BIG_UINT and SMB_BIG_INT types.
include/smb.h: Added flag defines from CIFS spec.
lib/debug.c: Fixed one more mode_t issue.
lib/system.c: Added sys_statvfs wrapper.
lib/util.c: Changed trim_string to use size_t.
param/loadparm.c: Moved "blocking locks" into locking section. Alphabetised
locking options. Question - shuld we do this for all options ?
passdb/ldap.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT.
passdb/nispass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT.
passdb/smbpass.c: Changed SMB_BIG_INTEGER to SMB_BIG_UINT.
smbd/dfree.c: Changed to use 64 bit types if available. Moved to use unsigned
types.
smbd/dosmode.c: Fixed one more mode_t issue.
smbd/negprot.c: Changed literals to be FLAG_ #defines.
smbd/nttrans.c: Removed dead code.
smbd/open.c: Changed disk_free call.
smbd/process.c: Changed literals to be FLAG_ #defines.
smbd/reply.c: Changed disk_free call.
smbd/trans2.c: Fixed but in SMB_QUERY_FS_VOLUME_INFO call. Was using
UNICODE - should use ascii.
tests/summary.c: Added STAT_STATVFS64 check.
Jeremy.
echo "configure:4629: checking how to get filesystem space usage" >&5
space=no
+# Test for statvfs64.
+if test $space = no; then
+ # SVR4
+ echo $ac_n "checking statvfs64 function (SVR4)""... $ac_c" 1>&6
+echo "configure:4636: checking statvfs64 function (SVR4)" >&5
+if eval "test \"`echo '$''{'fu_cv_sys_stat_statvfs64'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4644 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <sys/statvfs.h>
+ main ()
+ {
+ struct statvfs64 fsd;
+ exit (statfs64 (".", &fsd));
+ }
+EOF
+if { (eval echo configure:4655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+ fu_cv_sys_stat_statvfs64=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ fu_cv_sys_stat_statvfs64=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$fu_cv_sys_stat_statvfs64" 1>&6
+ if test $fu_cv_sys_stat_statvfs64 = yes; then
+ space=yes
+ cat >> confdefs.h <<\EOF
+#define STAT_STATVFS64 1
+EOF
+
+ fi
+fi
+
# Perform only the link test since it seems there are no variants of the
# statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs)
# because that got a false positive on SCO OSR5. Adding the declaration
if test $space = no; then
# SVR4
echo $ac_n "checking statvfs function (SVR4)""... $ac_c" 1>&6
-echo "configure:4641: checking statvfs function (SVR4)" >&5
+echo "configure:4688: checking statvfs function (SVR4)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statvfs'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4646 "configure"
+#line 4693 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/statvfs.h>
struct statvfs fsd; statvfs (0, &fsd);
; return 0; }
EOF
-if { (eval echo configure:4654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
fu_cv_sys_stat_statvfs=yes
else
if test $space = no; then
# DEC Alpha running OSF/1
echo $ac_n "checking for 3-argument statfs function (DEC OSF/1)""... $ac_c" 1>&6
-echo "configure:4679: checking for 3-argument statfs function (DEC OSF/1)" >&5
+echo "configure:4726: checking for 3-argument statfs function (DEC OSF/1)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs3_osf1'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs3_osf1=no
else
cat > conftest.$ac_ext <<EOF
-#line 4687 "configure"
+#line 4734 "configure"
#include "confdefs.h"
#include <sys/param.h>
exit (statfs (".", &fsd, sizeof (struct statfs)));
}
EOF
-if { (eval echo configure:4700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs3_osf1=yes
else
if test $space = no; then
# AIX
echo $ac_n "checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)""... $ac_c" 1>&6
-echo "configure:4727: checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)" >&5
+echo "configure:4774: checking for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs2_bsize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs2_bsize=no
else
cat > conftest.$ac_ext <<EOF
-#line 4735 "configure"
+#line 4782 "configure"
#include "confdefs.h"
#ifdef HAVE_SYS_PARAM_H
exit (statfs (".", &fsd));
}
EOF
-if { (eval echo configure:4754: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs2_bsize=yes
else
if test $space = no; then
# SVR3
echo $ac_n "checking for four-argument statfs (AIX-3.2.5, SVR3)""... $ac_c" 1>&6
-echo "configure:4781: checking for four-argument statfs (AIX-3.2.5, SVR3)" >&5
+echo "configure:4828: checking for four-argument statfs (AIX-3.2.5, SVR3)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs4'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs4=no
else
cat > conftest.$ac_ext <<EOF
-#line 4789 "configure"
+#line 4836 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/statfs.h>
exit (statfs (".", &fsd, sizeof fsd, 0));
}
EOF
-if { (eval echo configure:4799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4846: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs4=yes
else
if test $space = no; then
# 4.4BSD and NetBSD
echo $ac_n "checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)""... $ac_c" 1>&6
-echo "configure:4826: checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)" >&5
+echo "configure:4873: checking for two-argument statfs with statfs.fsize member (4.4BSD and NetBSD)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_statfs2_fsize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_statfs2_fsize=no
else
cat > conftest.$ac_ext <<EOF
-#line 4834 "configure"
+#line 4881 "configure"
#include "confdefs.h"
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
exit (statfs (".", &fsd));
}
EOF
-if { (eval echo configure:4850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_statfs2_fsize=yes
else
if test $space = no; then
# Ultrix
echo $ac_n "checking for two-argument statfs with struct fs_data (Ultrix)""... $ac_c" 1>&6
-echo "configure:4877: checking for two-argument statfs with struct fs_data (Ultrix)" >&5
+echo "configure:4924: checking for two-argument statfs with struct fs_data (Ultrix)" >&5
if eval "test \"`echo '$''{'fu_cv_sys_stat_fs_data'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
fu_cv_sys_stat_fs_data=no
else
cat > conftest.$ac_ext <<EOF
-#line 4885 "configure"
+#line 4932 "configure"
#include "confdefs.h"
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
exit (statfs (".", &fsd) != 1);
}
EOF
-if { (eval echo configure:4905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
fu_cv_sys_stat_fs_data=yes
else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 4934 "configure"
+#line 4981 "configure"
#include "confdefs.h"
#include "tests/summary.c"
EOF
-if { (eval echo configure:4938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
echo "configure OK";
else
AC_CHECKING(how to get filesystem space usage)
space=no
+# Test for statvfs64.
+if test $space = no; then
+ # SVR4
+ AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
+ [AC_TRY_RUN([
+#include <sys/types.h>
+#include <sys/statvfs.h>
+ main ()
+ {
+ struct statvfs64 fsd;
+ exit (statfs64 (".", &fsd));
+ }],
+ fu_cv_sys_stat_statvfs64=yes,
+ fu_cv_sys_stat_statvfs64=no)])
+ if test $fu_cv_sys_stat_statvfs64 = yes; then
+ space=yes
+ AC_DEFINE(STAT_STATVFS64)
+ fi
+fi
+
# Perform only the link test since it seems there are no variants of the
# statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs)
# because that got a false positive on SCO OSR5. Adding the declaration
#undef STAT_STATFS3_OSF1
#undef STAT_STATFS4
#undef STAT_STATVFS
+#undef STAT_STATVFS64
#undef HAVE_NETMASK_IFREQ
#undef HAVE_NETMASK_AIX
#undef HAVE_CRYPT
# endif
#endif
+/*
+ * Type for statvfs structure.
+ */
+
+#ifndef SMB_STRUCT_STATVFS
+# if defined(STAT_STATVFS64)
+# define SMB_STRUCT_STATVFS struct statvfs64
+# else
+# define SMB_STRUCT_STATVFS struct statvfs
+# endif
+#endif
+
/*
* Defines for 64 bit fcntl locks.
*/
#endif
#if defined(HAVE_LONGLONG)
-#define SMB_BIG_INTEGER unsigned long long
+#define SMB_BIG_UINT unsigned long long
+#define SMB_BIG_INT long long
#else
-#define SMB_BIG_INTEGER unsigned long
+#define SMB_BIG_UINT unsigned long
+#define SMB_BIG_INT long
#endif
#ifndef MIN
int sys_stat(char *fname,SMB_STRUCT_STAT *sbuf);
int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf);
int sys_lstat(char *fname,SMB_STRUCT_STAT *sbuf);
+int sys_statvfs( const char *path, SMB_STRUCT_STATVFS *fsd);
int sys_ftruncate(int fd, SMB_OFF_T offset);
SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
/*The following definitions come from smbd/dfree.c */
-int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize);
/*The following definitions come from smbd/dir.c */
void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int share_mode,int ofun,
mode_t mode,int oplock_request, int *Access,int *action);
int open_directory(files_struct *fsp,connection_struct *conn,
- char *fname, int smb_ofun, int unixmode, int *action);
+ char *fname, int smb_ofun, mode_t unixmode, int *action);
BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op);
/*The following definitions come from smbd/oplock.c */
*/
void *(*startsmbpwent)(BOOL);
void (*endsmbpwent)(void *);
- SMB_BIG_INTEGER (*getsmbpwpos)(void *);
- BOOL (*setsmbpwpos)(void *, SMB_BIG_INTEGER);
+ SMB_BIG_UINT (*getsmbpwpos)(void *);
+ BOOL (*setsmbpwpos)(void *, SMB_BIG_UINT);
/*
* smb password database query functions.
#define smb_vwv16 69
#define smb_vwv17 71
+/* flag defines. CIFS spec 3.1.1 */
+#define FLAG_SUPPORT_LOCKREAD 0x01
+#define FLAG_CLIENT_BUF_AVAIL 0x02
+#define FLAG_RESERVED 0x04
+#define FLAG_CASELESS_PATHNAMES 0x08
+#define FLAG_CANONICAL_PATHNAMES 0x10
+#define FLAG_REQUEST_OPLOCK 0x20
+#define FLAG_REQUEST_BATCH_OPLOCK 0x40
+#define FLAG_REPLY 0x80
/* the complete */
#define SMBmkdir 0x00 /* create directory */
/* these are for the NT create_and_X */
#define smb_ntcreate_NameLength (smb_vwv0 + 5)
#define smb_ntcreate_Flags (smb_vwv0 + 7)
-#define smb_ntcreate_RootDirectoryFid (smb_wvw0 + 11)
+#define smb_ntcreate_RootDirectoryFid (smb_vwv0 + 11)
#define smb_ntcreate_DesiredAccess (smb_vwv0 + 15)
#define smb_ntcreate_AllocationSize (smb_vwv0 + 19)
#define smb_ntcreate_FileAttributes (smb_vwv0 + 27)
/*
* Core protocol.
*/
-#define CORE_OPLOCK_REQUEST(inbuf) ((CVAL(inbuf,smb_flg)&((1<<5)|(1<<6)))>>5)
+#define CORE_OPLOCK_REQUEST(inbuf) \
+ ((CVAL(inbuf,smb_flg)&(FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK))>>5)
/*
* Extended protocol.
if( !strcsequal( fname, debugf ) || !dbf || !file_exist( debugf, NULL ) )
{
- int oldumask = umask( 022 );
+ mode_t oldumask = umask( 022 );
pstrcpy( debugf, fname );
if( dbf )
{
if( !dbf )
{
- int oldumask = umask( 022 );
+ mode_t oldumask = umask( 022 );
if( append_log )
dbf = fopen( debugf, "a" );
#endif
}
+/*******************************************************************
+ An statvfs() wrapper that will deal with 64 bit filesizes.
+********************************************************************/
+
+int sys_statvfs( const char *path, SMB_STRUCT_STATVFS *fsd)
+{
+#if defined(STAT_STATVFS64)
+ return statvfs64(path, fsd);
+#else
+ return statvfs(path, fsd);
+#endif
+}
+
/*******************************************************************
An ftruncate() wrapper that will deal with 64 bit filesizes.
********************************************************************/
BOOL trim_string(char *s,char *front,char *back)
{
BOOL ret = False;
- int front_len = (front && *front) ? strlen(front) : 0;
- int back_len = (back && *back) ? strlen(back) : 0;
- int s_len;
+ size_t front_len = (front && *front) ? strlen(front) : 0;
+ size_t back_len = (back && *back) ? strlen(back) : 0;
+ size_t s_len;
while (front_len && strncmp(s, front, front_len) == 0)
{
{"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL, NULL, 0},
{"Tuning Options", P_SEP, P_SEPARATOR},
- {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, 0},
{"change notify timeout", P_INTEGER, P_GLOBAL, &Globals.change_notify_timeout, NULL, NULL, 0},
{"deadtime", P_INTEGER, P_GLOBAL, &Globals.deadtime, NULL, NULL, 0},
{"getwd cache", P_BOOL, P_GLOBAL, &use_getwd_cache, NULL, NULL, 0},
{"WINS Options", P_SEP, P_SEPARATOR},
{"dns proxy", P_BOOL, P_GLOBAL, &Globals.bDNSproxy, NULL, NULL, 0},
- {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC},
{"wins proxy", P_BOOL, P_GLOBAL, &Globals.bWINSproxy, NULL, NULL, 0},
{"wins server", P_STRING, P_GLOBAL, &Globals.szWINSserver, NULL, NULL, FLAG_BASIC},
+ {"wins support", P_BOOL, P_GLOBAL, &Globals.bWINSsupport, NULL, NULL, FLAG_BASIC},
{"Locking Options", P_SEP, P_SEPARATOR},
+ {"blocking locks", P_BOOL, P_LOCAL, &sDefault.bBlockingLocks, NULL, NULL, 0},
+ {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, 0},
{"locking", P_BOOL, P_LOCAL, &sDefault.bLocking, NULL, NULL, FLAG_GLOBAL},
+ {"ole locking compatibility", P_BOOL, P_GLOBAL, &Globals.bOleLockingCompat, NULL, NULL, FLAG_GLOBAL},
+ {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_GLOBAL},
{"strict locking", P_BOOL, P_LOCAL, &sDefault.bStrictLocking, NULL, NULL, FLAG_GLOBAL},
{"share modes", P_BOOL, P_LOCAL, &sDefault.bShareModes, NULL, NULL, FLAG_GLOBAL},
- {"oplocks", P_BOOL, P_LOCAL, &sDefault.bOpLocks, NULL, NULL, FLAG_GLOBAL},
- {"fake oplocks", P_BOOL, P_LOCAL, &sDefault.bFakeOplocks, NULL, NULL, 0},
- {"ole locking compatibility", P_BOOL, P_GLOBAL, &Globals.bOleLockingCompat, NULL, NULL, FLAG_GLOBAL},
#ifdef WITH_LDAP
{"Ldap Options", P_SEP, P_SEPARATOR},
}
/*************************************************************************
- Return the current position in the ldap passwd list as an SMB_BIG_INTEGER.
+ Return the current position in the ldap passwd list as an SMB_BIG_UINT.
This must be treated as an opaque token.
do not call this function directly. use passdb.c instead.
*************************************************************************/
-static SMB_BIG_INTEGER getldappwpos(void *vp)
+static SMB_BIG_UINT getldappwpos(void *vp)
{
- return 0;
+ return (SMB_BIG_UINT)0;
}
/*************************************************************************
- Set the current position in the ldap passwd list from SMB_BIG_INTEGER.
+ Set the current position in the ldap passwd list from SMB_BIG_UINT.
This must be treated as an opaque token.
do not call this function directly. use passdb.c instead.
*************************************************************************/
-static BOOL setldappwpos(void *vp, SMB_BIG_INTEGER tok)
+static BOOL setldappwpos(void *vp, SMB_BIG_UINT tok)
{
return False;
}
}
/*************************************************************************
- Return the current position in the nisplus passwd list as an SMB_BIG_INTEGER.
+ Return the current position in the nisplus passwd list as an SMB_BIG_UINT.
This must be treated as an opaque token.
do not call this function directly. use passdb.c instead.
*************************************************************************/
-static SMB_BIG_INTEGER getnisppwpos(void *vp)
+static SMB_BIG_UINT getnisppwpos(void *vp)
{
- return 0;
+ return (SMB_BIG_UINT)0;
}
/*************************************************************************
- Set the current position in the nisplus passwd list from SMB_BIG_INTEGER.
+ Set the current position in the nisplus passwd list from SMB_BIG_UINT.
This must be treated as an opaque token.
do not call this function directly. use passdb.c instead.
*************************************************************************/
-static BOOL setnisppwpos(void *vp, SMB_BIG_INTEGER tok)
+static BOOL setnisppwpos(void *vp, SMB_BIG_UINT tok)
{
return False;
}
}
/*************************************************************************
- Return the current position in the smbpasswd list as an SMB_BIG_INTEGER
+ Return the current position in the smbpasswd list as an SMB_BIG_UINT.
This must be treated as an opaque token.
*************************************************************************/
-static SMB_BIG_INTEGER getsmbfilepwpos(void *vp)
+static SMB_BIG_UINT getsmbfilepwpos(void *vp)
{
- return (SMB_BIG_INTEGER)sys_ftell((FILE *)vp);
+ return (SMB_BIG_UINT)sys_ftell((FILE *)vp);
}
/*************************************************************************
- Set the current position in the smbpasswd list from an SMB_BIG_INTEGER.
+ Set the current position in the smbpasswd list from an SMB_BIG_UINT.
This must be treated as an opaque token.
*************************************************************************/
-static BOOL setsmbfilepwpos(void *vp, SMB_BIG_INTEGER tok)
+static BOOL setsmbfilepwpos(void *vp, SMB_BIG_UINT tok)
{
return !sys_fseek((FILE *)vp, (SMB_OFF_T)tok, SEEK_SET);
}
/****************************************************************************
normalise for DOS usage
****************************************************************************/
-static void disk_norm(int *bsize,int *dfree,int *dsize)
+static void disk_norm(SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize)
{
/* check if the disk is beyond the max disk size */
- int maxdisksize = lp_maxdisksize();
+ SMB_BIG_UINT maxdisksize = lp_maxdisksize();
if (maxdisksize) {
/* convert to blocks - and don't overflow */
maxdisksize = ((maxdisksize*1024)/(*bsize))*1024;
/* Return the number of TOSIZE-byte blocks used by
BLOCKS FROMSIZE-byte blocks, rounding away from zero.
- TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */
-static int adjust_blocks(int blocks, int fromsize, int tosize)
+*/
+static SMB_BIG_UINT adjust_blocks(SMB_BIG_UINT blocks, SMB_BIG_UINT fromsize, SMB_BIG_UINT tosize)
{
- if (tosize <= 0 || fromsize <= 0) {
- return -1;
- }
-
if (fromsize == tosize) /* e.g., from 512 to 512 */
return blocks;
else if (fromsize > tosize) /* e.g., from 2048 to 512 */
return blocks * (fromsize / tosize);
else /* e.g., from 256 to 512 */
- return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize);
+ return (blocks + 1) / (tosize / fromsize);
}
/* this does all of the system specific guff to get the free disk space.
results are returned in *dfree and *dsize, in 512 byte units
*/
-static int fsusage(const char *path, int *dfree, int *dsize)
+static int fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
#ifdef STAT_STATFS3_OSF1
-#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512)
+#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_fsize, (SMB_BIG_UINT)512)
struct statfs fsd;
if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
#endif /* STAT_STATFS3_OSF1 */
#ifdef STAT_STATFS2_FS_DATA /* Ultrix */
-#define CONVERT_BLOCKS(B) adjust_blocks ((B), 1024, 512)
+#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)1024, (SMB_BIG_UINT)512)
struct fs_data fsd;
if (statfs (path, &fsd) != 1)
#endif /* STAT_STATFS2_FS_DATA */
#ifdef STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
-#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512)
+#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512)
struct statfs fsd;
if (statfs (path, &fsd) < 0)
#ifdef STAT_STATFS2_FSIZE /* 4.4BSD */
-#define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_fsize, 512)
+#define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_fsize, (SMB_BIG_UINT)512)
struct statfs fsd;
#ifdef STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */
# if _AIX || defined(_CRAY)
-# define CONVERT_BLOCKS(B) adjust_blocks ((B), fsd.f_bsize, 512)
+# define CONVERT_BLOCKS(B) adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512)
# ifdef _CRAY
# define f_bavail f_bfree
# endif
# else
-# define CONVERT_BLOCKS(B) (B)
+# define CONVERT_BLOCKS(B) ((SMB_BIG_UINT)B)
# ifndef _SEQUENT_ /* _SEQUENT_ is DYNIX/ptx */
# ifndef DOLPHIN /* DOLPHIN 3.8.alfa/7.18 has f_bavail */
# define f_bavail f_bfree
#ifdef STAT_STATVFS /* SVR4 */
# define CONVERT_BLOCKS(B) \
- adjust_blocks ((B), fsd.f_frsize ? fsd.f_frsize : fsd.f_bsize, 512)
+ adjust_blocks ((SMB_BIG_UINT)(B), fsd.f_frsize ? (SMB_BIG_UINT)fsd.f_frsize : (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512)
- struct statvfs fsd;
+ SMB_STRUCT_STATVFS fsd;
- if (statvfs (path, &fsd) < 0)
+ if (sys_statvfs (path, &fsd) < 0)
return -1;
/* f_frsize isn't guaranteed to be supported. */
/****************************************************************************
return number of 1K blocks available on a path and total number
****************************************************************************/
-static int disk_free(char *path,int *bsize,int *dfree,int *dsize)
+static SMB_BIG_UINT disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize)
{
int dfree_retval;
/****************************************************************************
wrap it to get filenames right
****************************************************************************/
-int sys_disk_free(char *path,int *bsize,int *dfree,int *dsize)
+SMB_BIG_UINT sys_disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SMB_BIG_UINT *dsize)
{
return(disk_free(dos_to_unix(path,False),bsize,dfree,dsize));
}
-
-
{
SMB_STRUCT_STAT st1;
int mask=0;
- int tmp;
+ mode_t tmp;
mode_t unixmode;
if (!st) {
int outsize = set_message(outbuf,13,0,True);
SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support
readbraw and writebraw (possibly) */
- CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */
+ /* Reply, SMBlockread, SMBwritelock supported. */
+ SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
SSVAL(outbuf,smb_vwv1,0x1); /* user level security, don't encrypt */
Protocol = PROTOCOL_COREPLUS;
Protocol = PROTOCOL_LANMAN1;
- CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */
+ /* Reply, SMBlockread, SMBwritelock supported. */
+ SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
SSVAL(outbuf,smb_vwv2,max_recv);
SSVAL(outbuf,smb_vwv3,lp_maxmux()); /* maxmux */
SSVAL(outbuf,smb_vwv4,1);
Protocol = PROTOCOL_LANMAN2;
- CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */
+ /* Reply, SMBlockread, SMBwritelock supported. */
+ SCVAL(outbuf,smb_flg,FLAG_REPLY|FLAG_SUPPORT_LOCKREAD);
SSVAL(outbuf,smb_vwv2,max_recv);
SSVAL(outbuf,smb_vwv3,lp_maxmux());
SSVAL(outbuf,smb_vwv4,1);
return(outsize);
}
-
int oplock_request = 0;
mode_t unixmode;
int pnum = -1;
- int fmode=0,mtime=0,rmode=0;
+ int fmode=0,rmode=0;
off_t file_len = 0;
SMB_STRUCT_STAT sbuf;
int smb_action = 0;
fmode = dos_mode(conn,fname,&sbuf);
if(fmode == 0)
fmode = FILE_ATTRIBUTE_NORMAL;
- mtime = sbuf.st_mtime;
if (fmode & aDIR) {
close_file(fsp,False);
if ((fd_ptr->fd >=0) &&
conn->printer && lp_minprintspace(SNUM(conn))) {
pstring dname;
- int dum1,dum2,dum3;
+ SMB_BIG_UINT dum1,dum2,dum3;
char *p;
pstrcpy(dname,fname);
p = strrchr(dname,'/');
if (p) *p = 0;
- if (sys_disk_free(dname,&dum1,&dum2,&dum3) <
- lp_minprintspace(SNUM(conn))) {
+ if (sys_disk_free(dname,&dum1,&dum2,&dum3) < (SMB_BIG_UINT)lp_minprintspace(SNUM(conn))) {
if(fd_attempt_close(fd_ptr) == 0)
dos_unlink(fname);
fsp->fd_ptr = 0;
Open a directory from an NT SMB call.
****************************************************************************/
int open_directory(files_struct *fsp,connection_struct *conn,
- char *fname, int smb_ofun, int unixmode, int *action)
+ char *fname, int smb_ofun, mode_t unixmode, int *action)
{
extern struct current_user current_user;
SMB_STRUCT_STAT st;
memcpy(outbuf+4,inbuf+4,4);
CVAL(outbuf,smb_rcls) = SMB_SUCCESS;
CVAL(outbuf,smb_reh) = 0;
- CVAL(outbuf,smb_flg) = 0x80 | (CVAL(inbuf,smb_flg) & 0x8); /* bit 7 set
+ SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES)); /* bit 7 set
means a reply */
- SSVAL(outbuf,smb_flg2,1); /* say we support long filenames */
+ SSVAL(outbuf,smb_flg2,FLAGS2_LONG_PATH_COMPONENTS); /* say we support long filenames */
SSVAL(outbuf,smb_err,SMB_SUCCESS);
SSVAL(outbuf,smb_tid,SVAL(inbuf,smb_tid));
SSVAL(outbuf,smb_pid,SVAL(inbuf,smb_pid));
int reply_dskattr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = 0;
- int dfree,dsize,bsize;
+ SMB_BIG_UINT dfree,dsize,bsize;
sys_disk_free(".",&bsize,&dfree,&dsize);
{
case 1:
{
- int dfree,dsize,bsize;
+ SMB_BIG_UINT dfree,dsize,bsize;
data_len = 18;
sys_disk_free(".",&bsize,&dfree,&dsize);
SIVAL(pdata,l1_idFileSystem,st.st_dev);
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));
+ DEBUG(5,("call_trans2qfsinfo : bsize=%u, id=%x, cSectorUnit=%u, cUnit=%u, cUnitAvail=%u, cbSector=%d\n",
+ (unsigned int)bsize, (unsigned int)st.st_dev, ((unsigned int)bsize)/512, (unsigned int)dsize,
+ (unsigned int)dfree, 512));
break;
}
case 2:
SIVAL(pdata,4,128); /* Max filename component length */
SIVAL(pdata,8,2*strlen(FSTYPE_STRING));
PutUniCode(pdata+12,FSTYPE_STRING);
+ SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2)|FLAGS2_UNICODE_STRINGS);
break;
case SMB_QUERY_FS_LABEL_INFO:
data_len = 4 + strlen(vname);
pstrcpy(pdata+4,vname);
break;
case SMB_QUERY_FS_VOLUME_INFO:
- data_len = 18 + 2*strlen(vname);
+
+ /*
+ * NB: The earlier CIFS spec that says this always
+ * uses UNICODE is incorrect ! JRA.
+ */
+
+ data_len = 18 + strlen(vname);
+
/*
* Add volume serial number - hash of a combination of
* the called hostname and the service name.
*/
SIVAL(pdata,8,str_checksum(lp_servicename(snum)) ^ (str_checksum(local_machine)<<16) );
- SIVAL(pdata,12,2*strlen(vname));
- PutUniCode(pdata+18,vname);
+ SIVAL(pdata,12,strlen(vname));
+ pstrcpy(pdata+18,vname);
DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_FS_VOLUME_INFO namelen = %d, vol = %s\n", strlen(vname),
vname));
break;
case SMB_QUERY_FS_SIZE_INFO:
{
- int dfree,dsize,bsize;
+ SMB_BIG_UINT dfree,dsize,bsize;
data_len = 24;
sys_disk_free(".",&bsize,&dfree,&dsize);
SIVAL(pdata,0,dsize);
printf("WARNING: No automated netmask determination - use an interfaces line\n");
#endif
-#if !(defined(STAT_STATVFS) || defined(STAT_STATFS3_OSF1) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS4) || defined(STAT_STATFS2_FSIZE) || defined(STAT_STATFS2_FS_DATA))
+#if !(defined(STAT_STATVFS) || defined(STAT_STATVFS64) || defined(STAT_STATFS3_OSF1) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS4) || defined(STAT_STATFS2_FSIZE) || defined(STAT_STATFS2_FS_DATA))
printf("ERROR: No disk free routine!\n");
exit(1);
#endif