Lecture 5 Software Development under Unix - PowerPoint PPT Presentation

Loading...

PPT – Lecture 5 Software Development under Unix PowerPoint presentation | free to view - id: 15733b-ZDc1Z



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Lecture 5 Software Development under Unix

Description:

Lecture 5. Software Development under Unix. Topics. File systems revisited ... http://cm.bell-labs.com/cm/cs/who/dmr/chist.html (Ritchie Article on the history ... – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 17
Provided by: mantonm5
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Lecture 5 Software Development under Unix


1
Lecture 5 Software Development under Unix

CSCE 510 Systems Programming
  • Topics
  • File systems revisited
  • Directories
  • Libraries archives
  • Ar

September 1, 2005
2
  • Last Time
  • xx
  • Today
  • Overview of the Compilation Process
  • Files Systems revisited
  • Next Time
  • yy
  • Handouts
  • C Reference Card
  • http//cm.bell-labs.com/cm/cs/who/dmr/chist.html
    (Ritchie Article on the history of C )

3
File systems
  • File systems
  • 1.boot block
  • 2.super block
  • 3.inode table
  • 4.data blocks

4
Original Unix File system
  • Disk Block Pointers
  • 10 direct pointers
  • single indirect pointer
  • double indirect pointer
  • triple indirect pointer
  • Assuming 32 bit words, 24 bit disk block pointers
    and 512 byte blocks what is the largest possible
    file using the original Unix Scheme?

5
Adding Directories
  • Commands mkdir
  • From in a program
  • int mkdir ( const char path, mode_t mode )

6
Directory Entries
  • /usr/include/dirent.h
  • struct dirent
  • ino_t d_ino
  • char d_nameNAME_MAX 1

7
Directory functions
  • DIR opendir(const char path)
  • struct dirent readdir(DIR dp)
  • void rewinddir(DIR dp)
  • int closedir(DIR dp)
  • int rmdir(const char path)
  • mkdir

8
File Times
  • Times in stat struct of inode
  • st_atime "last access time" (ls -ul)
  • st_mtime "last modification time" (ls -l)
  • st_ctime "last inode change time" chmod, chown,
    (ls -cl)
  • time_t time in seconds since 000000 GMT, Jan
    1, 1970
  • /usr/include/time.h
  • struct utimbuf
  • time_t actime / access time /
  • time_t modtime / modification time /
  • int utime(const path, struct utimbuf times) /
    set times/

9
Ls1.c
  • main(int argc, char argv)
  • DIR dp
  • struct dirent dirp
  • if (argc ! 2)
  • err_quit("a single argument (the
    directory name) is required")
  • if ( (dp opendir(argv1)) NULL)
  • err_quit("can't open ")
  • while ( (dirp readdir(dp)) ! NULL)
  • printf("7d\ts\n", dirp-gtd_ino,
    dirp-gtd_name)
  • closedir(dp)

10
AR - archive and library maintainer
  • A file produced by ar has a magic string at the
    start, followed by the constituent files, each
    preceded by a file header. The magic number and
    header layout as described in the include file
    are
  • struct ar_hdr
  • char ar_name16
  • char ar_date12
  • char ar_uid6
  • char ar_gid6
  • char ar_mode8
  • char ar_size10
  • char ar_fmag2

11
TSEARCH(3) Linux
  • NAME
  • tsearch, tfind, tdelete, twalk - manage a
    binary tree
  • SYNOPSIS
  • include ltsearch.hgt
  • void tsearch(const void key, void
    rootp,
  • int(compar)(const void ,
    const void ))
  • void tfind(const void key, const void
    rootp,
  • int(compar)(const void ,
    const void ))
  • void tdelete(const void key, void
    rootp,
  • int(compar)(const void ,
    const void ))
  • void twalk(const void root,
    void(action)(const void nodep,
  • const
    VISIT which,
  • const
    int depth))

12
  • int compare(const void pa, const void pb)
  • if((int )pa lt (int )pb) return
    -1
  • if((int )pa gt (int )pb) return
    1
  • return 0

13
(No Transcript)
14
(No Transcript)
15
(No Transcript)
16
(No Transcript)
About PowerShow.com