Sponsored Content
Top Forums Programming locate holes in a sparse file. Post 302317752 by fpmurphy on Wednesday 20th of May 2009 12:06:31 AM
Old 05-20-2009
The only Unix filesystem I am aware of that currently supports the functionality you are looking for is ZFS using the SEEK_HOLE and SEEK_DATA whence options to lseek(). From the Solaris lseek() man page:

- If whence is SEEK_HOLE, the offset of the start of the
next hole greater than or equal to the supplied offset
is returned.

- If whence is SEEK_DATA, the file pointer is set to the
start of the next non-hole file region greater than or
equal to the supplied offset.

There is also the Andreas Dilger FIEMAP extend mapping ioctl() proposal which I am aware of but have no real experience with. An implementation for Linux ext3 and ext4 filesystems is available. Do a Web search for FIEMAP and SEEK_HOLE for more information or read the Linux 2.6 kernel documentation file .../kernel/Documentation/filesystems/fiemap.txt

Last edited by fpmurphy; 05-20-2009 at 01:20 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

sparse files

what are sparse files? (2 Replies)
Discussion started by: areef4u
2 Replies

2. Shell Programming and Scripting

How to copy file and locate in new folder?

Hi All, Please advise me how to make a copy of file from a list and store in one particular location? For example , I have aaa.txt which contains as below, But, those *usg files might be randomly store in different location.... > cat aaa.txt adc.usg dfdjkf.usg ugjfk.usg And I want... (3 Replies)
Discussion started by: cedrichiu
3 Replies

3. UNIX for Dummies Questions & Answers

URGENT! How to copy with holes?

I need to write a program that reads in data from a file with holes and copy the file. the cp command copies the file but the holes use disk blocks then; but when this progrm copies the file the new file should not have hose extra blocks. the file should be copied with holes. PLZZ help! (2 Replies)
Discussion started by: kominbhai
2 Replies

4. Shell Programming and Scripting

Locate file and path

Hi, I am writing a script to manage my server a bit better, but want to make it so if a path changes I dont need to update the script. I was thinking of doing something like if then echo -e "psa/admin/sbin located " else echo "no luck chump" fi but would need to... (2 Replies)
Discussion started by: foz
2 Replies

5. UNIX for Advanced & Expert Users

Locate text in file then remove and replace

I'm trying to locate a block of text in a file, remove it and then replace with a new block. I can find the first line number that the text starts on using grep -n. I then need to locate the ending line by searching for the string "}" that follows the line I found. Here's the steps I need to... (1 Reply)
Discussion started by: lchandle
1 Replies

6. Shell Programming and Scripting

File creating in another path.. application unable to locate

I am submitting a concurrent program (of HOST tyme) from Oracle apps screen, The MAIN shell program submits another program, (child) which is also a Shell program. The child writes data to log file. Now the main program, read the log and do some calculations and sends the data to user through... (1 Reply)
Discussion started by: Pradeep Garine
1 Replies

7. Shell Programming and Scripting

Convert a matrix to sparse representation

Hi All, I have a matrix stored in a file matrix.mtx and looks like this: 1 0.5 0.33 0.25 0 0.33 0.25 0.2 0 0 0 0.16 0 0 0 0.14 I want to convert this matrix to its sparse representation like the one give below (sparse_matrix.mtx). This means that above matrix has been converted to its... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

8. Shell Programming and Scripting

using find but avoiding sparse files

I am no Unix administrator...I live in windows land. I wrote a script to find files of certain names and process them but was later advised to avoid checking sparse files since it would use up a lot of resources and the files I was looking for were not there. How do I avoid doing the find on... (3 Replies)
Discussion started by: shellFun
3 Replies

9. Programming

C Data Structure to represent a Sparse Array

Which data structure will be most appropriate to represent a sparse array? (1 Reply)
Discussion started by: rupeshkp728
1 Replies

10. UNIX for Dummies Questions & Answers

Locate the column names with their values in the file and the printing the same in the other file

I have text file in Linux with two rows : first row conmtain the column nam and the second row contain its value .I nned to fetch few columns first and then redirect the data of those colum in the another file. Any ideas?? (1 Reply)
Discussion started by: Anamica
1 Replies
MPAGE_READPAGES(9)						   The Linux VFS						MPAGE_READPAGES(9)

NAME
mpage_readpages - populate an address space with some pages & start reads against them SYNOPSIS
int mpage_readpages(struct address_space * mapping, struct list_head * pages, unsigned nr_pages, get_block_t get_block); ARGUMENTS
mapping the address_space pages The address of a list_head which contains the target pages. These pages have their ->index populated and are otherwise uninitialised. The page at pages->prev has the lowest file offset, and reads should be issued in pages->prev to pages->next order. nr_pages The number of pages at *pages get_block The filesystem's block mapper function. DESCRIPTION
This function walks the pages and the blocks within each page, building and emitting large BIOs. If anything unusual happens, such as: - encountering a page which has buffers - encountering a page which has a non-hole after a hole - encountering a page with non-contiguous blocks then this code just gives up and calls the buffer_head-based read function. It does handle a page which has holes at the end - that is a common case: the end-of-file on blocksize < PAGE_CACHE_SIZE setups. BH_BOUNDARY EXPLANATION There is a problem. The mpage read code assembles several pages, gets all their disk mappings, and then submits them all. That's fine, but obtaining the disk mappings may require I/O. Reads of indirect blocks, for example. So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be SUBMITTED IN THE FOLLOWING ORDER
12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 because the indirect block has to be read to get the mappings of blocks 13,14,15,16. Obviously, this impacts performance. So what we do it to allow the filesystem's get_block function to set BH_Boundary when it maps block 11. BH_Boundary says: mapping of the block after this one will require I/O against a block which is probably close to this one. So you should push what I/O you have currently accumulated. This all causes the disk requests to be issued in the correct order. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 MPAGE_READPAGES(9)
All times are GMT -4. The time now is 11:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy