2004-10-24 14:18:03 +00:00
/*
Unix SMB / CIFS implementation .
POSIX NTVFS backend - seek
Copyright ( C ) Andrew Tridgell 2004
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2004-11-05 07:24:25 +00:00
# include "includes.h"
2004-10-24 14:18:03 +00:00
# include "vfs_posix.h"
/*
seek in a file
*/
NTSTATUS pvfs_seek ( struct ntvfs_module_context * ntvfs ,
2006-03-10 20:49:20 +00:00
struct ntvfs_request * req ,
union smb_seek * io )
2004-10-24 14:18:03 +00:00
{
struct pvfs_state * pvfs = ntvfs - > private_data ;
struct pvfs_file * f ;
2004-11-08 03:54:12 +00:00
struct pvfs_file_handle * h ;
2004-10-24 14:18:03 +00:00
NTSTATUS status ;
2006-03-12 22:48:25 +00:00
f = pvfs_find_fd ( pvfs , req , io - > lseek . in . file . fnum ) ;
2004-10-24 14:18:03 +00:00
if ( ! f ) {
return NT_STATUS_INVALID_HANDLE ;
}
2004-11-08 03:54:12 +00:00
h = f - > handle ;
2004-10-24 14:18:03 +00:00
status = NT_STATUS_OK ;
2006-03-10 20:49:20 +00:00
switch ( io - > lseek . in . mode ) {
2004-10-24 14:18:03 +00:00
case SEEK_MODE_START :
2006-03-10 20:49:20 +00:00
h - > seek_offset = io - > lseek . in . offset ;
2004-10-24 14:18:03 +00:00
break ;
case SEEK_MODE_CURRENT :
2006-03-10 20:49:20 +00:00
h - > seek_offset + = io - > lseek . in . offset ;
2004-10-24 14:18:03 +00:00
break ;
case SEEK_MODE_END :
2004-11-08 03:54:12 +00:00
status = pvfs_resolve_name_fd ( pvfs , h - > fd , h - > name ) ;
2006-03-10 20:49:20 +00:00
h - > seek_offset = h - > name - > st . st_size + io - > lseek . in . offset ;
2004-10-24 14:18:03 +00:00
break ;
}
2006-03-10 20:49:20 +00:00
io - > lseek . out . offset = h - > seek_offset ;
2004-10-24 14:18:03 +00:00
return status ;
}