apue-exercises icon indicating copy to clipboard operation
apue-exercises copied to clipboard

SEEK_HOLE/DATA problem

Open miluchen opened this issue 6 years ago • 3 comments

https://github.com/banool/apue-exercises/blob/2ecce52040fdef5a27f42d51b1dcceca33416d70/code/04.06.c#L23

Not sure whether it works on other systems, but... I am using ubuntu 18.04. lseek(fd, offset, SEEK_HOLE/SEEK_DATA) seems to change the file offset to the offset of the block that contains the hole or data.

For example, suppose I have a file containing "abc" followed by a hole with length 16*1024 bytes. If the file block size if 4096, lseek(fd, 0, SEEK_HOLE) would return 4096 instead of 3.

miluchen avatar Mar 29 '20 22:03 miluchen

I realized I'm coming here 3 years late hahaha but I don't suppose you ever figured this out?

banool avatar Apr 11 '23 12:04 banool

I realized I'm coming here 3 years late hahaha but I don't suppose you ever figured this out?

I need to refresh my memory, but it's very likely I didn't figure this out, otherwise, I would have closed the ticket 🤔

miluchen avatar Apr 11 '23 16:04 miluchen

Okay cool, if I get time I can take a look into it. I probably won't though, so we can check back in in a few years hahahah.

banool avatar Apr 11 '23 17:04 banool