FreeBSD/sbin/restore/dirs.c
/*
 * Seek to an entry in a directory.
 * Only values returned by rst_telldir should be passed to rst_seekdir.
 * This routine handles many directories in a single file.
 * It takes the base of the directory in the file, plus
 * the desired seek offset into it.
 */
Seek to an entry in a directory.
Only values returned by rst_telldir should be passed to rst_seekdir.
This routine handles many directories in a single file.
It takes the base of the directory in the file, plus
the desired seek offset into it.
Seek to an entry in a directory . Only values returned by rst_telldir should be passed to rst_seekdir . This routine handles many directories in a single file . It takes the base of the directory in the file plus the desired seek offset into it .
static void
rst_seekdir(RST_DIR *dirp, long loc, long base)
{
	if (loc == rst_telldir(dirp))
		return;
	loc -= base;
	if (loc < 0)
		fprintf(stderr, "bad seek pointer to rst_seekdir %ld\n", loc);
	(void) lseek(dirp->dd_fd, base + rounddown2(loc, DIRBLKSIZ), SEEK_SET);
	dirp->dd_loc = loc & (DIRBLKSIZ - 1);
	if (dirp->dd_loc != 0)
		dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ);
}
static void rst_seekdir ( RST_DIR * dirp , long loc , long base ) { if ( loc == rst_telldir ( dirp ) ) return ; loc -= base ; if ( loc < 0 ) fprintf ( stderr , " \n " , loc ) ; ( void ) lseek ( dirp -> dd_fd , base + rounddown2 ( loc , DIRBLKSIZ ) , SEEK_SET ) ; dirp -> dd_loc = loc & ( DIRBLKSIZ - 1 ) ; if ( dirp -> dd_loc != 0 ) dirp -> dd_size = read ( dirp -> dd_fd , dirp -> dd_buf , DIRBLKSIZ ) ; }
Seek to an entry in a directory.
Seek to an entry in a directory .