Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

Advanced Programming in the UNIX® Environment: UNIX File I/O

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Learn about the traditional UNIX I/O functions. You will see how to apply these functions when using your UNIX system.

3.1 Introduction

We'll start our discussion of the Unix system by describing the functions available for file I/O—open a file, read a file, write a file, and so on. Most Unix file I/O can be performed using only five functions: open, read, write, lseek, and close. We then examine the effect of different buffer sizes on the read and write functions.

The functions described in this chapter are often referred to as unbuffered I/O (in contrast to the standard I/O routines, which we describe in Chapter 5). The term unbuffered refers to the fact that each read or write invokes a system call in the kernel. These unbuffered I/O functions are not part of ANSI C, but are part of POSIX.1 and XPG3.

Whenever we describe the sharing of resources between multiple processes, the concept of an atomic operation becomes important. We examine this concept with regard to file I/O and the arguments to the open function. This leads to a discussion of how files are shared between multiple processes and the kernel data structures involved. Once we've described these features, we describe the dup, fcntl, and ioctl functions.

  • Share ThisShare This
  • Save To Your Account

Discussions

comments powered by Disqus

Related Resources

What Apple and Every Apple Support Professional Must Do
By on April 14, 2012Comments

The Flashback attack is a sign of more to come.  Are you prepared to see your Apple computer (or those you support) as functional UNIX devices that require special skills?


Flashbacks On Your Mac?
By on April 9, 2012Comments
Unless you live under a rock, by now, you should have learned about the Flashback trojan that has compromised over 600,000 Apple computers.

Care to learn what you can do?  Read on...


Commodities
By on March 7, 2012Comments

What are the security implications of Operating Systems being reduced to container commodities that live to give applications life support?


See All Related Blogs