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

Size: px
Start display at page:

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

Transcription

1 Files and Directories Objectives Additional Features of the File System Properties of a File. Three major functions that return file information: #include <sys/types.h> #include <sys/stat.h> int stat(const char *pathname, struct stat *buf); int fstat(int filedes, struct stat *buf); int lstat(const char *pathname, struct stat *buf); Return: 0 if OK, -1 on error 1

2 Files and Directories UNIX kernel maintains considerable details about every file system object whether it is: File Directory Special device Named pipe (FIFO) stat(), fstat(), and lstat() return information about file system objects in a structure named stat. 2

3 Files and Directories Differences on stat(), fstat(), lstat(). lstat() similar to stat(), except that, when file is a symbolic link, it returns info regarding the symbolic link itself, not the referenced file. File info is returned in buf defined as the following structure: struct stat { mode_t st_mode; /* type & mode */ ino_t st_ino; /* i-node number */ dev_t st_dev; /* device no (filesystem) */ dev_t st_rdev; /* device no for special file */ nlink_t st_nlink; /* # of links */ uid_t st_uid; gid_t st_gid; off_t st_size; /* sizes in bytes */ time_t st_atime; /* last access time */ time_t st_mtime; /* last modification time */ time_t st_ctime; /* time for last status change */ long st_blksize; /* best I/O block size */ long st_blocks; /* number of 512-byte blocks allocated */ }; 3

4 File Types Regular Files: text, binary, etc. Directory Files: Only Kernel can update these files { (filename, i-node pointer) }. Character Special Files, e.g., tty, audio, etc. Block Special Files, e.g., disks, etc. FIFO named pipes Sockets Symbolic Links not POSIX.1 or SVR4 4

5 File Types File types can be determined using following macros; argument of macro is st_mode (which encodes file type) member from the stat structure. Macro S_ISREG() S_ISDIR() S_ISCHR() S_ISBLK() S_ISFIFO() S_ISLNK() S_ISSOCK() Type of File Regular file Directory Character special file Block special file FIFO or PIPE Symbolic link Socket 5

6 #include <sys/types.h> #include <sys/stat.h> int main(int argc, char *argv[]) { int i; struct stat buf; char *ptr; for (i = 1; i < argc; i++) { printf("%s: ", argv[i]); if (lstat(argv[i], &buf) < 0) { err_ret( lstat error"); continue; } if (S_ISREG(buf.st_mode)) ptr = "regular"; else if (S_ISDIR(buf.st_mode)) ptr = "directory"; else if (S_ISCHR(buf.st_mode)) ptr = "character special"; else if (S_ISBLK(buf.st_mode)) ptr = "block special"; else if (S_ISFIFO(buf.st_mode)) ptr = "fifo"; #ifdef S_ISLNK /* only for BSD */ else if (S_ISLNK(buf.st_mode)) ptr = "symbolic link"; #endif #ifdef S_ISSOCK /* only for BSD */ else if (S_ISSOCK(buf.st_mode)) ptr = "socket"; #endif } } exit(0); else ptr = "** unknown mode **"; printf("%s\n", ptr); 6

7 File Types Example of execution: $ a.out /vmunix /etc /dev/ttya /dev/hd0a gives: /vmunix: regular file /etc: directory /dev/ttya: character special device /dev/hd0a: block special device 7

8 Set-User-ID and Set-Group-ID Every process has 6 or more IDs associated with it. Real user ID Real group ID Effective user ID Effective group ID Supplementary group ID Saved set-user-id Saved set-group-id who we really are Used for file access permission checks Saved by exec function Real user ID and real group ID are taken from user entry in passwd file when user logs in. No change during a login session. Effective IDs and supplementary IDs control user file access permissions. Saved IDs contain copies of effective IDs when a program is executed. 8

9 Set-User-ID and Set-Group-ID Every file has an owner and a group owner. -The owner is specified by the st_uid of the stat structure. -The group owner is specified by the st_gid member. When a program is executed, -The effective user is usually the real user. -The effective group ID is usually the real group ID. The flag st_mode can be used to set the effective user ID of the process to be the owner of the file (st_uid). Similarly the effective group ID can be set to be the group owner of the file. Example: Passwd(1) is a UNIX system program that allows anyone to change his or her password. This program is a set-user-id program. The program needs to write the new password to the password file (/etc/passwd or /etc/shadow) that should be writable only by the superuser set-user-id and set-group-id bits contained in the st_mode word can be tested through stat function using constants S_ISUID and S_ISGID. 9

10 File Access Permissions st_mode word encodes access permissions for files and directories as Permission Bits According to permissions, allowed operations are: For a Directory * X pass through the dir (search bit). Example: to open file /usr/student/ali, we need execute permissions in /usr and in /usr/student. * R list of files under the directory (different from X!) * W update the dir, e.g., delete or create a file (both need also X bit). For a File * X execute a file (which must be a regular file) * R can open file for reading. O_RDONLY or O_RDWR * W can open file for writing. O_WRONLY, O_RDWR, or O_TRUNC 10

11 Permission bits st_mode mask S_IRUSR S_IWUSR S_IXUSR S_IRGRP S_IWGRP S_IXGRP S_IROTH S_IWOTH S_IXOTH meaning User ( i.e OWNER) read User ( i.e OWNER) write User ( i.e OWNER) execute Group read Group write Group execute Other read Other write Other execute 11

12 Access Permissions & UID/GID File Access Test: Tests performed by OS when process opens, creates or deletes file. Depend on the owners of the file (st_uid, st_gid), the effective IDs of the process (EUID, EGID) and the supplementary groups. 1. If the effective UID == 0 superuser! access allowed 2. If the effective UID == owner UID of the file If appropriate access permissions, access allowed, otherwise denied 3. If the effective GID == owner GID of the file If appropriate access permissions, access allowed, otherwise denied 4. Check appropriate access permissions for others same way. These 4 steps are tried in sequence. Related Commands: chmod & umask 12

13 Ownership of a New File UID of a new file = the effective UID of the creating process. GID of a new file 2 options defined by POSIX: 1. GID of the new file = the effective GID of the process 2. GID of the new file = the GID of the directory in which the file is created. 13

14 Function access: file accessibility tests Accessibility tests are performed by OS on open operation, based on effective UID and GID. Sometimes, need to test accessibility for a file based on real UID and GID. #include <unistd.h> int access(const char *pathname, int mode); Returns: 0 if OK, -1 on error mode is the bitwise OR of any of the constants: R_OK, W_OK, X_OK, F_OK (file existence) 14

15 #include <sys/types.h> #include <fcntl.h> int main(int argc, char *argv[]) { if (argc!= 2) err_quit("usage: a.out <pathname>"); if (access(argv[1], R_OK) < 0) err_ret("access error for %s", argv[1]); else printf("read access OK\n"); if (open(argv[1], O_RDONLY) < 0) err_ret("open error for %s", argv[1]); else printf("open for reading OK\n"); exit(0); } Example of execution: $ a.out a.out read access OK open for reading OK 15

16 Function umask Defines the file mode CREATION MASK. The permissions defined in the mask will be used as default permissions for newly created files. Function umask sets the file mode creation mask for the process and returns the previous value. #include <sys/types.h> #include <sys/stat.h> mode_t umask(mode_t cmask); Returns: previous file mode creation mask cmask = bitwise OR of any of file permissions (S_IRUSR, S_IWUSR, S_IXUSR ). Any bits set in cmask are turned OFF in file mode. 16

17 #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #define RWRWRW (S_IRUSR S_IWUSR S_IRGRP S_IWGRP S_IROTH S_IWOTH) int main(void) { umask(0); /* ensure that anyone can read a file */ if (creat("foo", RWRWRW) < 0) err_sys("creat error for foo"); /* disable all the group and other permission bits */ umask(s_irgrp S_IWGRP S_IROTH S_IWOTH); } if (creat("bar", RWRWRW) < 0) err_sys("creat error for bar"); exit(0); 17

18 Example of execution: $ umask 02 $ a.out $ ls l foo bar -rw bar -rw-rw-rw- foo $ umask 02 shell s umask command is used to print the file mode creation mask before the program is run. Changing the file mode of a process doesn t affect the mask of its parent. 18

19 umask file access permission bits 0400: user-read 0200: user-write 0100: user-execute 0040: group-read 0020: group-write 0010: group-execute 0004: other-read 0002: other-write 0001: other-execute Common umask values 0: anyone can read 002: prevent others from writing 022:prevent group members and others from writing your files 027: prevent group members from writing your files and others from reading, writing, or executing your files. 19

20 Functions chmod & fchmod Change file access permissions for an existing file. #include <sys/types.h> #include <sys/stat.h> int chmod(const char *pathname, mode_t mode); int fchmod(int filedes, mode_t mode); Both return: 0 if OK, -1 on error chmod function operates on the specified file fchmod function operates on a file that has already been opened. Callers must be a superuser or effective UID = file UID (file owner). mode = bitwise OR of constants defined in the next table. 20

21 mode description S_ISUID S_ISGID S_ISVTX S_IRWXU S_IRUSR S_IWUSR S_IXUSR S_IRWXG S_IRGRP S_IWGRP S_IXGRP S_IRWXO S_IROTH S_IWOTH S_IXOTH set-user-id on execution set-group-id on execution saved-text (sticky bit) R/W/E by user (owner) Read by user Write by user Execute by user R/W/E by group Read by group Write by group Execute by group R/W/E by others (world) Read by others Write by others Execute by others 21

22 S_ISUID When a process runs a regular file that has the S_ISUID bit set, the effective user ID of the process is set to the owner ID of the file. SUID option tells Linux to run the program with the permissions that runs the program. It is indicated by s in the owner s execute bit position: rwsr-xr-x e.g. if a file is owned by root and has its SUID bit set, the program runs with root privileges and can therefore read any file on the computer. S_ISGID When a process runs a regular file that has both the S_ISGID bit and the S_IXGRP permission bit set, the effective user ID of the process is set to the group ID of the file. It is indicated by s in the group execute bit position: rwxr-sr-x 22

23 Sticky bit In modern Linux implementations, the sticky bit is used to protect files from being deleted by those who don t own the file. When this bit is present on a directory, the directory s files can only be deleted by their owners, the directory s owner or root. The sticky bit is indicated by a t in the others execute bit, rwxr-xr-t 23

24 #include <sys/types.h> #include <sys/stat.h> int main(void) { struct stat statbuf; /* turn on group-execute relative to current mode*/ if (stat("foo", &statbuf) < 0) err_sys("stat error for foo"); if (chmod("foo", (statbuf.st_mode & S_IXGRP) )< 0) err_sys("chmod error for foo"); /* set absolute mode to "rw-r--r--" */ if (chmod("bar", S_IRUSR S_IWUSR S_IRGRP S_IROTH) < 0) err_sys("chmod error for bar"); } exit(0); 24

25 Before change $ ls l foo bar -rw rw-rw-rw- foo bar After change $ ls l foo bar -rw-r--r-- -rw-rwxrw- foo bar 25

26 Functions chown, fchown, lchown #include <sys/types.h> #include <unistd.h> int chown(const char *pathname, uid_t owner, gid_t grp); int fchown(int filedes, uid_t owner, gid_t, grp); int lchown(const char *pathname, uid_t owner, gid_t grp); All three return: 0 if OK, -1 on error Only owner of a file can change file ownership. if either of the arguments owner or group is -1, the corresponding ID is left unchanged. 26

27 File Systems A hierarchical arrangement of directories and files starting in root /. Typical physical organization of disks and file systems is as follows: 27

28 File Systems i-node: fixed length entries that contain most of file info. Most info in stat structure comes from i-node. Version 7: 64Bytes, 4.4 BSD:128B File type, access permission, file size, data blocks, link count (hard links) see fig above with 2 directories pointing to same i-node. File can be deleted only when link count=0. UNLINK a file does not mean always DELETE a file!!! link count is contained in st_nlink (in stat). LINK_MAX (POSIX.1) defines max number of links. 28

29 Hard links UNIX filenames are pointers to files Linking to an existing file: shell ln omar ali system call link ( omar, ali ) File omar must already exist unlink simply removes a pointer File destroyed only when last link goes ali omar 29

30 Functions link, unlink link function creates a new dir entry that references an existing file. unlink function removes an existing dir entry and decrements the link count of the file. #include <unistd.h> int link(const char *existingpath, const char *newpath); int unlink(const char *pathname); Both return: 0 if OK, -1 on error 30

31 Example #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(void) { if (open("tempfile", O_RDWR) < 0) err_sys("open error"); if (unlink("tempfile") < 0) err_sys("unlink error"); printf("file unlinked\n"); sleep(15); printf("done\n"); exit(0); } 31

32 Functions rename, remove remove = rmdir if pathname is a dir. (ANSI C) rename ANSI C File: both files, newname is removed first, WX permission for both residing directories Directory: both dir, newname must be empty, newname could not contain oldname. #include <stdio.h> int remove(const char *pathname); int rename(const char *oldname, const char *newname); Both return: 0 if OK, -1 on error 32

33 Functions rename, remove Only possible within a file system newname is unlinked newname is linked to the file pointed to by oldname oldname is unlinked e.g. rename (ali, omar) ali omar ali omar 33

34 Symbolic links Hard links are limited: Cannot link to a different disk Generally only one link to a directory Symbolic links are more flexible shell ln s omar ali system call symlink ( omar, ali ) omar needs not exist ali points to the name omar (alias) ali omar 34

35 Symbolic Links: symlink, readlink #include <unistd.h> /* Create a new symbolic link: */ int symlink(const char *actualpath, const char *sympath); /* read symbolic link itself into buf*/ ssize_t readlink(const char *pathname, char *buf, int bufsize); Both return: 0 if OK, -1 on error symlink: A new dir entry sympath is created that points to actualpath. readlink is an action consisting of open, read, and close of a symbolic link. Returns symlink as non-null terminated string. 35

36 Functions mkdir and rmdir #include <sys/types.h> #include <sys/stat.h> int mkdir(const char *pathname, mode_t mode); Returns: 0 if OK, -1 on error The function mkdir creates a new empty directory. Access permissions mode modified according to umask. #include <unistd.h> int rmdir(const char *pathname); Returns: 0 if OK, -1 on error An empty dir is deleted. Condition: link count reaches zero, and no one still opens the dir. 36

37 Directory structure dirent struct is defined in the file <dirent.h>. It is very much implementation dependent. It contains at least the following two members: struct dirent { ino_t d_ino; /* i-node number */ char d_name[name_max+1]; /* nullterminated file name */ } The DIR structure is an internal structure used by above functions. It has similar role to FILE structure for buffered IO. Pointer to DIR structure returned by opendir is used with all other functions. opendir makes necessary initializations of DIR struct so that readdir reads 1rst entry of directory. 37

38 Functions opendir, readdir, rewinddir, closedir #include <sys/types.h> #include <dirent.h> DIR *opendir(const char *pathname); Returns: pointer if OK, NULL on error. struct dirent *readdir(dir *dp); Returns: pointer if OK, NULL at end of directory or error. void rewinddir(dir *dp); int closedir(dir *dp); Both return: 0 if OK, -1 on error 38

39 Functions telldir and seekdir #include <sys/types.h> #include <dirent.h> long telldir(dir *dp); Returns: current location in directory associated with dp, -1 on error. void seekdir(dir *dp, long loc); telldir returns an offset into the directory for later use by seekdir function. The offset returned is greater than or equal to zero. seekdir is used to restore the directory position. No success or position is returned for this call. 39

40 Functions telldir and seekdir, cont. Example: #include <sys/types.h> #include <dirent.h> DIR *dirp; /* open DIR pointer */ long dirpos; /* directory offset */ dirpos = telldir(dirp); /* get offset in directory */ seekdir(dirpos); /* restore directory position */ 40

41 Functions scandir and alphasort #include <sys/types.h> #include <dirent.h> int scandir( const char *dirname, struct dirent **namelist, int (*select)(struct dirent *), int (*compar)(const void *, const void *)); int alphasort (const void *d1, const void *d2); 41

42 Functions scandir and alphasort, cont. scandir() reads the directory dirname and builds an array of pointers to directory entries or -1 for an error. namelist is a pointer to an array of structure pointers. (*select)() is a pointer to a function which is called with a pointer to a directory entry (defined in <sys/types> and should return a non zero value if the directory entry should be included in the array. If this pointer is NULL, then all the directory entries will be included. The last argument is a pointer to a routine which is passed to qsort (see man qsort) -- a built in function which sorts the completed array. If this pointer is NULL, the array is not sorted. The function alphasort() can be supplied in the argument compar if you require the namelist be sorted alphabetically. 42

43 Functions scandir and alphasort, cont. /* Example - a simple C version of UNIX ls utility */ #include <sys/types.h> #include <sys/dir.h> #include <sys/param.h> #include <stdio.h> #define FALSE 0 #define TRUE!FALSE extern int alphasort(); char pathname[maxpathlen]; 43

44 Functions scandir and alphasort, cont. main() { int count,i; struct direct **files; int file_select(); if (getwd(pathname) == NULL ) { printf("error getting path\n"); exit(0); } printf("current Working Directory = %s\n",pathname); count = scandir(pathname, &files, file_select, alphasort); /* If no files found, make a non-selectable menu item */ if (count <= 0) { printf(``no files in this directory\n''); exit(0); } printf(``number of files = %d\n'',count); for (i=1;i<count+1;++i) printf(``%s '',files[i-1]->d_name); printf(``\n''); /* flush buffer */ } 44

45 Functions scandir and alphasort, cont. int file_select(struct direct *entry) { if ((strcmp(entry->d_name, ``.'') == 0) (strcmp(entry->d_name, ``..'') == 0)) return (FALSE); else return (TRUE); } scandir returns the current directory (.) and the directory above this (..) as well as all files so we need to check for these and return FALSE so that they are not included in our list. Note: scandir and alphasort have definitions in sys/types.h and sys/dir.h. MAXPATHLEN and getwd definitions in sys/param.h 45

46 Functions scandir and alphasort, cont. We can go further than this and search for specific files: Let's write a modified file_select() that only scans for files with a.c,.o or.h suffix: int file_select(struct direct *entry) { char *ptr; char *rindex(char *s, char c); if ((strcmp(entry->d_name, ``.'')== 0) (strcmp(entry->d_name, ``..'') == 0)) return (FALSE); /* Check for filename extensions */ ptr = rindex(entry->d_name, '.') if ((ptr!= NULL) && ((strcmp(ptr, ``.c'') == 0) (strcmp(ptr, ``.h'') == 0) (strcmp(ptr, ``.o'') == 0) )) return (TRUE); else return(false); } Note: rindex() is a string handling function that returns a pointer to the last occurrence of character c in string s, or a NULL pointer if c does not occur in the string. (index() is similar function but assigns a pointer to 1st occurrence.) 46

47 Functions chdir, fchdir, and getcwd Functions chdir and fchdir let to specify the current directory either as a pathname or through an open file descriptor. #include <unistd.h> int chdir(const char *pathname); int fchdir(int filedes); Both return: 0 if OK, -1 on error #include <unistd.h> char *getcwd(char *buf, size_t size); Returns: buf if OK, NULL on error The getcwd() function copies the absolute pathname of the current working directory to the array pointed to by buf, which is of length size. 47

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

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 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

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

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

Files and Directories E. Im

Files and Directories E. Im Files and Directories 2009 E. Im 1 How to write the ls program? Is this a directory? Permissions for the owner Permissions for the members of the owner group group Symbolic links ($ln -s RigidBodyWin.h

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

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

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

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

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

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

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

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

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

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

Linux C C man mkdir( ) mkdir Linux man mkdir mkdir( ) mkdir mkdir( )

Linux C C man mkdir( ) mkdir Linux man mkdir mkdir( ) mkdir mkdir( ) D Linux Linux E-D.1 Linux C C man mkdir( ) mkdir Linux man mkdir mkdir( ) mkdir mkdir( ) jhchen@aho:~$ man -S 2 mkdir Reformatting mkdir(2), please wait... MKDIR(2) Linux Programmer's Manual MKDIR(2) NAME

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

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 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

The link() System Call. Preview. The link() System Call. The link() System Call. The unlink() System Call 9/25/2017

The link() System Call. Preview. The link() System Call. The link() System Call. The unlink() System Call 9/25/2017 Preview The link() System Call link(), unlink() System Call remove(), rename() System Call Symbolic link to directory Symbolic link to a executable file symlink() System Call File Times utime() System

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

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

Thesis, antithesis, synthesis

Thesis, antithesis, synthesis Identity Page 1 Thesis, antithesis, synthesis Thursday, December 01, 2011 4:00 PM Thesis, antithesis, synthesis We began the course by considering the system programmer's point of view. Mid-course, we

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

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

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

Preview. lseek System Calls. A File Copy 9/18/2017. An opened file offset can be explicitly positioned by calling lseek system call.

Preview. lseek System Calls. A File Copy 9/18/2017. An opened file offset can be explicitly positioned by calling lseek system call. Preview lseek System Calls lseek() System call File copy dup() and dup2() System Cal Command Line Argument sat, fsat, lsat system Call ID s for a process File Access permission access System Call umask

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

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

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

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

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

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

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

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

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

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

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

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

System Calls and I/O Appendix. Copyright : University of Illinois CS 241 Staff 1

System Calls and I/O Appendix. Copyright : University of Illinois CS 241 Staff 1 System Calls and I/O Appendix Copyright : University of Illinois CS 241 Staff 1 More System Calls Directory and File System Management s = mkdir(name, mode) Create a new directory s = rmdir(name) s = link(name,

More information

INTRODUCTION TO THE UNIX FILE SYSTEM 1)

INTRODUCTION TO THE UNIX FILE SYSTEM 1) INTRODUCTION TO THE UNIX FILE SYSTEM 1) 1 FILE SHARING Unix supports the sharing of open files between different processes. We'll examine the data structures used by the kernel for all I/0. Three data

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

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

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

f90 unix file: Unix File Operations Module March 9, 2009

f90 unix file: Unix File Operations Module March 9, 2009 f90 unix file: Unix File Operations Module March 9, 2009 1 Name f90 unix file Module of Unix file operations 2 Usage USE F90 UNIX FILE This module contains part of a Fortran API to functions detailed in

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

FILE SYSTEMS. Jo, Heeseung

FILE SYSTEMS. Jo, Heeseung FILE SYSTEMS Jo, Heeseung TODAY'S TOPICS File system basics Directory structure File system mounting File sharing Protection 2 BASIC CONCEPTS Requirements for long-term information storage Store a very

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

0UNIT-III UNIX FILE SYSTEM

0UNIT-III UNIX FILE SYSTEM 1 0UNIT-III UNIX FILE SYSTEM UNIX System Overview UNIX Architecture Login Name Shells Files and Directories 1. File System 2. Filename 3. Pathname 4. Working Directory, Home Directory File Structures Files

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

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

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

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

ADVANCED OPERATING SYSTEMS UNIT 2 FILE AND DIRECTORY I/O BY MR.PRASAD SAWANT

ADVANCED OPERATING SYSTEMS UNIT 2 FILE AND DIRECTORY I/O BY MR.PRASAD SAWANT ADVANCED OPERATING SYSTEMS UNIT 2 FILE AND DIRECTORY I/O BY MR.PRASAD SAWANT OUT LINE OF SESSION 1. Buffer headers 2. structure of the buffer pool 3. scenarios for retrieval of a buffer 4. reading and

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

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

File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

File Systems Overview. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University File Systems Overview Jin-Soo Kim ( jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics File system basics Directory structure File system mounting

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

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

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

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls Lecture 3 Introduction to Unix Systems Programming: Unix File I/O System Calls 1 Unix File I/O 2 Unix System Calls System calls are low level functions the operating system makes available to applications

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

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

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

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

Preview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call

Preview. System Call. System Call. System Call. System Call. Library Functions 9/20/2018. System Call Preview File Descriptors for a Process for Managing Files write read open close lseek A system call is a request for the operating system to do something on behalf of the user's program. The system calls

More information

Parents and Children

Parents and Children 1 Process Identifiers Every process apart from the PID also has a PUID and a PGID. There are two types of PUID and PGID: real and effective. The real PUID is always equal to the user running the process

More information

CS 33. Files Part 2. CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

CS 33. Files Part 2. CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. CS 33 Files Part 2 CS33 Intro to Computer Systems XXI 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. Directories unix etc home pro dev passwd motd twd unix... slide1 slide2 CS33 Intro to Computer

More information

Programiranje za UNIX. Datoteke i direktoriji

Programiranje za UNIX. Datoteke i direktoriji Programiranje za UNIX Datoteke i direktoriji Sadržaj Svojstva UNIX datoteka Korisnici i prava Operacije sa linkovima Rad s direktorijima Sistemske datoteke Sistemske informacije 2 Svojstva datoteke Svojstva

More information

Introduction. Files. 3. UNIX provides a simple and consistent interface to operating system services and to devices. Directories

Introduction. Files. 3. UNIX provides a simple and consistent interface to operating system services and to devices. Directories Working With Files Introduction Files 1. In UNIX system or UNIX-like system, all input and output are done by reading or writing files, because all peripheral devices, even keyboard and screen are files

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

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

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

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

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

CMPSC 311- Introduction to Systems Programming Module: Input/Output

CMPSC 311- Introduction to Systems Programming Module: Input/Output CMPSC 311- Introduction to Systems Programming Module: Input/Output Professor Patrick McDaniel Fall 2014 Input/Out Input/output is the process of moving bytes into and out of the process space. terminal/keyboard

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

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

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

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

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

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

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

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

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

Unix File and I/O. Outline. Storing Information. File Systems. (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu

Unix File and I/O. Outline. Storing Information. File Systems. (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu Outline Unix File and I/O (USP Chapters 4 and 5) Instructor: Dr. Tongping Liu Basics of File Systems Directory and Unix File System: inode UNIX I/O System Calls: open, close, read, write, ioctl File Representations:

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

Linux Programming Chris Seddon

Linux Programming Chris Seddon Linux Programming Chris Seddon seddon-software@keme.co.uk 2000-9 CRS Enterprises Ltd 1 2000-9 CRS Enterprises Ltd 2 Linux Programming 1. The Unix Model 2. File Input and Output 3. Files and Directories

More information

CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O

CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O CMSC 216 Introduction to Computer Systems Lecture 17 Process Control and System-Level I/O Sections 8.2-8.5, Bryant and O'Hallaron PROCESS CONTROL (CONT.) CMSC 216 - Wood, Sussman, Herman, Plane 2 Signals

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

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

How do we define pointers? Memory allocation. Syntax. Notes. Pointers to variables. Pointers to structures. Pointers to functions. Notes.

How do we define pointers? Memory allocation. Syntax. Notes. Pointers to variables. Pointers to structures. Pointers to functions. Notes. , 1 / 33, Summer 2010 Department of Computer Science and Engineering York University Toronto June 15, 2010 Table of contents, 2 / 33 1 2 3 Exam, 4 / 33 You did well Standard input processing Testing Debugging

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

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

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 15: Unix interface: low-level interface Cristina Nita-Rotaru Lecture 15/Fall 2013 1 Streams Recap Higher-level interface, layered on top of the primitive file descriptor

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

System Calls and I/O. CS 241 January 27, Copyright : University of Illinois CS 241 Staff 1

System Calls and I/O. CS 241 January 27, Copyright : University of Illinois CS 241 Staff 1 System Calls and I/O CS 241 January 27, 2012 Copyright : University of Illinois CS 241 Staff 1 This lecture Goals Get you familiar with necessary basic system & I/O calls to do programming Things covered

More information