Question

What is a function that will use stat to get a files st_mode, st_nlinks, st_uid, st_gid,...

What is a function that will use stat to get a files st_mode, st_nlinks, st_uid, st_gid, st_size and print?

display_file(file){

stat info = stat(file)

printf(.....)

}

Homework Answers

Answer #1

Answer:

The stat() function will obtain the information about the named file and write it to the area pointed to by the buf argument. The path argument points to a path name and also naming a file to read, write, or execute permission of the named file is not particularly required. An implementation that provides additional or alternate file access control mechanisms may, under implementation-defined conditions, cause stat() to fail. In particular, the system may deny the access of existence of the file specified by path.

If the named file is a symbolic link, the stat() function will continue the path name resolution using the contents of the symbolic link, and shall return information pertaining to the resulting file if the file exists.

Thank you!!! Good luck! keep coding :)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please use C++. You will be provided with two files. The first file (accounts.txt) will contain...
Please use C++. You will be provided with two files. The first file (accounts.txt) will contain account numbers (10 digits) along with the account type (L:Loan and S:Savings) and their current balance. The second file (transactions.txt) will contain transactions on the accounts. It will specifically include the account number, an indication if it is a withdrawal/deposit and an amount. Both files will be pipe delimited (|) and their format will be the following: accounts.txt : File with bank account info...
Please answer the following C question: Read the files vec5C.h, vec5C.c, and main5C.h. Build an executable...
Please answer the following C question: Read the files vec5C.h, vec5C.c, and main5C.h. Build an executable using gcc -Wall main5C.c vec5C.c Do this: Add function definitions to vec5C.c so that functions are available for dot product, sum, and cross product. Do not change the function prototypes in vec5C.h. Then add code to main to call these functions and display the dot product of u and v, the sum of u and v, and the cross product of u and v....
Python problem: write a main function that ask user for 2 file name, open files and...
Python problem: write a main function that ask user for 2 file name, open files and read the 1st line of each and compare them using hamming function(below is the hamming function I wrote). Just assume the fist line of each file only contains 0s and 1s, such as 0100111101. The main function may have to do some extra work to remove newline characters or other whitespace from the text read from each file. This is hamming function that need...
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...
I cannot upload the needed text files to this question for your benefit of double checking...
I cannot upload the needed text files to this question for your benefit of double checking your solution, but I need help on this multi part question. Thanks! Write a Python program that will open the ‘steam.csv’ file. Your program should load the data as col- umns corresponding to the variable names located in the first row (You can hard code this – i.e open the file and use the names in the first row as variable names). You should...
Use C code please! Write the function definition for a function called FindQuo that takes one...
Use C code please! Write the function definition for a function called FindQuo that takes one argument of type double (arg1 ) and returns a double.  The purpose of the function is to calculate the quotient of arg1 divided by a double (num) that will be entered by the user. Inside the function declare ask and get a double value from the user called num Use a loop (while or do/while) to ensure that the user does not enter a 0.0....
please use linux/unix command terminal to complete, step 1 1-create a new directory named by inlab4...
please use linux/unix command terminal to complete, step 1 1-create a new directory named by inlab4 enter directory inlab4 create a new file named by reverse.c with the following contents and then close the file: /*reverse.c */ #include <stdio.h> reverse(char *before, char *after); main() { char str[100]; /*Buffer to hold reversed string */ reverse("cat", str); /*Reverse the string "cat" */ printf("reverse(\"cat\")=%s\n", str); /*Display result */ reverse("noon", str); /*Reverse the string "noon" */ printf("reverse(\"noon\")=%s\n", str); /*Display result */ } reverse(char *before,...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total 52 case sensitive) and five special characters (‘.’, ‘,’, ‘:’, ‘;’ and ‘!’) in all the .txt files under a given directory. The program should include a header count.h, alphabetcount.c to count the frequency of alphabet letters; and specialcharcount.c to count the frequency of special characters. Please only add code to where it says //ADDCODEHERE and keep function names the same. I have also...
Helllp plz Allow the InsertAt method to add to the front position 0 (zero) also if...
Helllp plz Allow the InsertAt method to add to the front position 0 (zero) also if you try to add to a position greater than the number of nodes you get an error warning. /INSERT.C /*THIS PROGRAM READS A BINARY FILE (MUST ALREADY EXIST AND BE FILLED) */ /*AND PUTS IT INTO A LINKED LIST AND PRINTS THE LIST TO THE SCREEN) */ #include #include #include #include typedef struct ENTRY { char name[81]; }ENTRY; typedef struct LISTREC /* LISTREC is...
Assume you have a file called letters.txt containing all the lowercase letters of the alphabet in...
Assume you have a file called letters.txt containing all the lowercase letters of the alphabet in order one letter per line. What would be printed out by the following code? f = open("letters.txt") info = f.readline() print(len(info)) f.close() f = open("letters.txt") info = f.readline() info = f.readline() print(info[0]) f.close() f = open("letters.txt") info = f.readline() f.close() f = open("letters.txt") info = f.readline() print(info[0]) f.close()