Re: any one knows how to truncate a file from its begining ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 23, 2008 at 1:14 AM, Raz <raziebe@xxxxxxxxx> wrote:
> I  think XFS can do it . it has some un/reserve  space ioctl.
> 3521        /*
> 3522         * XFS_IOC_RESVSP and XFS_IOC_UNRESVSP will reserve or unreserve
> 3523         * file space.
> 3524         * These calls do NOT zero the data space allocated to the file,
> 3525         * nor do they change the file size.
> 3526

But these would be similar to fallocate( ) which I believe is
tangential to your original problem.

I think using seek would be the best option.
Also, when you say block a,b,c,d.....

You will not be aware of the block allcation of the file system used
by it internally.
You can just work on offsets and for that I believe that fseek would
be the best option.
        *
> 3527         * XFS_IOC_ALLOCSP and XFS_IOC_FREESP will allocate and free file
> 3528         * space.
> 3529         * These calls cause the new file data to be zeroed and the file
> 3530         * size to be changed.
> 3531         */
>
>
> On Wed, Oct 22, 2008 at 8:07 PM, Karl Tatgenhorst
> <karl.tatgenhorst@xxxxxxxxx> wrote:
>> if it is a binary file, use dd and figure out the offset to start from
>> (man dd will help). If it is a text file just use some perl like this:
>>
>>
>>
>> #open your file here
>>
>> $count=0;
>> $start_removing= 100; ###starting at 100
>> $stop_removing= 300; ###end of block to remove
>> while<FILE> {
>>   $count++;
>>   if(100 < $count < 300) {
>>      next;
>>   }
>>   print $_
>> }
>>
>> both methods create a copy of the file and you can just copy your file over it.
>>
>> good luck
>>
>>
>> On Wed, Oct 22, 2008 at 12:31 PM, Raz <raziebe@xxxxxxxxx> wrote:
>>> no.
>>> I mean i want to remove a portion of the file :
>>> if a file is composed of : a,b,c,d blocks.
>>> I want to be able to remove from the **disk** block c or block a.
>>> ftruncate remove the end.
>>>
>>> On Wed, Oct 22, 2008 at 7:24 PM, Manish Katiyar <mkatiyar@xxxxxxxxx> wrote:
>>>> On Wed, Oct 22, 2008 at 10:42 PM, Raz <raziebe@xxxxxxxxx> wrote:
>>>>> or a file system that can do it ?
>>>>
>>>> What does that mean ???
>>>>
>>>> just doing
>>>>
>>>> $ > filename
>>>> on command line will truncate it............or probably "man
>>>> ftruncate" can help you.
>>>>
>>>> Thanks -
>>>> Manish
>>>>
>>>>
>>>>>
>>>>> thank you
>>>>> raz
>>>>>
>>>>> --
>>>>> To unsubscribe from this list: send an email with
>>>>> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>>>>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>>>>
>>>>>
>>>>
>>>
>>> --
>>> To unsubscribe from this list: send an email with
>>> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>>
>>>
>>
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>



-- 
Regards,
Sandeep.





 	
"To learn is to change. Education is a process that changes the learner."

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux