mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
smbd: Simplify SeekDir() with an early return
Review with git show -w Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
a1d348fd5e
commit
5c19e6ca75
@ -1686,31 +1686,36 @@ void RewindDir(struct smb_Dir *dir_hnd, long *poffset)
|
||||
|
||||
void SeekDir(struct smb_Dir *dirp, long offset)
|
||||
{
|
||||
if (offset != dirp->offset) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user