งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

การทำงานกับ Files ธวัชชัย เอี่ยมไพโรจน์. UNIX File Structure ดูรายละเอียดได้ที่ 404/doc/file.ppt บน UNIX ทุกๆ อย่างเป็น.

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "การทำงานกับ Files ธวัชชัย เอี่ยมไพโรจน์. UNIX File Structure ดูรายละเอียดได้ที่ 404/doc/file.ppt บน UNIX ทุกๆ อย่างเป็น."— ใบสำเนางานนำเสนอ:

1 การทำงานกับ Files ธวัชชัย เอี่ยมไพโรจน์

2 UNIX File Structure ดูรายละเอียดได้ที่ http://lecture.compsci.buu.ac.th/~f44 404/doc/file.ppt บน UNIX ทุกๆ อย่างเป็น File ตั้งแต่ disk files, serial ports, printers และอุปกรณ์ อื่นๆ สามารถใช้ basic functions ต่อไปนี้จัดการ ได้หมด open, close, read, write, ioctl

3 คำสั่งที่ควรศึกษา od -c od -d คำถาม คำสั่งทั้ง 2 ทำอะไรกับ File inode คืออะไร ?

4 Files / Devices /dev/console /dev/tty /dev/null system calls : เป็นบริการจาก UNIX และ ติดต่อโดยตรงกับ OS device drivers: เป็น low level interfaces สำหรับควบคุม Hardware

5 System called สำหรับ device drivers Open a file or device. : open Read from an open file or device. : read Write to a file or device. : write Close the file or device. : close Specific control the device. : ioctl ioctl( ) ของแต่ละเครื่องอาจแตกต่างกันได้

6 ประสิทธิภาพ UNIX ต้อง switch จากโปรแกรม แล้วไป run kernel code แล้วต้อง switch กลับมา อีก Hardware limit เกี่ยวกับขนาดของ data blocks ซึ่ง low level function call สามารถ ใช้ได้มีขนาดจำกัด นิยมใช้ Library Functions เช่น stdio.h แทน แต่ยังมีที่จำเป็นต้องใช้อีกมาก

7 Low-level File Access 0 : standard input 1: standard output2 : standard error write ดูโปรแกรมตัวอย่างที่ http://lecture.compsci.buu.ac.th/~f44213 /samples/jun26/write.c read ดูโปรแกรมตัวอย่างที่ http://lecture.compsci.buu.ac.th/~f44213 /samples/jun26/read.c open close ioctl

8 A File Copy Program ศึกษาได้จาก http://lecture.compsci.buu.ac.th/~f4421 3/samples/jun26/system.c

9 lseek เป็น low level system call ในการหา ตำแหน่งใน file SEEK_SET SEEK_CUR SEEK_END man lseek

10 get file status system call stat : fstat : lstat struct stat { dev_t st_dev; /* device */ ino_t st_ino; /* inode */ ….. }; เป็น structure ที่ต้องศึกษาให้เข้าใจ

11 dup และ dup2 duplicate a file descriptor #include int dup(int oldfd); int dup2(int oldfd, int newfd);

12 File Maintenance (man 2 ) chmod int chmod(const char *path, mode_t mode); chown int chown(const char *path, uid_t owner, gid_t group); link int link(const char *oldpath, const char *newpath); unlink int unlink(const char *pathname);

13 Directories Maintenance (man 2 ) mkdir int mkdir(const char *pathname, mode_t mode); rmdir int rmdir(const char *pathname); chdir int chdir(const char *path); getcwd [man getcwd] char *getcwd(char *buf, size_t size);


ดาวน์โหลด ppt การทำงานกับ Files ธวัชชัย เอี่ยมไพโรจน์. UNIX File Structure ดูรายละเอียดได้ที่ 404/doc/file.ppt บน UNIX ทุกๆ อย่างเป็น.

งานนำเสนอที่คล้ายกัน


Ads by Google