-1

I have gone through some of the links Which talks about fastest way of copying files in windows using FILE_FLAG_NO_BUFFERING and FILE_FLAG_OVERLAPPED . It also talks about how request made for read and write opeartions with BUFFER SIZE as 256KB and 128KB are faster than 1Mb .The link for that is :- Explanation for tiny reads (overlapped, buffered) outperforming large contiguous reads? I am also loking for a Similar method in linux Which allows me to copy the content of my DVD to Hard Disc in a fast Way . So I wanted to know Is there some file operation flags in Linux which would provide me the best result or Which way of Copy in Linux is the best ? My codes are all in c++.

Community
  • 1
  • 1
Invictus
  • 4,028
  • 10
  • 50
  • 80
  • I dont know i see a down vote by a User without any specific comment or reason for doing so ? – Invictus Jun 18 '12 at 15:34
  • system( "dd if=/dev/dvd of=/path/to/img bs=16384" ) should be plenty fast – stijn Jun 18 '12 at 15:41
  • @stijn What I understand is that its a system call but can you please explain me the above line and What is the `bs` there ? – Invictus Jun 18 '12 at 15:46
  • @stijn My DVD will have a Playlist which will contain some files . I want to copy say particular files from those playlist . Will it be still that efficient ? – Invictus Jun 18 '12 at 15:50
  • dd (http://en.wikipedia.org/wiki/Dd_(Unix) or man dd) does a raw copy so no, you cannot use it for copying only a part of a dvd – stijn Jun 18 '12 at 15:52
  • Those links are for optimizing disk-to-disk copying. When copying from a DVD, reading will be the bottleneck. Writing to the hard disk will have no problems keeping up with that. – Bo Persson Jun 18 '12 at 18:41
  • @Bo Persson What do you think would be a best way to copy in case of Linux ? – Invictus Jun 18 '12 at 19:06
  • @Ritesh - I just don't think there is a problem to solve. Reading from the DVD is the bottleneck, and that will limit the speed of copying. You cannot do much about that. – Bo Persson Jun 18 '12 at 19:10

1 Answers1

1

Mount your DVD, open() the files you want to copy, and use sendfile(). If you'd like to copy the full DVD, you might also try to open() the DVD's /dev entry and pass that descriptor to sendfile().

$ man 2 sendfile

"sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space."

Răzvan Cojocaru
  • 883
  • 9
  • 12