This provides functionality somewhat similar to mmap() but using read(). * It gives sliding window access to a file. mmap() is not used because of * the possibility of another program (such as a mailer) truncating the * file thus giving us a SIGBUS. */
| 216 | * the possibility of another program (such as a mailer) truncating the |
| 217 | * file thus giving us a SIGBUS. */ |
| 218 | struct map_struct *map_file(int fd, OFF_T len, int32 read_size, int32 blk_size) |
| 219 | { |
| 220 | struct map_struct *map; |
| 221 | |
| 222 | map = new0(struct map_struct); |
| 223 | |
| 224 | if (blk_size && (read_size % blk_size)) |
| 225 | read_size += blk_size - (read_size % blk_size); |
| 226 | |
| 227 | map->fd = fd; |
| 228 | map->file_size = len; |
| 229 | map->def_window_size = ALIGNED_LENGTH(read_size); |
| 230 | |
| 231 | return map; |
| 232 | } |
| 233 | |
| 234 | |
| 235 | /* slide the read window in the file */ |
no outgoing calls
no test coverage detected