csc374And407_lect8 - CSC 374/407 Computer Systems II...

Info icon This preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
CSC 374/407: Computer Systems II Lecture 8 Joseph Phillips De Paul University 2016 September 6 Copyright © 2012-2016 Joseph Phillips All rights reserved
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Reading Bryant & O'Hallaron “ Computer Systems, 3 rd Ed. Chapter 10: System Level I/O Chapter 11: Networking Programming Hoover “ System Programming Chapter 5: Input/Output
Image of page 2
Topics Unix Filesystem Design: A Process' Prospective Unix Filesystem Design: A Systemwide Prospective Low-level C Input-Output Socket communication and the client/server model Server-side socket programming Client-side socket programming
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Unix Filesystem Design: A Process' Prospective
Image of page 4
Unix Filesystem Design: A Systemwide Prospective
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
What's an “I-Node”? Tells a files: Size in bytes Access times (last read, last written, last its status was modified) User and group ID Device ID Access privileges Link count (num different names/directories) Pointers
Image of page 6
Low level C Input-Output File descriptors are indices into process' file table 0: Standard input ( stdin ) 1: Standard output ( stdout ) 2: Standard error ( stderr ) Useful commands include: int open(const char* path, int how,  int permission) int close(int fd) int read(int fd, char* bufferPtr,  size_t bufferSize) int write(int fd, char* bufferPtr,  size_t numBytes) int dup(int fd); int pipe(int** );
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
open() int open( const char* path , int how,  int permission) Returns file descriptor (index into process' file array) File path given by path .
Image of page 8
open() int open(const char* path,  int how int permission) Integer how is bitwise or-ing of one of: O_RDONLY : Open for reading only. O_WRONLY : Open for writing only. O_RDWR : Open for reading and writing. And perhaps one or more of: O_CREAT : Create file if doesn't already exist O_TRUNC : If exist truncate its length to 0 (even if not open for writing) O_EXCL : If O_CREAT is also set fail if file exists. O_APPEND : Write to end of file.
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
open(), cont'd int open(const char* path, int flags,  int permission ) In “Classic” Unix there are 3 types of permissions: R ”ead: permission to read (i.e. load a file into memory) W ”rite: permission to over-write a file e“ X ”ecute: permission to run an executable Each of these permissions is either “On” (1) or “Off” (0) This suggests storing all three as an octal digit : Read * 2 2 + Write * 2 1 + Execute * 2 0 Examples: Read and write, but no execute: 1*4 + 1*2 + 0*1 = 6 Read and execute, but no write: 1*4 + 0*2 + 1*1 = 5
Image of page 10
open(), cont'd int open(const char* path, int flags,  int permission )   Further, three types of folks for whom must specify permission: “User” (i.e. the Owner) of the file “Group”, audience of file May just be User , or may be group to which user belongs, like CSC374Students “Other”, anyone else on OS.
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern