1. Question on writing c program implement cp function using UNIX system calls - read, write, etc.
I need to write a c program that will perform like the cp command in UNIX
and copy one file to another. I need to use the UNIX system calls read(),
write(), open(), close(). I know how to open the source file for read access
and destination file for write access with open(), but I am unsure of how to
use read() and write().
I know read takes my file descriptor (fd) of the source file I opened as its
1st arguement. For the second, I need to put those bytes in some sort of
buffer right? Could I just write them directly to the destination file
instead of storing into a buffer? Well if I have to make a buffer for input
I read in I do this:
c = (char *) calloc(100, sizeof(char));
Is that right? If I do this will it work for all files whether they are
binary or ascii files?
The 3rd arg of read() takes in how many bytes to read, how do I tell it to
read in the entire source file?
So for read, this is what I have so far: read(fd, c, ????) where fd is my
source file descriptor and c as define above.
As for write, I have: write(fd2, ???, ???) where fd2 is the file descriptor
of my destination file. How do I specify it to write what I read from the
input source file and write all of those bytes inputted? Thanks for any
help.
2. en0 is deaf on a B50 in AIX 4.2.1
3. Need help writing C program using UNIX system calls (read, write, etc) that copies files
4. Creating a concurrent server... (again?)
5. system call read(), write() thread-safe?
6. cvs up
7. System() Call & Writing to Spawned Process' STDIN
8. Trying to read in a file line at a time, and output each entry to a text file in different order.
9. Read & Read/Write Groups
10. how to read disk read & write i/o through a c/c++ program ?
11. Sockets: write() writes OK, yet read() reads garbage...?
12. How I could add a new system call to linux or modify a system calls
13. How to use open system call in a new system call