"error %d. Falling back to slow manual allocation\n", errno));
/* available disk space is enough or not? */
- space_avail = get_dfree_info(fsp->conn,
- fsp->fsp_name->base_name,
- &bsize, &dfree, &dsize);
+ space_avail =
+ get_dfree_info(fsp->conn, fsp->fsp_name, &bsize, &dfree, &dsize);
/* space_avail is 1k blocks */
if (space_avail == (uint64_t)-1 ||
((uint64_t)space_to_write/1024 > space_avail) ) {
"error %d. Falling back to slow manual allocation\n", errno));
/* available disk space is enough or not? */
- space_avail = get_dfree_info(fsp->conn,
- fsp->fsp_name->base_name,
- &bsize, &dfree, &dsize);
+ space_avail =
+ get_dfree_info(fsp->conn, fsp->fsp_name, &bsize, &dfree, &dsize);
/* space_avail is 1k blocks */
if (space_avail == (uint64_t)-1 ||
((uint64_t)space_to_write/1024 > space_avail) ) {
Return number of 1K blocks available on a path and total number.
****************************************************************************/
-uint64_t sys_disk_free(connection_struct *conn, const char *path,
+uint64_t sys_disk_free(connection_struct *conn, struct smb_filename *fname,
uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
uint64_t dfree_retval;
uint64_t dsize_q = 0;
const char *dfree_command;
static bool dfree_broken = false;
+ const char *path = fname->base_name;
(*dfree) = (*dsize) = 0;
(*bsize) = 512;
return (uint64_t)-1;
}
- if (disk_quotas(conn, path, &bsize_q, &dfree_q, &dsize_q)) {
+ if (disk_quotas(conn, fname, &bsize_q, &dfree_q, &dsize_q)) {
uint64_t min_bsize = MIN(*bsize, bsize_q);
(*dfree) = (*dfree) * (*bsize) / min_bsize;
Potentially returned cached dfree info.
****************************************************************************/
-uint64_t get_dfree_info(connection_struct *conn,
- const char *path,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize)
+uint64_t get_dfree_info(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
int dfree_cache_time = lp_dfree_cache_time(SNUM(conn));
struct dfree_cached_info *dfc = conn->dfree_info;
uint64_t dfree_ret;
if (!dfree_cache_time) {
- return sys_disk_free(conn, path, bsize, dfree, dsize);
+ return sys_disk_free(conn, fname, bsize, dfree, dsize);
}
if (dfc && (conn->lastused - dfc->last_dfree_time < dfree_cache_time)) {
return dfc->dfree_ret;
}
- dfree_ret = sys_disk_free(conn, path, bsize, dfree, dsize);
+ dfree_ret = sys_disk_free(conn, fname, bsize, dfree, dsize);
if (dfree_ret == (uint64_t)-1) {
/* Don't cache bad data. */
/* The following definitions come from smbd/dfree.c */
-uint64_t sys_disk_free(connection_struct *conn, const char *path,
- uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
-uint64_t get_dfree_info(connection_struct *conn,
- const char *path,
- uint64_t *bsize,
- uint64_t *dfree,
- uint64_t *dsize);
+uint64_t sys_disk_free(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
+uint64_t get_dfree_info(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
/* The following definitions come from smbd/dir.c */
/* The following definitions come from smbd/quotas.c */
-bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize);
+bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
/* The following definitions come from smbd/reply.c */
Quota code by Peter Urbanec (amiga@cse.unsw.edu.au).
****************************************************************************/
-bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
uid_t euser_id;
int ret;
SMB_STRUCT_STAT sbuf;
SMB_DEV_T devno;
bool found = false;
+ const char *path = fname->base_name;
euser_id = geteuid();
- if (sys_stat(path, &sbuf, false) == -1) {
- return false;
- }
-
- devno = sbuf.st_ex_dev ;
+ devno = fname->st.st_ex_dev;
DEBUG(5,("disk_quotas: looking for path \"%s\" devno=%x\n",
path, (unsigned int)devno));
if ((fd = fopen(MNTTAB, "r")) == NULL) {
try to get the disk space from disk quotas - default version
****************************************************************************/
-bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
int r;
struct dqblk D;
uid_t euser_id;
+ const char *path = fname->base_name;
#if !defined(AIX)
char dev_disk[256];
- SMB_STRUCT_STAT S;
+ SMB_STRUCT_STAT S = fname->st;
/* find the block device file */
#else /* WITH_QUOTAS */
-bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
(*bsize) = 512; /* This value should be ignored */
/* wrapper to the new sys_quota interface
this file should be removed later
*/
-bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
+ uint64_t *bsize, uint64_t *dfree, uint64_t *dsize)
{
int r;
SMB_DISK_QUOTA D;
*/
ZERO_STRUCT(D);
id.uid = -1;
- r = SMB_VFS_GET_QUOTA(conn, path, SMB_USER_FS_QUOTA_TYPE, id, &D);
+ r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_USER_FS_QUOTA_TYPE,
+ id, &D);
if (r == -1 && errno != ENOSYS) {
goto try_group_quota;
}
ZERO_STRUCT(D);
id.uid = geteuid();
- r = SMB_VFS_GET_QUOTA(conn, path, SMB_USER_QUOTA_TYPE, id, &D);
+ r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_USER_QUOTA_TYPE, id,
+ &D);
if (r == -1) {
goto try_group_quota;
*/
ZERO_STRUCT(D);
id.gid = -1;
- r = SMB_VFS_GET_QUOTA(conn, path, SMB_GROUP_FS_QUOTA_TYPE, id, &D);
+ r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_FS_QUOTA_TYPE,
+ id, &D);
if (r == -1 && errno != ENOSYS) {
return false;
}
id.gid = getegid();
ZERO_STRUCT(D);
- r = SMB_VFS_GET_QUOTA(conn, path, SMB_GROUP_QUOTA_TYPE, id, &D);
+ r = SMB_VFS_GET_QUOTA(conn, fname->base_name, SMB_GROUP_QUOTA_TYPE, id,
+ &D);
if (r == -1) {
return False;
connection_struct *conn = req->conn;
uint64_t ret;
uint64_t dfree,dsize,bsize;
+ struct smb_filename smb_fname;
START_PROFILE(SMBdskattr);
- ret = get_dfree_info(conn, ".", &bsize, &dfree, &dsize);
+ ZERO_STRUCT(smb_fname);
+ smb_fname.base_name = discard_const_p(char, ".");
+
+ if (SMB_VFS_STAT(conn, &smb_fname) != 0) {
+ reply_nterror(req, map_nt_error_from_unix(errno));
+ DBG_WARNING("stat of . failed (%s)\n", strerror(errno));
+ END_PROFILE(SMBdskattr);
+ return;
+ }
+
+ ret = get_dfree_info(conn, &smb_fname, &bsize, &dfree, &dsize);
if (ret == (uint64_t)-1) {
reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBdskattr);
{
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit;
data_len = 18;
- df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
- &dsize);
+ df_ret = get_dfree_info(conn, &smb_fname, &bsize,
+ &dfree, &dsize);
if (df_ret == (uint64_t)-1) {
return map_nt_error_from_unix(errno);
}
{
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit;
data_len = 24;
- df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
- &dsize);
+ df_ret = get_dfree_info(conn, &smb_fname, &bsize,
+ &dfree, &dsize);
if (df_ret == (uint64_t)-1) {
return map_nt_error_from_unix(errno);
}
{
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit;
data_len = 32;
- df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
- &dsize);
+ df_ret = get_dfree_info(conn, &smb_fname, &bsize,
+ &dfree, &dsize);
if (df_ret == (uint64_t)-1) {
return map_nt_error_from_unix(errno);
}
len -= fsp->fsp_name->st.st_ex_size;
len /= 1024; /* Len is now number of 1k blocks needed. */
- space_avail = get_dfree_info(conn, fsp->fsp_name->base_name,
- &bsize, &dfree, &dsize);
+ space_avail =
+ get_dfree_info(conn, fsp->fsp_name, &bsize, &dfree, &dsize);
if (space_avail == (uint64_t)-1) {
return -1;
}