Download presentation
Presentation is loading. Please wait.
1
CS 311 – Lecture 13 Outline File management system calls chown() chmod() dup() and dup2() link() Lecture 131CS 311 - Operating Systems 1
2
chown() Changes the owner and/or group of a file Prototype: int chown (const char* filename, uid_t ownerid, gid_t groupid) int lchown (const char* filename, uid_t ownerid, gid_t groupid) int fchown (int fd, uid_t ownerid, gid_t groupid) A value of -1 for ownerid and groupid means that the field should be left unchanged. Lecture 122CS 311 - Operating Systems 1
3
chmod() Changes the file permissions Prototype: int chmod (const char* filename, int mode) int fchmod (int fd, mode_t mode) mode – octal representation for file permissions Lecture 133CS 311 - Operating Systems 1
4
dup() Duplicate a file descriptor. Fd duplication done internally when a pipe or redirection takes place. Prototype: int dup (int oldFd) int dup2 (int oldfd, int newfd) – closes newfd if its active and then points it to the same file as oldfd. Lecture 134CS 311 - Operating Systems 1
5
Link() Creates hard links to an existing file. Prototype: int link(const char* oldpath, const char* newpath) Creates a new label called newpath and links it to the same file referred by oldpath. Returns -1 if unsuccessful and 0 otherwise. Lecture 135CS 311 - Operating Systems 1
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.