CS215 | CS215 Lab Assignment 7 – myls

CS215 Lab Assignment 7 – myls

DUE: Friday, 12/13/2019

In this lab we are going to work with the Posix file interface

Where to start Have a look at OSTEP, Ch. 39, especially 39.8 and 39.11. Read manual pages for stat(2), opendir(3), readdir(2), and scandir(3).

NOTE: As always, it’s optional, but strongly encouraged, to make your program verbose so that it’s printing what it’s doing – be thorough. Also, use “valgrind” to help you find bugs, especially memory leaks! You should aim to have no reported leaks at all.

Begin by running /bin/ls -ai1 [thing] on several things, both files and directories. Find some symbolic links and run it on those. Then do the same with /bin/ls -ail1 [thing] and figure out what all the columns mean.

Implement a version of your program that takes one argument and duplicates the output of /bin/ls -ai1 [thing] if thing is just a file. Note that this means finding the inode number of the file. Use lstat(2) to do this so that you are getting information about symbolic links themselves. As a general rule, if you find a type that is probably really a number, it’s probably safe to just cast it to int.

Implement a version of your program that can also handle directories as the argument, again duplicating the output of /bin/ls -ai1 [thing] . There’s some sample code in the man page of scandir(3) that could be very helpful here – you may just borrow it with attribution in a comment.

Implement a version of your program that duplicates the output of /bin/ls -ail1 [thing] on regular files and symbolic links. Don’t fuss too much about getting the date formatted correctly, but you might want to look at man pages for strftime and localtime. If you want to see how complex handling time is, man 7 time and settle in for a long read :-).

Finally, implement a version of your program that can duplicate the output of of /bin/ls -ail1 [thing] on directories. Getting the output correct for symbolic links is optional here, but would be quite impressive.

Optionally, implement a version of your program that can duplicate the output of of /bin/ls -Rail1 [thing] on directories. Good luck!

2019-12-07

Java

physics

LINUX

C++

Python

Processing

sas

ios

maths

maple

C语言

Internet and World Wide Web

Principles of Programming Languages

sql

scheme

prolog

JavaScript

Haskell

essay

Finance

Accounting

Rust

Economics

算法分析(Algorithm analysis)

MATLAB

Ethics

Chemistry

LaTeX

OCaml

SPSS

Project

ASP

Stata

FORTRAN

Information system

SDLC

Basic

Digital Media

Biological

Android

ruby

HTML/CSS

Scala

PHP语言

C#

R语言

发表评论

了解 KJESSAY历史案例 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读