Question: In C File permissions in Linux can be set using a 3-digit octal code as you learned before. For example, command chmod 644 file sets

In C

In C File permissions in Linux can be set using a 3-digit

File permissions in Linux can be set using a 3-digit octal code as you learned before. For example, command chmod 644 file sets file to be readable by everyone and writable by owner only. If you list the details of the file such a permission is represented by a string of 9 characters " rw-r--r Write a C program rwx2octal that reads from standard input a string of 9 characters (e.g., " rw-r- ") and outputs the octal version of that (e.g., "644"). The program should print out "invalid permission" for any input that is not a valid 9-character string. Note that valid input characters are only 'r', 'w', 'x', and' (we ignore indicators for file-type/setuid/setgid in this exercise.) Also, valid length and order of characters need to be checked. More examples of inputs and expected outputs are as follow. Input Output I r-xr-x--x I 551 I000 I W-r 024 I r-wr-x-x invalid permission | I rwxrwxinvalid permission| I arwxrwxrw | invalid permission

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!