0% found this document useful (0 votes)
37 views4 pages

B-PSU-100 My Ls

This document provides instructions for a programming assignment to recreate the ls command in C. It lists the allowed system calls and provides examples of how the command should function, including handling options and formatting output. Students are to submit all source code files in a delivery along with any bonus files in a separate bonus directory. The program must write error messages to standard error and return an error code.

Uploaded by

Ulrich ADEGOKE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views4 pages

B-PSU-100 My Ls

This document provides instructions for a programming assignment to recreate the ls command in C. It lists the allowed system calls and provides examples of how the command should function, including handling options and formatting output. Students are to submit all source code files in a delivery along with any bonus files in a separate bonus directory. The program must write error messages to standard error and return an error code.

Uploaded by

Ulrich ADEGOKE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

B1 - Unix System Programming

B-PSU-100

my_ls
LiSting command-like

2.3
my_ls
binary name: my_ls
language: C
compilation: via Makefile, including re, clean and fclean rules

• The totality of your source files, except all useless files (binary, temp files, obj
files,...), must be included in your delivery.

• All the bonus files (including a potential specific Makefile) should be in a directory
named bonus.

• Error messages have to be written on the error output, and the program should
then exit with the 84 error code (0 if there is no error).

You must recode the ls [-alRdrt] [FILE] command.


Options can be given in either order:

∇ Terminal - + x
∼/B-PSU-100> ./my_ls -l -t
...
∼/B-PSU-100> ./my_ls -lRt
...
∼/B-PSU-100> ./my_ls -lt -R -t

It must be possible to pass a list of files/folders as parameters:

∇ Terminal - + x
∼/B-PSU-100> ./my_ls -l /dev /usr/sbin
...
∼/B-PSU-100> ./my_ls -l -r file1 file2
...

Handling the column formatting without the -l option would be considered as a bonus
point, as well as sorting and coloring.

As a bonus, you could also handle others options, such as -uFgf.

1
AUTHORIZED FUNCTIONS
The only system calls allowed are the following ones:

• opendir, readdir, closedir, stat, lstat, write


• getpwuid, getgrgid, time, ctime, readlink,
• malloc, free, perror, strerror, exit.

EXAMPLES
∇ Terminal - + x
∼/B-PSU-100> ./my_ls -l -R
.:
total 156
drwxr-xr-x 2 johan johan 4096 Nov 9 15:31 dir
-rwxr-xr-x 1 johan johan 151352 Nov 30 14:32 my_ls
-rw-r–r– 1 johan johan 0 Nov 9 15:30 ‘#test#’
-rw-r–r– 1 johan johan 80 Nov 9 15:30 test~

./dir:
total 0
-rw-r–r– 1 johan johan 0 Nov 9 15:31 test

2
∇ Terminal - + x
∼/B-PSU-100> ./my_ls /bin
bash date kmod nano su uncompress
bunzip2 dd less netstat sync vdir
bzcat df lessecho networkctl systemctl wdctl
bzcmp dir lessfile nisdomainname systemd which
bzdiff dmesg lesskey pidof systemd-ask-password wslpath
bzegrep dnsdomainname lesspipe ping systemd-escape ypdomainname
bzexe domainname ln ping4 systemd-hwdb zcat
bzfgrep echo login ping6 systemd-inhibit zcmp
bzgrep egrep loginctl ps systemd-machine-id-setup zdiff
bzip2 false ls pwd systemd-notify zegrep
bzip2recover fgrep lsblk rbash systemd-sysusers zfgrep
bzless findmnt lsmod readlink systemd-tmpfiles zforce
bzmore fuser mkdir rm systemd-tty-ask-password-agent zgrep
cat grep mknod rmdir tar zless
chgrp gunzip mktemp rnano tcsh zmore
chmod gzexe more run-parts tempfile znew
chown gzip mount sed touch
cp hostname mountpoint sh true
cpio ip mt sleep udevadm
csh journalctl mt-gnu ss umount
dash kill mv stty uname

You might also like