Implementations of VFS System Calls

For the sake of brevity, we cannot discuss the implementation of all the VFS system calls listed in Table 12-1. However, it could be useful to sketch out the implementation of a few system calls, just to show how VFS's data structures interact.

Let's reconsider the example proposed at the beginning of this chapter: a user issues a shell command that copies the MS-DOS file /floppy/TEST to the Ext2 file /tmp/test. The command shell invokes an external program like cp, which we assume executes the following code fragment:

outf = open("/tmp/test", O_WRONLY | O_CREAT | O_TRUNC, 0600); do {

len = read(inf, buf, 4096); write(outf, buf, len); } while (len); close(outf); close(inf);

Actually, the code of the real cp program is more complicated, since it must also check for possible error codes returned by each system call. In our example, we just focus our attention on the "normal" behavior of a copy operation.

Was this article helpful?

0 0

Post a comment