* OT: simple file operations in C
@ 2003-03-10 3:33 darren
2003-03-10 8:02 ` Valdis.Kletnieks
0 siblings, 1 reply; 9+ messages in thread
From: darren @ 2003-03-10 3:33 UTC (permalink / raw)
To: reiserfs-list
Hi all,
Sorry for being slightly off-topic.
I want my program to be able copy, move and delete files, but i cannot seem to find any available functions or system calls to do this.
I don't really want to use shell by invoking "exec("mv XX YYY");, and i also do not want to fopen 2 files and then do multiple freads and fwrites.
Any suggestions?
Regards
Darren
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: OT: simple file operations in C
2003-03-10 3:33 OT: simple file operations in C darren
@ 2003-03-10 8:02 ` Valdis.Kletnieks
2003-03-10 11:47 ` Heinz-Josef Claes
0 siblings, 1 reply; 9+ messages in thread
From: Valdis.Kletnieks @ 2003-03-10 8:02 UTC (permalink / raw)
To: darren; +Cc: reiserfs-list
[-- Attachment #1: Type: text/plain, Size: 518 bytes --]
On Mon, 10 Mar 2003 03:33:42 GMT, darren <teodarren@myrealbox.com> said:
> I want my program to be able copy, move and delete files, but i cannot seem t
o find any available functions or system calls to do this.
For move and delete, you want the rename() and unlink() system calls.
For copying, you might want to skip the stdio fopen() and friends, and
use open()/read()/write()/close(). You may need chmod() and utime() if you
want to be preserving filemode/timestamps.
Google for '+linux +programming +guide'.
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: simple file operations in C
2003-03-10 8:02 ` Valdis.Kletnieks
@ 2003-03-10 11:47 ` Heinz-Josef Claes
2003-03-10 22:35 ` Zygo Blaxell
0 siblings, 1 reply; 9+ messages in thread
From: Heinz-Josef Claes @ 2003-03-10 11:47 UTC (permalink / raw)
To: reiserfs-list; +Cc: darren
Am Mon, 2003-03-10 um 09.02 schrieb Valdis.Kletnieks@vt.edu:
> On Mon, 10 Mar 2003 03:33:42 GMT, darren <teodarren@myrealbox.com> said:
>
> > I want my program to be able copy, move and delete files, but i cannot seem t
> o find any available functions or system calls to do this.
>
> For move and delete, you want the rename() and unlink() system calls.
>
> For copying, you might want to skip the stdio fopen() and friends, and
> use open()/read()/write()/close(). You may need chmod() and utime() if you
> want to be preserving filemode/timestamps.
>
> Google for '+linux +programming +guide'.
That's ok. But if you want to copy big files it's a good idea to have a
look at mmap(2).
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: simple file operations in C
2003-03-10 11:47 ` Heinz-Josef Claes
@ 2003-03-10 22:35 ` Zygo Blaxell
0 siblings, 0 replies; 9+ messages in thread
From: Zygo Blaxell @ 2003-03-10 22:35 UTC (permalink / raw)
To: reiserfs-list
In article <1047296851.1036.2.camel@kakapo.schnulli.de>,
Heinz-Josef Claes <hjclaes@web.de> wrote:
>Am Mon, 2003-03-10 um 09.02 schrieb Valdis.Kletnieks@vt.edu:
>> On Mon, 10 Mar 2003 03:33:42 GMT, darren <teodarren@myrealbox.com> said:
>>
>> > I want my program to be able copy, move and delete files, but i cannot seem t
>> o find any available functions or system calls to do this.
>>
>> For move and delete, you want the rename() and unlink() system calls.
You might want to try sendfile(), which is Linux-specific, but basically
transfers the contents of one FD to another FD entirely in kernel-space.
It's designed for sending files over a socket, but I see no reason why
the destination FD couldn't be a file. On the other hand, I've never
used it myself.
>> For copying, you might want to skip the stdio fopen() and friends, and
>> use open()/read()/write()/close(). You may need chmod() and utime() if you
>> want to be preserving filemode/timestamps.
>>
>> Google for '+linux +programming +guide'.
>
>That's ok. But if you want to copy big files it's a good idea to have a
>look at mmap(2).
mmap() can be slow, especially for reading files sequentially. read()
usually comes with support from the OS and filesystem for read-ahead
and large I/O transfers. These make a huge difference in performance,
and more than compensate for the extra CPU and memory overhead of copying
the data. mmap() usually uses the same mechanism as swap, and is oriented
toward reading single pages. mmap() is good for exectuables and shared
memory (e.g. lock tables), not for reading or writing big files
sequentially.
mmap() can be annoying to use, especially if the file might be modified while
you are copying it. All errors are reported by your process receiving a
SIGBUS. If the file is bigger than a few hundred megabytes you will still
need a loop to map the file in multiple small pieces. Not all filesystems
support mmap(), which means you'll usually need to be able to fall back
to read() anyway. read() and mmap() may also have different atomicity and
consistency characteristics.
Modern CPU's can copy data in memory in multiples of a gigabyte per
second (and five-year-old CPU's can do hundreds of megabytes easily).
If your disks are slower than this, you will probably find that read()
is so much faster than mmap() (I usually get read() about 10 times faster
than mmap()) that you'll not bother with mmap().
If you really need speed, try a few different techniques and do a
benchmark on the filesystem, OS, and hardware you will be using.
--
Zygo Blaxell (Laptop) <zblaxell@feedme.hungrycats.org>
GPG = D13D 6651 F446 9787 600B AD1E CCF3 6F93 2823 44AD
^ permalink raw reply [flat|nested] 9+ messages in thread
* OT: simple file operations in C
@ 2003-03-10 3:34 darren
0 siblings, 0 replies; 9+ messages in thread
From: darren @ 2003-03-10 3:34 UTC (permalink / raw)
To: reiserfs-list
Hi all,
Sorry for being slightly off-topic.
I want my program to be able copy, move and delete files, but i cannot seem to find any available functions or system calls to do this.
I don't really want to use shell by invoking "exec("mv XX YYY");, and i also do not want to fopen 2 files and then do multiple freads and fwrites.
Any suggestions?
Regards
Darren
^ permalink raw reply [flat|nested] 9+ messages in thread* OT: simple file operations in C
@ 2003-03-10 3:33 darren
2003-03-10 4:37 ` Manuel Krause
0 siblings, 1 reply; 9+ messages in thread
From: darren @ 2003-03-10 3:33 UTC (permalink / raw)
To: reiserfs-list
Hi all,
Sorry for being slightly off-topic.
I want my program to be able copy, move and delete files, but i cannot seem to find any available functions or system calls to do this.
I don't really want to use shell by invoking "exec("mv XX YYY");, and i also do not want to fopen 2 files and then do multiple freads and fwrites.
Any suggestions?
Regards
Darren
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: OT: simple file operations in C
2003-03-10 3:33 darren
@ 2003-03-10 4:37 ` Manuel Krause
2003-03-10 12:20 ` Hans Reiser
2003-03-10 13:57 ` darren
0 siblings, 2 replies; 9+ messages in thread
From: Manuel Krause @ 2003-03-10 4:37 UTC (permalink / raw)
To: darren; +Cc: reiserfs-list
On 03/10/2003 04:33 AM, darren wrote:
> Hi all,
>
> Sorry for being slightly off-topic.
>
> I want my program to be able copy, move and delete files, but i cannot seem to find any available functions or system calls to do this.
>
> I don't really want to use shell by invoking "exec("mv XX YYY");, and i also do not want to fopen 2 files and then do multiple freads and fwrites.
>
> Any suggestions?
If you will never send your original mail once again someone may answer
-- otherways you are definitely SPAMMING!!! and you should be excluded.
Manuel
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: OT: simple file operations in C
2003-03-10 4:37 ` Manuel Krause
@ 2003-03-10 12:20 ` Hans Reiser
2003-03-10 13:57 ` darren
1 sibling, 0 replies; 9+ messages in thread
From: Hans Reiser @ 2003-03-10 12:20 UTC (permalink / raw)
To: Manuel Krause; +Cc: darren, reiserfs-list
On 03/10/2003 04:33 AM, darren wrote:
> Hi all,
>
> Sorry for being slightly off-topic.
>
> I want my program to be able copy, move and delete files, but i cannot
> seem to find any available functions or system calls to do this.
>
> I don't really want to use shell by invoking "exec("mv XX YYY");, and
> i also do not want to fopen 2 files and then do multiple freads and
> fwrites.
>
> Any suggestions?
Unlink and rename will delete and remove, but copying you cannot do in
Unix in a single system call until we release sys_reiser4()
--
Hans
^ permalink raw reply [flat|nested] 9+ messages in thread* RE: OT: simple file operations in C
2003-03-10 4:37 ` Manuel Krause
2003-03-10 12:20 ` Hans Reiser
@ 2003-03-10 13:57 ` darren
1 sibling, 0 replies; 9+ messages in thread
From: darren @ 2003-03-10 13:57 UTC (permalink / raw)
To: 'Manuel Krause'; +Cc: 'reiserfs-list'
Hi all and Manuel,
Sorry my mail was sent multiple times (that's what happens when you use
the http version of myrealbox sometimes).
Anyway, for the newbies who may have the same problem as me:
File operations:
Move: rename
Delete: Unlink
Copy: no choice...must open read write close.
I am just curious, but will the link command work for a file copy?
Regards
Darren
-----Original Message-----
From: Manuel Krause [mailto:manuelkrause@netscape.net]
Sent: Monday, March 10, 2003 12:37 PM
To: darren
Cc: reiserfs-list
Subject: Re: OT: simple file operations in C
On 03/10/2003 04:33 AM, darren wrote:
> Hi all,
>
> Sorry for being slightly off-topic.
>
> I want my program to be able copy, move and delete files, but i cannot
seem to find any available functions or system calls to do this.
>
> I don't really want to use shell by invoking "exec("mv XX YYY");, and
i also do not want to fopen 2 files and then do multiple freads and
fwrites.
>
> Any suggestions?
If you will never send your original mail once again someone may answer
-- otherways you are definitely SPAMMING!!! and you should be excluded.
Manuel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-03-10 22:35 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-10 3:33 OT: simple file operations in C darren
2003-03-10 8:02 ` Valdis.Kletnieks
2003-03-10 11:47 ` Heinz-Josef Claes
2003-03-10 22:35 ` Zygo Blaxell
-- strict thread matches above, loose matches on Subject: below --
2003-03-10 3:34 darren
2003-03-10 3:33 darren
2003-03-10 4:37 ` Manuel Krause
2003-03-10 12:20 ` Hans Reiser
2003-03-10 13:57 ` darren
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.