Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- For Beginners
- 시스템 프로그래밍
- c
- IT
- 10773
- File 조작
- 전자책
- 균형잡힌 세상
- 해바
- QA
- c++
- Process Communication
- file IO
- LJESNJAK
- 시프
- The Balance of the World
- process control
- 4949
- 입력 버퍼
- 5622
- 1874
- system programming
- 브런치
- BAKA
- Baekjoon
- 백준
- Parenthesis
- 2941
- Zero That Out
- 바샤
Archives
- Today
- Total
해바
Lab #3 본문
stat() 시스템 호출을 이용하여 파일의 정보를 출력한다 :
- 주어진 하나의 파일의 inode 번호를 출력한다.
- 해당 파일의 처음 생성 날짜/시간, 마지막으로 업데이트 된 날짜/시간, 마지막으로 접근한 날짜/시간을 출력한다.
- 자기 홈 디렉토리에 lab3 디렉토리를 만든 후 프로그램 파일(stat.c)을 보관할 것
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <time.h>
int main() {
int fd;
struct stat sb;
if(stat("testfile", &sb) == -1) {
perror("stat");
return 1;
}
printf("Inode number : %ld\n", (long)sb.st_ino);
printf("처음 생성 날짜/시간 : %s", ctime(&sb.st_ctime));
printf("마지막으로 업데이트 된 날짜/시간 : %s", ctime(&sb.st_mtime));
printf("마지막으로 접근한 날짜/시간 : %s", ctime(&sb.st_atime));
return 0;
}
컴파일 :
%gcc stat.c
실행 :
%./a.out
Comments