struct files_struct *dirfsp = NULL;
const char *dname = NULL;
char *talloced = NULL;
- long offset = 0;
NTSTATUS status;
int ret;
uint32_t slots;
sc_data->num_volumes = 0;
sc_data->labels = NULL;
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))
!= NULL)
{
if (ISDOT(dname) || ISDOTDOT(dname)) {
struct files_struct *dirfsp = NULL;
const char *dname = NULL;
char *talloced = NULL;
- long offset = 0;
struct smb_filename *snaps_dname = NULL;
const char *snapdir = lp_parm_const_string(SNUM(handle->conn),
"ceph", "snapdir",
goto err_out;
}
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))
!= NULL)
{
struct smb_filename *smb_fname = NULL;
struct smb_Dir *dir_hnd = NULL;
const char *dname = NULL;
char *talloced = NULL;
- long offset = 0;
size_t nbands;
NTSTATUS status;
nbands = 0;
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))
!= NULL)
{
if (ISDOT(dname) || ISDOTDOT(dname)) {
struct smb_Dir *dir_hnd = NULL;
const char *dname = NULL;
char *talloced = NULL;
- long offset = 0;
uint64_t dfree;
uint64_t dsize;
bool ok;
return UINT64_MAX;
}
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))
!= NULL)
{
ok = fruit_tmsize_do_dirent(handle, &state, dname);
struct smb_Dir *dir_hnd = NULL;
const char *dname = NULL;
char *talloced = NULL;
- long offset = 0;
NTSTATUS status;
struct smb_filename *smb_fname = synthetic_smb_fname(talloc_tos(),
fsp->conn->connectpath,
SHADOW_COPY_LABEL *tlabels;
int ret;
- dname = ReadDirName(dir_hnd, &offset, NULL, &talloced);
+ dname = ReadDirName(dir_hnd, NULL, &talloced);
if (dname == NULL) {
break;
}
struct smb_filename *dir_smb_fname = NULL;
struct smb_Dir *dir_hnd = NULL;
const char *dname = NULL;
- long offset = 0;
char *talloced = NULL;
NTSTATUS status;
return status;
}
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))
!= NULL)
{
if (ISDOT(dname) || ISDOTDOT(dname)) {
{
const char *dname = NULL;
char *talloced = NULL;
- long offset = 0;
struct smb_Dir *dir_hnd = NULL;
struct files_struct *dirfsp = NULL;
int retval;
dirfsp = dir_hnd_fetch_fsp(dir_hnd);
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))) {
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))) {
struct smb_filename *atname = NULL;
struct smb_filename *smb_dname_full = NULL;
char *fullname = NULL;
struct smb_filename *at_fname = NULL;
const char *dname = NULL;
char *talloced = NULL;
- long dirpos = 0;
struct smb_Dir *dir_hnd = NULL;
struct files_struct *dirfsp = NULL;
int unlink_flags = 0;
dirfsp = dir_hnd_fetch_fsp(dir_hnd);
while ((dname = ReadDirName(
- dir_hnd, &dirpos, NULL, &talloced)) != NULL) {
+ dir_hnd, NULL, &talloced)) != NULL) {
struct smb_filename *smb_dname_full = NULL;
struct smb_filename *direntry_fname = NULL;
char *fullname = NULL;
}
/* Do a recursive delete. */
- RewindDir(dir_hnd,&dirpos);
+ RewindDir(dir_hnd);
while ((dname = ReadDirName(
- dir_hnd, &dirpos, NULL, &talloced)) != NULL) {
+ dir_hnd, NULL, &talloced)) != NULL) {
struct smb_filename *direntry_fname = NULL;
struct smb_filename *smb_dname_full = NULL;
char *fullname = NULL;
struct smb_Dir {
connection_struct *conn;
DIR *dir;
- long offset;
struct smb_filename *dir_smb_fname;
unsigned int file_number;
bool case_sensitive;
static int smb_Dir_destructor(struct smb_Dir *dir_hnd);
-static void SeekDir(struct smb_Dir *dirp, long offset);
-static long TellDir(struct smb_Dir *dirp);
-
#define INVALID_DPTR_KEY (-3)
/****************************************************************************
void dptr_RewindDir(struct dptr_struct *dptr)
{
- long offset;
- RewindDir(dptr->dir_hnd, &offset);
+ RewindDir(dptr->dir_hnd);
dptr->did_stat = false;
TALLOC_FREE(dptr->overflow.fname);
TALLOC_FREE(dptr->overflow.smb_fname);
}
-long dptr_TellDir(struct dptr_struct *dptr)
-{
- return TellDir(dptr->dir_hnd);
-}
-
unsigned int dptr_FileNumber(struct dptr_struct *dptr)
{
return dptr->dir_hnd->file_number;
char *dptr_ReadDirName(TALLOC_CTX *ctx,
struct dptr_struct *dptr,
- long *poffset,
SMB_STRUCT_STAT *pst)
{
struct smb_Dir *dir_hnd = dptr->dir_hnd;
if (dptr->has_wild) {
const char *name_temp = NULL;
char *talloced = NULL;
-
- name_temp = ReadDirName(dir_hnd, poffset, pst, &talloced);
+ name_temp = ReadDirName(dir_hnd, pst, &talloced);
if (name_temp == NULL) {
return NULL;
}
slashlen = ( dpath[pathlen-1] != '/') ? 1 : 0;
while (true) {
- long cur_offset;
SMB_STRUCT_STAT sbuf = { 0 };
char *dname = NULL;
bool isdots;
bool get_dosmode = get_dosmode_in;
bool ok;
- cur_offset = dptr_TellDir(dirptr);
- dname = dptr_ReadDirName(ctx, dirptr, &cur_offset, &sbuf);
+ dname = dptr_ReadDirName(ctx, dirptr, &sbuf);
- DBG_DEBUG("dir [%s] dirptr [0x%lx] offset [%ld] => "
+ DBG_DEBUG("dir [%s] dirptr [0x%lx] offset [%u] => "
"dname [%s]\n",
smb_fname_str_dbg(dir_hnd->dir_smb_fname),
(long)dirptr,
- cur_offset,
+ dirptr->dir_hnd->file_number,
dname ? dname : "(finished)");
if (dname == NULL) {
Don't check for veto or invisible files.
********************************************************************/
-const char *ReadDirName(struct smb_Dir *dir_hnd, long *poffset,
+const char *ReadDirName(struct smb_Dir *dir_hnd,
SMB_STRUCT_STAT *sbuf, char **ptalloced)
{
const char *n;
char *talloced = NULL;
connection_struct *conn = dir_hnd->conn;
- /* Cheat to allow . and .. to be the first entries returned. */
- if (((*poffset == START_OF_DIRECTORY_OFFSET) ||
- (*poffset == DOT_DOT_DIRECTORY_OFFSET)) &&
- (dir_hnd->file_number < 2))
- {
+ if (dir_hnd->file_number < 2) {
if (dir_hnd->file_number == 0) {
n = ".";
- *poffset = dir_hnd->offset = START_OF_DIRECTORY_OFFSET;
} else {
n = "..";
- *poffset = dir_hnd->offset = DOT_DOT_DIRECTORY_OFFSET;
}
dir_hnd->file_number++;
*ptalloced = NULL;
return n;
}
- if (*poffset == END_OF_DIRECTORY_OFFSET) {
- *poffset = dir_hnd->offset = END_OF_DIRECTORY_OFFSET;
- return NULL;
- }
-
- /* A real offset, seek to it. */
- SeekDir(dir_hnd, *poffset);
-
while ((n = vfs_readdirname(conn, dir_hnd->fsp, dir_hnd->dir, sbuf, &talloced))) {
/* Ignore . and .. - we've already returned them. */
if (ISDOT(n) || ISDOTDOT(n)) {
TALLOC_FREE(talloced);
continue;
}
- *poffset = dir_hnd->offset = SMB_VFS_TELLDIR(conn, dir_hnd->dir);
*ptalloced = talloced;
dir_hnd->file_number++;
return n;
}
- *poffset = dir_hnd->offset = END_OF_DIRECTORY_OFFSET;
*ptalloced = NULL;
return NULL;
}
Rewind to the start.
********************************************************************/
-void RewindDir(struct smb_Dir *dir_hnd, long *poffset)
+void RewindDir(struct smb_Dir *dir_hnd)
{
SMB_VFS_REWINDDIR(dir_hnd->conn, dir_hnd->dir);
dir_hnd->file_number = 0;
- dir_hnd->offset = START_OF_DIRECTORY_OFFSET;
- *poffset = START_OF_DIRECTORY_OFFSET;
-}
-
-/*******************************************************************
- Seek a dir.
-********************************************************************/
-
-static void SeekDir(struct smb_Dir *dirp, long offset)
-{
- if (offset == dirp->offset) {
- /*
- * Nothing to do
- */
- return;
- }
-
- if (offset == START_OF_DIRECTORY_OFFSET) {
- RewindDir(dirp, &offset);
- /*
- * Ok we should really set the file number here
- * to 1 to enable ".." to be returned next. Trouble
- * is I'm worried about callers using SeekDir(dirp,0)
- * as equivalent to RewindDir(). So leave this alone
- * for now.
- */
- } else if (offset == DOT_DOT_DIRECTORY_OFFSET) {
- RewindDir(dirp, &offset);
- /*
- * Set the file number to 2 - we want to get the first
- * real file entry (the one we return after "..")
- * on the next ReadDir.
- */
- dirp->file_number = 2;
- } else if (offset == END_OF_DIRECTORY_OFFSET) {
- ; /* Don't seek in this case. */
- } else {
- SMB_VFS_SEEKDIR(dirp->conn, dirp->dir, offset);
- }
- dirp->offset = offset;
-}
-
-/*******************************************************************
- Tell a dir position.
-********************************************************************/
-
-static long TellDir(struct smb_Dir *dir_hnd)
-{
- return(dir_hnd->offset);
}
struct files_below_forall_state {
NTSTATUS can_delete_directory_fsp(files_struct *fsp)
{
NTSTATUS status = NT_STATUS_OK;
- long dirpos = 0;
const char *dname = NULL;
char *talloced = NULL;
struct connection_struct *conn = fsp->conn;
return status;
}
- while ((dname = ReadDirName(dir_hnd, &dirpos, NULL, &talloced))) {
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))) {
struct smb_filename *smb_dname_full = NULL;
struct smb_filename *direntry_fname = NULL;
char *fullname = NULL;
const char *dname = NULL;
char *talloced = NULL;
char *unmangled_name = NULL;
- long curpos;
NTSTATUS status;
/* If we have a case-sensitive filesystem, it doesn't do us any
}
/* now scan for matching names */
- curpos = 0;
- while ((dname = ReadDirName(cur_dir, &curpos, NULL, &talloced))) {
+ while ((dname = ReadDirName(cur_dir, NULL, &talloced))) {
/* Is it dot or dot dot. */
if (ISDOT(dname) || ISDOTDOT(dname)) {
NTSTATUS status;
struct smb_filename *smb_fname = NULL;
struct smb_Dir *dir_hnd = NULL;
- long offset = 0;
if(*connect_path == '\0') {
TALLOC_FREE(frame);
goto out;
}
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))
!= NULL)
{
struct smb_filename *smb_dname =
struct referral *ref = NULL;
struct smb_filename *smb_fname = NULL;
struct smb_Dir *dir_hnd = NULL;
- long offset = 0;
NTSTATUS status;
if (jn_remain == 0) {
goto out;
}
- while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+ while ((dname = ReadDirName(dir_hnd, NULL, &talloced))
!= NULL)
{
struct smb_filename *smb_dname = NULL;
struct dptr_struct **dptr_ret);
void dptr_CloseDir(files_struct *fsp);
void dptr_RewindDir(struct dptr_struct *dptr);
-long dptr_TellDir(struct dptr_struct *dptr);
unsigned int dptr_FileNumber(struct dptr_struct *dptr);
bool dptr_has_wild(struct dptr_struct *dptr);
int dptr_dnum(struct dptr_struct *dptr);
bool dptr_case_sensitive(struct dptr_struct *dptr);
char *dptr_ReadDirName(TALLOC_CTX *ctx,
struct dptr_struct *dptr,
- long *poffset,
SMB_STRUCT_STAT *pst);
struct smb_Dir;
struct files_struct *dir_hnd_fetch_fsp(struct smb_Dir *dir_hnd);
const char *mask,
uint32_t attr,
struct smb_Dir **_dir_hnd);
-const char *ReadDirName(struct smb_Dir *dir_hnd, long *poffset,
+const char *ReadDirName(struct smb_Dir *dir_hnd,
SMB_STRUCT_STAT *sbuf, char **talloced);
-void RewindDir(struct smb_Dir *dir_hnd, long *poffset);
+void RewindDir(struct smb_Dir *dir_hnd);
NTSTATUS can_delete_directory(struct connection_struct *conn,
const char *dirname);
bool have_file_open_below(connection_struct *conn,
backup_priv = dptr_get_priv(fsp->dptr);
- DEBUG(3,("dptr_num is %d, mask = %s, attr = %x, dirptr=(0x%lX,%ld) "
+ DEBUG(3,("dptr_num is %d, mask = %s, attr = %x, dirptr=(0x%lX) "
"backup_priv = %d\n",
dptr_num, mask, dirtype,
(long)fsp->dptr,
- dptr_TellDir(fsp->dptr),
(int)backup_priv));
/* We don't need to check for VOL here as this is returned by
resume_name,
last_name_sent);
if (!sequential) {
- long offset = 0;
struct stat_ex st;
char *name = NULL;
bool found = false;
while ((name = dptr_ReadDirName(talloc_tos(),
fsp->dptr,
- &offset,
&st)) != NULL) {
found = smbd_dptr_name_equal(fsp->dptr,
resume_name,
return NT_STATUS_UNSUCCESSFUL;
}
- vfs->currentdir_offset = 0;
-
TALLOC_FREE(smb_fname);
printf("opendir: ok\n");
return NT_STATUS_OK;
}
dname = ReadDirName(vfs->currentdir,
- &vfs->currentdir_offset,
NULL,
&talloced);
if (dname == NULL) {
}
TALLOC_FREE(vfs->currentdir);
- vfs->currentdir_offset = 0;
printf("closedir: ok\n");
return NT_STATUS_OK;
errno = err;
return NT_STATUS_UNSUCCESSFUL;
}
- vfs->currentdir_offset = 0;
while (true) {
/* ReadDirName() returns Windows "encoding" */
dname = ReadDirName(vfs->currentdir,
- &vfs->currentdir_offset,
NULL,
&dname_talloced);
if (dname == NULL) {
TALLOC_FREE(translated);
TALLOC_FREE(smb_fname);
TALLOC_FREE(vfs->currentdir);
- vfs->currentdir_offset = 0;
return status;
}
uint64_t mid;
struct files_struct *files[1024];
struct smb_Dir *currentdir;
- long currentdir_offset;
void *data;
size_t data_size;
};