.hy 0 .ad l .nf

Prev, Top | Slide, Next

# 5. Strange and Interesting System Calls

- one strerror-equivalent per system call
- boundary conditions
- multiple causes for the same errno value
- multiple errno values for the same cause
- coders@slug mailing list

## 5.1 ENOMEDIUM

- of course, they are all frauds; slide
- Native English speakers don't know that “media” is a plural, let alone that “medium” is its singular.
- this strerror(3) string is almost content-free.
- surely this could be more informative; slide
- O_NONBLOCK
- it also groks floppies, magnetic tapes, MMC card readers, etc
- disc-with-a-c vs disk-with-a-k

## 5.2 EFAULT

- one pointer is easy; slide
- must not disturb process (thread) signal handlers
- bounded memory: mincore(2)
- strings: lstat(2)

## 5.3 EMFILE

- The message includes the limit; slide
- can't use `/proc`
- sysconf(3) is very handy
- of course, it could be a single-open device that is already open or mounted

## 5.4 ENFILE

- The message includes the limit; slide
- can't use `/proc`
- sysconf(3) is very handy
- this is when you read kernel sources
- system call with no [e]glibc binding
  `CTL_FS, FS_MAXFILE`

## 5.5 EPERM vs ENOSYS

- also EINVAL sometimes
- same cause, different errno(3) values; slide
- same errno(3) value, different causes; slide
- wishlist: pathconf for "is this fops pointer non-null"

## 5.6 errno(3) is not always set

- slide
- somtimes they set errno(3), sometimes they don't.
- traps for young players (old ones, too)
- not going into each one, read the paper
- who knew that fileno(3) could fail?

## 5.7 ENOSPC

- slide
- print the mount point
- work in progress (inodes vs data vs directory entries)
- special devices already includes device name...
- &...need to add device size, without altering state

## 5.8 EROFS

- file systems print the mount point; slide
- devices are more specific
- work in progress: filesys case could drill down
- work in progress: not all devices this accurate
  \&...because a CD-ROM is not writable
  \&...because the memory card has the write protect tab set
  \&...because the ½ inch magnetic tape does not have a write ring

## 5.9 rename(2)

- not talking about mv<(1)
- rename(2) directory over directory; slide
- destination must be empty
- implies all the rmdir(2) errors as well
- but not files over directories, or vice versa
- who knew: dup2(2) is the same
- ...implies all the unlink(2) errors as well