From mboxrd@z Thu Jan 1 00:00:00 1970 From: linux@horizon.com Subject: SEEK_HOLE and SEEK_DATA Date: 2 Feb 2006 04:03:49 -0500 Message-ID: <20060202090349.31898.qmail@science.horizon.com> Return-path: Received: from science.horizon.com ([192.35.100.1]:35144 "HELO science.horizon.com") by vger.kernel.org with SMTP id S1423394AbWBBJD5 (ORCPT ); Thu, 2 Feb 2006 04:03:57 -0500 To: linux-fsdevel@vger.kernel.org Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Solaris 10 has added a moderately useful new feature... lseek now supports whence = 3 (SEEK_DATA) and 4 (SEEK_HOLE). What these do is advance the file pointer to the start of the next run of the appropriate kind past the given (absolute) offset. This is, of course, to make backing up and copying sparse files more efficient. I'm still figuring out the fine details of semantics. EOF is considered the start of a hole. If the seek position is past EOF, they return ENXIO. I'm still trying to figure out if they search > the given offset or >=. Reading the code, it actually looks like lseek(fd, 13, SEEK_DATA) will return 0 on a non-sparse file, because they round down to blocks and then search by blocks. Not that this affects the usual case where you start at offset 0 and alternate SEEK_DATA/SEEK_HOLE to find ranges to copy. I was just wondering if it's an extension worth adopting.