# ------------------------------------------------------- @ Function(open) # ------------------------------------------------------- @ Returns(int,fd) @ Params(const char *path, int flags, mode_t mode) @ Requires(sys/types,sys/stat,fcntl) @ Description This function opens the file specified by path according to the request specified by flags. @ Code - Check that path is a valid path - Check that flags contains a valid request - Attempt to open the specified file - Return file descriptor or -1 @ EndCode # ------------------------------------------------------- @ Function(close) # ------------------------------------------------------- @ Returns(int,rc) @ Params(int fd) @ Requires(unistd) @ Description This function closes the file specified by file descriptor fd. @ Code - Check that fd is a valid descriptor - Attempt to close the specified file - Return 0 for ok or -1 in case of error @ EndCode # ------------------------------------------------------- @ Function(read) # ------------------------------------------------------- @ Returns(ssize_t,nbytes) @ Params(int fd, void *buf, size_t n) @ Requires(unistd) @ Description This function reads n bytes from the file specified by descriptor fd and copies them to the memory area addressed by buf. @ Code - Check that fd is a valid descriptor - Check that buf points to a valid memory area - Check that n is a non-negative number - Attempt to read the requested number of bytes - Return number of bytes actually read, 0 in case of end of file, -1 in case of error. @ EndCode # ------------------------------------------------------- @ Function(write) # ------------------------------------------------------- @ Returns(ssize_t,nbytes) @ Params(int fd, const void *buf, size_t n) @ Requires(unistd) @ Description This function writes n bytes to the file specified by descriptor fd copying them from the memory area addressed by buf. @ Code - Check that fd is a valid descriptor - Check that buf points to a valid memory area - Check that n is a non-negative number - Attempt to write the requested number of bytes - Return number of bytes actually written, -1 in case of error. @ EndCode