Thesis, antithesis, synthesis

Size: px
Start display at page:

Download "Thesis, antithesis, synthesis"

Transcription

1 Identity Page 1 Thesis, antithesis, synthesis Thursday, December 01, :00 PM Thesis, antithesis, synthesis We began the course by considering the system programmer's point of view. Mid-course, we switched to studying how to write the operating system itself. Finally, we take a look at programming again, knowing what's "under the hood." And things look very different now... Before: how to do things? After: what can we get away with?

2 Identity Page 2 Beyond the kernel Wednesday, November 30, :35 PM So far, we've concentrated on the kernel, where: drivers live. processes are executed. scheduling is accomplished. everything is a number. Now, we shift gears yet another time: Assume that the filesystem works. Utilize the filesystem to do useful things. Consider parts of the operating system outside the kernel.

3 Identity Page 3 Revisiting systems programming Thursday, December 01, :03 PM What we've learned about systems programming: Creating and reaping processes. Inter-process communications. Threads and mutexes. Revisiting systems programming: Manipulating filesystems. Understanding and manipulating privilege. Daemons as operating system extensions. Basics of security.

4 Identity Page 4 Manipulating the filesystem Thursday, December 01, :36 AM Manipulating the filesystem stat - read an inode. opendir, readdir, closedir - manipulate directories.

5 stat Thursday, December 01, :36 AM stat Purpose of stat: read most of an inode struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device ID (if special file) */ off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for filesystem I/O */ blkcnt_t st_blocks; /* number of blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last status change */ }; int stat(const char *path, struct stat *buf); int fstat(int filedes, struct stat *buf); int lstat(const char *path, struct stat *buf); Three different forms: stat: reads inode information from a path. fstat: reads from open file descriptor. lstat: reads the stat for a symlink, rather than following the link. Identity Page 5

6 opendir, readdir, closedir Thursday, December 01, :43 AM opendir, readdir, closedir A directory is a special kind of file. So it needs a special reader. #include <sys/types.h> #include <dirent.h> struct dirent { ino_t d_ino; /* inode number */ off_t d_off; /* offset to the next dirent */ unsigned short d_reclen; /* length of this record */ unsigned char d_type; /* type of file */ char d_name[256]; /* filename */ }; // DIR *opendir(const char *name); // struct dirent *readdir(dir *dir); // int closedir(dir *dir); Identity Page 6

7 Identity Page 7 Example: how to write 'ls' Thursday, December 01, :50 AM #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> main() { DIR *d = opendir("."); if (d) { struct dirent *e; while ((e=readdir(d))!= NULL) { struct stat s; if (stat(e->d_name, &s)==0) { printf("%s mode=0%o uid=%d gid=%d\n", e->d_name, s.st_mode, s.st_uid, s.st_gid); } else { perror("ls"); } } } else { // protection failure } perror("ls"); } closedir(d); Pasted from <

8 Identity Page 8 Oops! Thursday, December 01, :06 AM Oops! We don't have most of what normal 'ls' provides us Name of owner, group Pretty-printed mode Why? These are not in the inode! Info is contained elsewhere!

9 Identity Page 9 Users and Groups Thursday, December 01, :07 AM Users and Groups Users and Groups are represented as numbers. The names are for humans only. Somewhere, we must maintain a mapping between numbers and names.

10 Identity Page 10 The "configuration" Wednesday, November 30, :38 PM The "configuration": The filesystem contains everything the operating system needs to run. That part of the filesystem that determines OS function is called the configuration of the operating system. A configuration is a set of files. Configuration management is the process of controlling the configuration to create desired behaviors in the OS. The configuration mostly resides in /etc.

11 Identity Page 11 The concept of identity Wednesday, November 30, :40 PM Our first configuration concept: identity Who can login? What can someone who logs in actually do?

12 Identity Page 12 UIDs Wednesday, November 30, :54 PM Givin' you a number: Users in linux are known by numbers. Names are only for humans. The User ID (UID) of a user is an integer Between =root <1024: users necessary for operating system operation >=1024: human users.

13 Identity Page 13 User attributes Wednesday, November 30, :59 PM User attributes: name password (hashed) user id (UID) primary group id (GID) list of groups for which the user is a member. quotas for filesystems This is not in one file: login name: /etc/passwd password (hashed) /etc/shadow user id (UID) /etc/passwd primary group id (GID) /etc/passwd list of groups for which the user is a member. /etc/group quotas for filesystems stored are separately.

14 Identity Page 14 The concept of a group Wednesday, November 30, :03 PM A group is a set of users that share access to things Again by number: group identifier (GID). Defined in /etc/group, which contains group name GID list of login names that are members.

15 Identity Page 15 Federated identity Wednesday, November 30, :05 PM Federated identity Alas, /etc/passwd, group, shadow aren't that interesting on our linux stations. Reason: our identity management is federated: we use a network service to define user identity. Most common federation: Lightweight Directory Access Protocol (LDAP) Second most common: Windows Active Directory We run both: LDAP for Linux, AD for Windows. See /etc/nsswitch.conf for details.

16 Identity Page 16 Daemons Wednesday, December 2, :36 PM LDAP is actually serviced via a network daemon. daemon: a program that runs all the time. Answers requests. Using network programming (see COMP112)

17 Exploring LDAP Thursday, November 29, :27 AM Exploring LDAP ldapsearch -x uid=couch # user couch ldapsearch -x cn=grade111 # group grade111 Identity Page 17

18 Identity Page 18 Basic principle of configuration Thursday, December 01, :08 AM Basic principle of configuration Never read a configuration file directly. Instead, utilize library functions (man 3) to access it. These functions Read the files. Cache information for repeated use. Eliminate excess reads. Understand federation semantics.

19 Identity Page 19 Reading users Thursday, December 01, :10 AM Reading users: getpwuid, getpwnam struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* user password */ uid_t pw_uid; /* user ID */ gid_t pw_gid; /* group ID */ char *pw_gecos; /* real name */ char *pw_dir; /* home directory */ char *pw_shell; /* shell program */ }; #include <sys/types.h> #include <pwd.h> struct passwd *getpwnam(const char *name); struct passwd *getpwuid(uid_t uid);

20 Identity Page 20 Reading groups Thursday, December 01, :17 AM Reading groups: getgrnam, getgrgid struct group { char *gr_name; /* group name */ char *gr_passwd; /* group password */ gid_t gr_gid; /* group ID */ char **gr_mem; /* group members */ }; #include <sys/types.h> #include <grp.h> struct group *getgrnam(const char *name); struct group *getgrgid(gid_t gid);

21 Identity Page 21 What getgr*, getpw* do Thursday, December 01, :20 AM What getgr*, getpw* do: Read /etc/nsswitch.conf to determine data sources. Cache it in memory. Read data sources, cache them. Return a result that is a pointer into a data source. Caveats: Returned pointer is not persistent: content can change at next call of getgr*, getpw*.

22 Identity Page 22 Example: a better 'ls' Thursday, December 01, :20 AM #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <pwd.h> #include <grp.h> #include <string.h> main() { DIR *d = opendir("."); if (d) { struct dirent *e; while ((e=readdir(d))!= NULL) { struct stat s; if (stat(e->d_name, &s)==0) { char username[256]; struct passwd *p = getpwuid(s.st_uid); if (p) { strcpy(username, p->pw_name); // name } else { sprintf(username, "%d", s.st_uid); // number } char groupname[256]; struct group *g = getgrgid(s.st_gid); if (g) { strcpy(groupname, g->gr_name); // name } else { sprintf(groupname, "%d", s.st_gid); // number } printf("%s mode=0%o owner=%s group=%s\n", e->d_name, s.st_mode, username, groupname); } else { perror("ls"); } } } else { // protection failure perror("ls"); }

23 } Pasted from < Identity Page 23

24 Identity Page 24 Basic concepts of user privilege Wednesday, November 30, :08 PM Basic concepts of user privilege Defined as a filesystem concept. Every file has an owner: the UID of the person who owns it. group: the GID of its group. protection word: defines what people can do with the file.

25 Identity Page 25 The protection word Wednesday, November 30, :10 PM The protection word A binary integer Basic pattern: bit number ttttugouuugggooo -- scope sstrwxrwxrwx -- meaning Where t is a bit referring to the type of node u is a bit referring to owner privilege g is a bit referring to group privilege o is a bit referring to privilege for everyone other than the owner or group and, for each kind of privilege r means the item is readable w means the item is writeable x means the item is executable s is 1 means that this file executes for its own owner or in its own group. t is 1 means that the directory file exhibits temporary ownership characteristics. Values of tttt: (octal!) 014 socket 012 symbolic link 010 regular file 006 block device

26 004 directory 002 character device 001 FIFO (named pipe) Identity Page 26

27 Identity Page 27 Files versus directories Wednesday, November 30, :24 PM Protections mean different things depending upon whether a node is a file or directory: Protection Files Directories r can read it can ls it w can write it can create and delete files in it x can execute it as a program can access things in it if you know their names already Typical protections: Your files: rw only owner can read and write Your a.out: rwx can also execute it. Your directories: rwx------: you can read, write, and search. Typical system protections Shared files: rw-r--r--: anyone can read. Shared programs: rwxr-xr-x: anyone can run it as a program. Shared directories: rwxr-xr-x: anyone can ls or search it. Changing the mode of a file chmod 644 file: make the file public (rw-r--r--: octal) chmod go+x file: make the file executable to group and other if it is executable to owner. Your umask

28 Attribute of a process. Stored in the PCB. Inherited by sub-processes. Determines which bits of the protection word you won't set, in octal: umask 077: don't let others see what I am doing. umask 022: let others see but not write. Identity Page 28

29 Identity Page 29 Privilege and nested directories Thursday, December 01, :21 AM Privilege and nested directories In order to access something, you must be able to: get to it, by searching its directory (x). Thus you must have access to all directories in its path. change it, by modifying its inode. Thus you must have access to the object itself.

30 Identity Page 30 A simple protection quandary Thursday, December 01, :24 AM A simple protection quandary /foo rwx--x--x owner=root group=root /foo/bar rwx--x--x owner=couch group=grade111 /foo/bar/baz.txt rw owner=rveroy group=student What can rveroy do with baz.txt? cannot ls /foo cannot ls /foo/bar can edit /foo/bar/baz.txt (!) What can couch do with baz.txt? cannot ls /foo can ls /foo/bar can delete baz.txt cannot read or write baz.txt (!) In other words, Changing a file requires file permission. Adding or deleting a file requires permission in its directory. It is possible to be able to delete a file without being able to read it!

31 Identity Page 31 setuid, setgid, and the sticky bit Wednesday, November 30, 2011 The 10th-12th bits of the protection word are special. bit 12: setuid: for programs, run as the file owner, not the user. bit 11: setgid: for programs, run as the file group, not the user's group. bit 10: sticky bit: for directory, only owner can change contained files, even if directory is shared. A brief map of bits 12-10: s (12) s (11) t (10) for files setuid setgid no meaning for directories 5:33 PM no meaning group inheritance sticky behavior

32 Identity Page 32 An even better 'ls' Thursday, December 01, :47 AM #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <pwd.h> #include <grp.h> #include <string.h> void showmode(int mode, char *buffer); main() { DIR *d = opendir("."); if (d) { struct dirent *e; while ((e=readdir(d))!= NULL) { struct stat s; if (stat(e->d_name, &s)==0) { char username[256]; struct passwd *p = getpwuid(s.st_uid); if (p) { strcpy(username, p->pw_name); // name } else { sprintf(username, "%d", s.st_uid); // number } char groupname[256]; struct group *g = getgrgid(s.st_gid); if (g) { strcpy(groupname, g->gr_name); // name } else { sprintf(groupname, "%d", s.st_gid); // number } char mode[10]; showmode(s.st_mode, mode); printf("%s mode=%s owner=%s group=%s\n", e->d_name, mode, username, groupname); } else { perror("ls"); } } } else { // protection failure

33 Identity Page 33 perror("ls"); } } void showmode(int mode, char *buffer) { buffer[0]= (mode&(1<<8))?'r':'-'; buffer[1]= (mode&(1<<7))?'w':'-'; buffer[2]= (mode&(1<<6))?'x':'-'; buffer[3]= (mode&(1<<5))?'r':'-'; buffer[4]= (mode&(1<<4))?'w':'-'; buffer[5]= (mode&(1<<3))?'x':'-'; buffer[6]= (mode&(1<<2))?'r':'-'; buffer[7]= (mode&(1<<1))?'w':'-'; buffer[8]= (mode&(1<<0))?'x':'-'; buffer[9]='\0'; if (mode&(1<<11)) { // setuid buffer[2]= (buffer[2]=='x'? 's' : 'S'); } if (mode&(1<<10)) { // setgid buffer[5]= (buffer[5]=='x'? 's' : 'S'); } if (mode&(1<<9)) { // sticky bit buffer[8]= (buffer[8]=='x'? 't' : 'T'); } } Pasted from <

34 Identity Page 34 File privilege and process privilege Thursday, December 01, :52 AM File privilege: setuid: run as file owner. setgid: run as file group. Process privilege: real uid: the one inherited from one's parent process. effective uid: the one specified by file mode. real gid: the one inherited from one's parent process. effective gid: the one specified by file mode.

35 Identity Page 35 Discovering and manipulating privilege Thursday, December 01, :54 AM Discovering and manipulating privilege: int uid = getuid(); // real uid int euid = geteuid(); // effective uid int gid = getgid(); // real gid int egid = getegid(); // effective gid setuid(uid); // set the real uid seteuid(euid); // set the effective uid setgid(gid); // set the real gid setegid(egid); // set the effective gid Watch out: Regular processes can only set the euid to either the uid or an old euid. Root can set the uid or euid to anything. But once root sets the uid to non-root, there is no going back. Likewise for groups. Here is an example of manipulating protections: now.c

36 Example: provide protections Wednesday, November 30, :40 PM How provide protections work: /comp/111/grading has protection -s-rwxrws--- owner couch group grade111 which means that I own it, and either I or the group can modify it. group inheritance is enabled: things created in this directory have group grade111. Directories inside /comp/111/grading have the same protection Files inside /comp/111/grading have protection ---rw-rw---- owner: you or me group: grade111 grade111 has members couch,zhaokun,srao02 So Zhaokun can modify it. But you can't normally see it. But provide has to see it: provide is setuid root. The very first thing provide does is to figure out what its class is, and then downgrade its privilege to that class: start out as s--rwxr-xr-x root grading: setuid root. use root privilege to change effective group of process to grade111 (thus invoking setgid). downgrade privilege to that of user (you). At this point, provide is running as you, but with the ta group! Identity Page 36

37 What happens now is that you post your files to my directories. Now things get interesting: your grades are reported in progress.cgi This has Protections -s-rwxr-xr-x Owner couch Group grade111 So, it runs as group grade111, which means that it gets access to your work! Identity Page 37

38 Identity Page 38 What you don't want to see Wednesday, November 30, :56 PM What you don't want to see in your account: foo mode=rwsrwsrwx owner=root group=root Setuid root Setgid root world executable Whoever runs this gets root on your workstation. What a rootkit actually does, in some form: cp /bin/csh foo chown root foo chgrp root foo chmod foo so that anyone who runs foo gets a root shell.

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu CS@ECNU Operating System Labs Project 3 Oral test Handin your slides Time Project 4 Due: 6 Dec Code Experiment report Operating System Labs Overview of file system File

More information

CS , Spring Sample Exam 3

CS , Spring Sample Exam 3 Andrew login ID: Full Name: CS 15-123, Spring 2010 Sample Exam 3 Mon. April 6, 2009 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu CS@ECNU Operating System Labs Project 4 (multi-thread & lock): Due: 10 Dec Code & experiment report 18 Dec. Oral test of project 4, 9:30am Lectures: Q&A Project 5: Due:

More information

CS631 - Advanced Programming in the UNIX Environment

CS631 - Advanced Programming in the UNIX Environment CS631 - Advanced Programming in the UNIX Environment Slide 1 CS631 - Advanced Programming in the UNIX Environment Files and Directories Department of Computer Science Stevens Institute of Technology Jan

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto For more information please consult Advanced Programming in the UNIX Environment, 3rd Edition, W. Richard Stevens and

More information

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell

More information

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo

I/O OPERATIONS. UNIX Programming 2014 Fall by Euiseong Seo I/O OPERATIONS UNIX Programming 2014 Fall by Euiseong Seo Files Files that contain a stream of bytes are called regular files Regular files can be any of followings ASCII text Data Executable code Shell

More information

CSCI-E28 Lecture 3 Outline. Directories, File Attributes, Bits, File Operations. Write our own versions of Unix programs

CSCI-E28 Lecture 3 Outline. Directories, File Attributes, Bits, File Operations. Write our own versions of Unix programs CSCI-E28 Lecture 3 Outline Topics: Approach: Directories, File Attributes, Bits, File Operations Write our own versions of Unix programs Featured Commands: ls, ls -l Main Ideas: Adirectory is a list of

More information

File Systems. q Files and directories q Sharing and protection q File & directory implementation

File Systems. q Files and directories q Sharing and protection q File & directory implementation File Systems q Files and directories q Sharing and protection q File & directory implementation Files and file systems Most computer applications need to Store large amounts of data; larger than their

More information

Important Dates. October 27 th Homework 2 Due. October 29 th Midterm

Important Dates. October 27 th Homework 2 Due. October 29 th Midterm CSE333 SECTION 5 Important Dates October 27 th Homework 2 Due October 29 th Midterm String API vs. Byte API Recall: Strings are character arrays terminated by \0 The String API (functions that start with

More information

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University File I/O Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O

More information

File System (FS) Highlights

File System (FS) Highlights CSCI 503: Operating Systems File System (Chapters 16 and 17) Fengguang Song Department of Computer & Information Science IUPUI File System (FS) Highlights File system is the most visible part of OS From

More information

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1

Memory Mapped I/O. Michael Jantz. Prasad Kulkarni. EECS 678 Memory Mapped I/O Lab 1 Memory Mapped I/O Michael Jantz Prasad Kulkarni EECS 678 Memory Mapped I/O Lab 1 Introduction This lab discusses various techniques user level programmers can use to control how their process' logical

More information

Lecture 23: System-Level I/O

Lecture 23: System-Level I/O CSCI-UA.0201-001/2 Computer Systems Organization Lecture 23: System-Level I/O Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified) from: Clark Barrett

More information

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories

Chapter 4 - Files and Directories. Information about files and directories Management of files and directories Chapter 4 - Files and Directories Information about files and directories Management of files and directories File Systems Unix File Systems UFS - original FS FFS - Berkeley ext/ext2/ext3/ext4 - Linux

More information

System Calls. Library Functions Vs. System Calls. Library Functions Vs. System Calls

System Calls. Library Functions Vs. System Calls. Library Functions Vs. System Calls System Calls Library Functions Vs. System Calls A library function: Ordinary function that resides in a library external to the calling program. A call to a library function is just like any other function

More information

File I/O. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

File I/O. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University  Embedded Software Lab. 1 File I/O Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Unix files 2 A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O devices are represented

More information

structs as arguments

structs as arguments Structs A collection of related data items struct record { char name[maxname]; int count; ; /* The semicolon is important! It terminates the declaration. */ struct record rec1; /*allocates space for the

More information

File Systems. Today. Next. Files and directories File & directory implementation Sharing and protection. File system management & examples

File Systems. Today. Next. Files and directories File & directory implementation Sharing and protection. File system management & examples File Systems Today Files and directories File & directory implementation Sharing and protection Next File system management & examples Files and file systems Most computer applications need to: Store large

More information

Files and Directories

Files and Directories Contents 1. Preface/Introduction 2. Standardization and Implementation 3. File I/O 4. Standard I/O Library 5. Files and Directories 6. System Data Files and Information 7. Environment of a Unix Process

More information

File I/O. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

File I/O. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University File I/O Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O devices

More information

CSC209F Midterm (L0101) Fall 1999 University of Toronto Department of Computer Science

CSC209F Midterm (L0101) Fall 1999 University of Toronto Department of Computer Science CSC209F Midterm (L0101) Fall 1999 University of Toronto Department of Computer Science Date: October 26, 1999 Time: 1:10 pm Duration: 50 minutes Notes: 1. This is a closed book test, no aids are allowed.

More information

Preview. Review. System Data Files (Password File) System Data Files (Password File) System Data Files (Password File)

Preview. Review. System Data Files (Password File) System Data Files (Password File) System Data Files (Password File) Review Preview link(), unlink() System Call remove(), rename() System Call Symbolic Links Symbolic link to directory Symbolic link to a executable file symlink() System Call File Times utime() System Call

More information

CSci 4061 Introduction to Operating Systems. File Systems: Basics

CSci 4061 Introduction to Operating Systems. File Systems: Basics CSci 4061 Introduction to Operating Systems File Systems: Basics File as Abstraction Naming a File creat/open ( path/name, ); Links: files with multiple names Each name is an alias #include

More information

Contents. Programming Assignment 0 review & NOTICE. File IO & File IO exercise. What will be next project?

Contents. Programming Assignment 0 review & NOTICE. File IO & File IO exercise. What will be next project? File I/O Prof. Jin-Soo Kim(jinsookim@skku.edu) TA - Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents Programming Assignment 0 review & NOTICE

More information

CSC 271 Software I: Utilities and Internals

CSC 271 Software I: Utilities and Internals CSC 271 Software I: Utilities and Internals Lecture 13 : An Introduction to File I/O in Linux File Descriptors All system calls for I/O operations refer to open files using a file descriptor (a nonnegative

More information

17: Filesystem Examples: CD-ROM, MS-DOS, Unix

17: Filesystem Examples: CD-ROM, MS-DOS, Unix 17: Filesystem Examples: CD-ROM, MS-DOS, Unix Mark Handley CD Filesystems ISO 9660 Rock Ridge Extensions Joliet Extensions 1 ISO 9660: CD-ROM Filesystem CD is divided into logical blocks of 2352 bytes.

More information

Advanced Systems Security: Ordinary Operating Systems

Advanced Systems Security: Ordinary Operating Systems Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Advanced Systems Security:

More information

UNIX FILESYSTEM STRUCTURE BASICS By Mark E. Donaldson

UNIX FILESYSTEM STRUCTURE BASICS By Mark E. Donaldson THE UNIX FILE SYSTEM Under UNIX we can think of the file system as everything being a file. Thus directories are really nothing more than files containing the names of other files and so on. In addition,

More information

System- Level I/O. Andrew Case. Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron

System- Level I/O. Andrew Case. Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron System- Level I/O Andrew Case Slides adapted from Jinyang Li, Randy Bryant and Dave O Hallaron 1 Unix I/O and Files UNIX abstracts many things into files (just a series of bytes) All I/O devices are represented

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the

More information

UNIX System Calls. Sys Calls versus Library Func

UNIX System Calls. Sys Calls versus Library Func UNIX System Calls Entry points to the kernel Provide services to the processes One feature that cannot be changed Definitions are in C For most system calls a function with the same name exists in the

More information

Automated Test Generation in System-Level

Automated Test Generation in System-Level Automated Test Generation in System-Level Pros + Can be easy to generate system TCs due to clear interface specification + No false alarm (i.e., no assert violation caused by infeasible execution scenario)

More information

Files and Directories

Files and Directories Files and Directories Stat functions Given pathname, stat function returns structure of information about file fstat function obtains information about the file that is already open lstat same as stat

More information

Design Choices 2 / 29

Design Choices 2 / 29 File Systems One of the most visible pieces of the OS Contributes significantly to usability (or the lack thereof) 1 / 29 Design Choices 2 / 29 Files and File Systems What s a file? You all know what a

More information

Contents. NOTICE & Programming Assignment #1. QnA about last exercise. File IO exercise

Contents. NOTICE & Programming Assignment #1. QnA about last exercise. File IO exercise File I/O Examples Prof. Jin-Soo Kim(jinsookim@skku.edu) TA - Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents NOTICE & Programming Assignment

More information

Files and Directories Filesystems from a user s perspective

Files and Directories Filesystems from a user s perspective Files and Directories Filesystems from a user s perspective Unix Filesystems Seminar Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of

More information

UNIT I INTRODUCTION TO UNIX & FILE SYSTEM

UNIT I INTRODUCTION TO UNIX & FILE SYSTEM INTRODUCTION TO UNIX & FILE SYSTEM Part A 1. What is UNIX? UNIX(Uniplexed Information Computing System) it is an operating system was developed in Early 1970 at Bell Labs. It was initially a character

More information

Contents. NOTICE & Programming Assignment 0 review. What will be next project? File IO & File IO exercise

Contents. NOTICE & Programming Assignment 0 review. What will be next project? File IO & File IO exercise File I/O Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents NOTICE & Programming Assignment 0 review

More information

Linux Forensics. Newbug Tseng Oct

Linux Forensics. Newbug Tseng Oct Linux Forensics Newbug Tseng Oct. 2004. Contents Are u ready Go Real World Exploit Attack Detect Are u ready Linux File Permission OWNER 4 2 1 GROUP 4 2 1 OTHER 4 2 1 R R R W SUID on exection 4000 X W

More information

Master Calcul Scientifique - Mise à niveau en Informatique Written exam : 3 hours

Master Calcul Scientifique - Mise à niveau en Informatique Written exam : 3 hours Université de Lille 1 Année Universitaire 2015-2016 Master Calcul Scientifique - Mise à niveau en Informatique Written exam : 3 hours Write your code nicely (indentation, use of explicit names... ), and

More information

CS 201. Files and I/O. Gerson Robboy Portland State University

CS 201. Files and I/O. Gerson Robboy Portland State University CS 201 Files and I/O Gerson Robboy Portland State University A Typical Hardware System CPU chip register file ALU system bus memory bus bus interface I/O bridge main memory USB controller graphics adapter

More information

Files and Directories Filesystems from a user s perspective

Files and Directories Filesystems from a user s perspective Files and Directories Filesystems from a user s perspective Unix Filesystems Seminar Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science University of

More information

The course that gives CMU its Zip! I/O Nov 15, 2001

The course that gives CMU its Zip! I/O Nov 15, 2001 15-213 The course that gives CMU its Zip! I/O Nov 15, 2001 Topics Files Unix I/O Standard I/O A typical hardware system CPU chip register file ALU system bus memory bus bus interface I/O bridge main memory

More information

CSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19

CSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19 CSI 402 Lecture 11 (Unix Discussion on Files continued) 11 1 / 19 User and Group IDs Ref: Chapter 3 of [HGS]. Each user is given an ID (integer) called uid. (Most system programs use uid instead of the

More information

CptS 360 (System Programming) Unit 6: Files and Directories

CptS 360 (System Programming) Unit 6: Files and Directories CptS 360 (System Programming) Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2019 Motivation Need to know your way around a filesystem. A properly organized filesystem

More information

The UNIX File System

The UNIX File System The UNIX File System Magnus Johansson May 9, 2007 1 UNIX file system A file system is created with mkfs. It defines a number of parameters for the system, such as: bootblock - contains a primary boot program

More information

File and Directories. Advanced Programming in the UNIX Environment

File and Directories. Advanced Programming in the UNIX Environment File and Directories Advanced Programming in the UNIX Environment stat Function #include int stat(const char *restrict pathname, struct stat *restrict buf ); int fstat(int fd, struct stat

More information

All the scoring jobs will be done by script

All the scoring jobs will be done by script File I/O Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon Han(sanghoon.han@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Announcement (1) All the scoring jobs

More information

The UNIX File System

The UNIX File System The UNIX File System Magnus Johansson (May 2007) 1 UNIX file system A file system is created with mkfs. It defines a number of parameters for the system as depicted in figure 1. These paremeters include

More information

Homework 5. Due Date: Friday, June 7, 2002, at 11:59PM; no late assignments accepted Points: 100

Homework 5. Due Date: Friday, June 7, 2002, at 11:59PM; no late assignments accepted Points: 100 Homework 5 Due Date: Friday, June 7, 2002, at 11:59PM; no late assignments accepted Points: 100 UNIX System 1. (10 points) I want to make the file libprog.a in my home directory available to everyone so

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight HW2 Due Thursday, July 19 th Midterm on Monday, July 23 th 10:50-11:50 in TBD (And regular exercises in between) POSIX

More information

Privileges: who can control what

Privileges: who can control what Privileges: who can control what Introduction to Unix May 24, 2008, Morocco Hervey Allen Goal Understand the following: The Unix security model How a program is allowed to run Where user and group information

More information

39. File and Directories

39. File and Directories 39. File and Directories Oerating System: Three Easy Pieces AOS@UC 1 Persistent Storage Kee a data intact even if there is a ower loss. w Hard disk drive w Solid-state storage device Two key abstractions

More information

File Types in Unix. Regular files which include text files (formatted) and binary (unformatted)

File Types in Unix. Regular files which include text files (formatted) and binary (unformatted) File Management Files can be viewed as either: a sequence of bytes with no structure imposed by the operating system. or a structured collection of information with some structure imposed by the operating

More information

Lecture files in /home/hwang/cs375/lecture05 on csserver.

Lecture files in /home/hwang/cs375/lecture05 on csserver. Lecture 5 Lecture files in /home/hwang/cs375/lecture05 on csserver. cp -r /home/hwang/cs375/lecture05. scp -r user@csserver.evansville.edu:/home/hwang/cs375/lecture05. Project 1 posted, due next Thursday

More information

All the scoring jobs will be done by script

All the scoring jobs will be done by script File I/O Prof. Jinkyu Jeong( jinkyu@skku.edu) TA-Seokha Shin(seokha.shin@csl.skku.edu) TA-Jinhong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

More information

Systems Programming/ C and UNIX

Systems Programming/ C and UNIX Systems Programming/ C and UNIX Alice E. Fischer September 9, 2015 Alice E. Fischer Systems Programming Lecture 3... 1/39 September 9, 2015 1 / 39 Outline 1 Compile and Run 2 Unix Topics System Calls The

More information

Lecture 21 Systems Programming in C

Lecture 21 Systems Programming in C Lecture 21 Systems Programming in C A C program can invoke UNIX system calls directly. A system call can be defined as a request to the operating system to do something on behalf of the program. During

More information

COMP 2355 Introduction to Systems Programming

COMP 2355 Introduction to Systems Programming COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 Processes A process is an instance of a running program. Programs do not have to

More information

This document gives a general overview of the work done by an operating system and gives specific examples from UNIX.

This document gives a general overview of the work done by an operating system and gives specific examples from UNIX. This document gives a general overview of the work done by an operating system and gives specific examples from UNIX. 1 Manages Resources: I/O devices (disk, keyboard, mouse, terminal) Memory Manages Processes:

More information

SYSTEM INFORMATION. UNIX Programming 2015 Fall by Euiseong Seo

SYSTEM INFORMATION. UNIX Programming 2015 Fall by Euiseong Seo SYSTEM INFORMATION UNIX Programming 2015 Fall by Euiseong Seo Host Information POSIX defines host information as follows OS name (Linux) OS release (3.13.0) OS version (#60-Ubuntu SMP Web Aug 13) Node

More information

Files (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Files (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1 Files (review) and Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 midterms (Feb 11 and April 1) Files and Permissions Regular Expressions 2 Sobel, Chapter 6 160_pathnames.html

More information

OPERATING SYSTEMS: Lesson 2: Operating System Services

OPERATING SYSTEMS: Lesson 2: Operating System Services OPERATING SYSTEMS: Lesson 2: Operating System Services Jesús Carretero Pérez David Expósito Singh José Daniel García Sánchez Francisco Javier García Blas Florin Isaila 1 Goals To understand what an operating

More information

Files and Directories Objectives Additional Features of the File System Properties of a File. Three major functions that return file information:

Files and Directories Objectives Additional Features of the File System Properties of a File. Three major functions that return file information: Files and Directories Objectives Additional Features of the File System Properties of a File. Three major functions that return file information: #include #include int stat(const

More information

Outline. File Systems. File System Structure. CSCI 4061 Introduction to Operating Systems

Outline. File Systems. File System Structure. CSCI 4061 Introduction to Operating Systems Outline CSCI 4061 Introduction to Operating Systems Instructor: Abhishek Chandra File Systems Directories File and directory operations Inodes and metadata Links 2 File Systems An organized collection

More information

Last Week: ! Efficiency read/write. ! The File. ! File pointer. ! File control/access. This Week: ! How to program with directories

Last Week: ! Efficiency read/write. ! The File. ! File pointer. ! File control/access. This Week: ! How to program with directories Overview Unix System Programming Directories and File System Last Week:! Efficiency read/write! The File! File pointer! File control/access This Week:! How to program with directories! Brief introduction

More information

Operating system security models

Operating system security models Operating system security models Unix security model Windows security model MEELIS ROOS 1 General Unix model Everything is a file under a virtual root diretory Files Directories Sockets Devices... Objects

More information

Why are your linux files secure?

Why are your linux files secure? Security Page 1 Why are your linux files secure? Thursday, November 29, 2012 10:48 AM Why are your linux files secure? Part 1: the concept of identity. user, group,... Part 2: the concept of protection.

More information

which maintain a name to inode mapping which is convenient for people to use. All le objects are

which maintain a name to inode mapping which is convenient for people to use. All le objects are UNIX Directory Organization UNIX directories are simple (generally ASCII) les which maain a name to inode mapping which is convenient for people to use. All le objects are represented by one or more names

More information

Chp1 Introduction. Introduction. Objective. Logging In. Shell. Briefly describe services provided by various versions of the UNIX operating system.

Chp1 Introduction. Introduction. Objective. Logging In. Shell. Briefly describe services provided by various versions of the UNIX operating system. Chp1 Objective Briefly describe services provided by various versions of the UNIX operating system. Logging In /etc/passwd local machine or NIS DB root:x:0:1:super-user:/root:/bin/tcsh Login-name, encrypted

More information

Unix Basics. UNIX Introduction. Lecture 14

Unix Basics. UNIX Introduction. Lecture 14 Unix Basics Lecture 14 UNIX Introduction The UNIX operating system is made up of three parts; the kernel, the shell and the programs. The kernel of UNIX is the hub of the operating system: it allocates

More information

Memento: Time Travel for the Web

Memento: Time Travel for the Web Old Dominion University ODU Digital Commons Computer Science Presentations Computer Science 11-10-2010 Herbert Van de Sompel Michael L. Nelson Old Dominion University, mnelson@odu.edu Robert Sanderson

More information

Operating Systems Lab

Operating Systems Lab Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 4 Paths, Links & File Permissions

More information

System Programming. Introduction to Unix

System Programming. Introduction to Unix Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Introduction 2 3 Introduction

More information

Files and directories. Updated by: Dr. Safwan Qasem Spring 2010 Original version created by: Dr. Mohamed El Bachir Menai

Files and directories. Updated by: Dr. Safwan Qasem Spring 2010 Original version created by: Dr. Mohamed El Bachir Menai Files and directories Updated by: Dr. Safwan Qasem Spring 2010 Original version created by: Dr. Mohamed El Bachir Menai 1 Files and Directories Objectives Additional Features of the File System Properties

More information

System-Level I/O. Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O

System-Level I/O. Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O System-Level I/O Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O A Typical Hardware System CPU chip register file ALU system bus memory bus bus

More information

CIS Operating Systems File Systems Security. Professor Qiang Zeng Fall 2017

CIS Operating Systems File Systems Security. Professor Qiang Zeng Fall 2017 CIS 5512 - Operating Systems File Systems Security Professor Qiang Zeng Fall 2017 Previous class File and directory Hard link and soft link Mount Layered structure File system design Naïve: linked list

More information

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst Clicker Question #1 For a sequential workload, the limiting factor for a disk system is likely: (A) The speed of

More information

Processes are subjects.

Processes are subjects. Identification and Authentication Access Control Other security related things: Devices, mounting filesystems Search path TCP wrappers Race conditions NOTE: filenames may differ between OS/distributions

More information

Overview. Unix System Programming. Outline. Directory Implementation. Directory Implementation. Directory Structure. Directories & Continuation

Overview. Unix System Programming. Outline. Directory Implementation. Directory Implementation. Directory Structure. Directories & Continuation Overview Unix System Programming Directories & Continuation Maria Hybinette, UGA 1 Last Week: Efficiency read/write The File File pointer File control/access Permissions, Meta Data, Ownership, umask, holes

More information

Original ACL related man pages

Original ACL related man pages Original ACL related man pages NAME getfacl - get file access control lists SYNOPSIS getfacl [-drlpvh] file... getfacl [-drlpvh] - DESCRIPTION For each file, getfacl displays the file name, owner, the

More information

ELEC-C7310 Sovellusohjelmointi Lecture 3: Filesystem

ELEC-C7310 Sovellusohjelmointi Lecture 3: Filesystem ELEC-C7310 Sovellusohjelmointi Lecture 3: Filesystem Risto Järvinen September 21, 2015 Lecture contents Filesystem concept. System call API. Buffered I/O API. Filesystem conventions. Additional stuff.

More information

OPERATING SYSTEMS: Lesson 12: Directories

OPERATING SYSTEMS: Lesson 12: Directories OPERATING SYSTEMS: Lesson 12: Directories Jesús Carretero Pérez David Expósito Singh José Daniel García Sánchez Francisco Javier García Blas Florin Isaila 1 Goals To know the concepts of file and directory

More information

Processes are subjects.

Processes are subjects. Identification and Authentication Access Control Other security related things: Devices, mounting filesystems Search path Race conditions NOTE: filenames may differ between OS/distributions Principals

More information

void clearerr(file *stream); int feof(file *stream); int ferror(file *stream); int fileno(file *stream); #include <dirent.h>

void clearerr(file *stream); int feof(file *stream); int ferror(file *stream); int fileno(file *stream); #include <dirent.h> opendir/readdir(3) opendir/readdir(3) fileno(3) fileno(3) opendir open a directory / readdir read a directory clearerr, feof, ferror, fileno check and reset stream status #include #include

More information

Permission and Ownership

Permission and Ownership Permission and Ownership 1. Understanding file and directory ownership Every file on your Linux system, including directories, is owned by a specific user and group. Therefore, file permissions are defined

More information

Operating Systems. Processes

Operating Systems. Processes Operating Systems Processes 1 Process Concept Process a program in execution; process execution progress in sequential fashion Program vs. Process Program is passive entity stored on disk (executable file),

More information

CSCE 313 Introduction to Computer Systems

CSCE 313 Introduction to Computer Systems CSCE 313 Introduction to Computer Systems Instructor: Dr. Guofei Gu http://courses.cse.tamu.edu/guofei/csce313 The UNIX File System File Systems and Directories Accessing directories UNIX s Understanding

More information

HEC POSIX I/O API Extensions Rob Ross Mathematics and Computer Science Division Argonne National Laboratory

HEC POSIX I/O API Extensions Rob Ross Mathematics and Computer Science Division Argonne National Laboratory HEC POSIX I/O API Extensions Rob Ross Mathematics and Computer Science Division Argonne National Laboratory rross@mcs.anl.gov (Thanks to Gary Grider for providing much of the material for this talk!) POSIX

More information

Outline. UNIX security ideas Users and groups File protection Setting temporary privileges. Examples. Permission bits Program language components

Outline. UNIX security ideas Users and groups File protection Setting temporary privileges. Examples. Permission bits Program language components UNIX security Ulf Larson (modified by Erland Jonsson/Magnus Almgren) Computer security group Dept. of Computer Science and Engineering Chalmers University of Technology, Sweden Outline UNIX security ideas

More information

The UNIX File System. File Systems and Directories UNIX inodes Accessing directories Understanding links in directories.

The UNIX File System. File Systems and Directories UNIX inodes Accessing directories Understanding links in directories. The UNIX File System File Systems and Directories UNIX s Accessing directories Understanding links in directories Reading: R&R, Ch 5 Directories Large amounts of data: Partition and structure for easier

More information

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1 bash startup files Linux/Unix files stty Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 midterms (Feb 27 and April 10) bash startup files More Linux Files review stty 2 We customize our

More information

Operating systems fundamentals - B10

Operating systems fundamentals - B10 Operating systems fundamentals - B10 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems fundamentals - B10 1 / 12 Introduction Basics of protection and security

More information

UNIX File Hierarchy: Structure and Commands

UNIX File Hierarchy: Structure and Commands UNIX File Hierarchy: Structure and Commands The UNIX operating system organizes files into a tree structure with a root named by the character /. An example of the directory tree is shown below. / bin

More information

Permissions User and Administrator Guide

Permissions User and Administrator Guide Permissions User and Administrator Guide Table of contents 1 Overview...2 2 User Identity...2 3 Understanding the Implementation...3 4 Changes to the File System API... 3 5 Changes to the Application Shell...4

More information

CSCI 4500/8506 Operating Systems Some UNIX System Calls, Library, and PThreads Functions

CSCI 4500/8506 Operating Systems Some UNIX System Calls, Library, and PThreads Functions CSCI 4500/8506 Operating Systems Some UNIX System Calls, Library, and PThreads Functions Described below is a subset of UNIX system calls, library functions, and Pthreads (that is, POSIX Threads) functions.

More information

FILE SYSTEMS. Tanzir Ahmed CSCE 313 Fall 2018

FILE SYSTEMS. Tanzir Ahmed CSCE 313 Fall 2018 FILE SYSTEMS Tanzir Ahmed CSCE 313 Fall 2018 References Previous offerings of the same course by Prof Tyagi and Bettati Textbook: Operating System Principles and Practice 2 The UNIX File System File Systems

More information

Input & Output 1: File systems

Input & Output 1: File systems Input & Output 1: File systems What are files? A sequence of (usually) fixed sized blocks stored on a device. A device is often refered to as a volume. A large device might be split into several volumes,

More information

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand

Fall 2017 :: CSE 306. File Systems Basics. Nima Honarmand File Systems Basics Nima Honarmand File and inode File: user-level abstraction of storage (and other) devices Sequence of bytes inode: internal OS data structure representing a file inode stands for index

More information