blob: 7181cb3ce47be233b93d2830ee68f1fa8d77ce56 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Glenn L McGrath95ebf612001-10-25 14:18:08 +00002/*
"Robert P. J. Day"801ab142006-07-12 07:56:04 +00003 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Glenn L McGrath95ebf612001-10-25 14:18:08 +00004 */
5
Glenn L McGrath237ae422002-11-03 14:05:15 +00006#include "libbb.h"
7#include "unarchive.h"
8
Denys Vlasenko0a130d52009-08-28 21:09:51 +02009void FAST_FUNC seek_by_jump(int fd, off_t amount)
Glenn L McGrath95ebf612001-10-25 14:18:08 +000010{
Denis Vlasenkoadc772a2008-07-20 17:10:43 +000011 if (amount
Denys Vlasenko0a130d52009-08-28 21:09:51 +020012 && lseek(fd, amount, SEEK_CUR) == (off_t) -1
Denis Vlasenkoadc772a2008-07-20 17:10:43 +000013 ) {
Denis Vlasenko1af00ed2008-04-05 02:44:30 +000014 if (errno == ESPIPE)
Denys Vlasenko0a130d52009-08-28 21:09:51 +020015 seek_by_read(fd, amount);
Denis Vlasenko1af00ed2008-04-05 02:44:30 +000016 else
Denis Vlasenkoe1a0d482006-10-20 13:28:22 +000017 bb_perror_msg_and_die("seek failure");
Glenn L McGrath95ebf612001-10-25 14:18:08 +000018 }
Eric Andersen2276d832002-07-11 11:11:56 +000019}