디렉토리를 파일로 변경하고 싶습니다. 몇 가지 연구를했습니다. Linux에서 inode 구조는 파일과 디렉토리에 대한 메타 데이터를 저장합니다. 파일 보호 모드를 디렉토리에서 파일로 변경하고 싶습니다.C 프로그램에서 inode 구조를 사용하여 Linux에서 파일을 디렉토리로 수정
Print some general file info
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
int main(int argc, char *argv[]) {
struct stat file_stats;
if(argc != 2)
fprintf(stderr, "Usage: fstat FILE...\n"), exit(EXIT_FAILURE);
if((stat(argv[1], &file_stats)) == -1) {
perror("fstat");
return 1;
}
printf("filename: %s\n", argv[1]);
printf(" device: %lld\n", file_stats.st_dev);
printf(" inode: %ld\n", file_stats.st_ino);
printf(" protection: %o\n", file_stats.st_mode);
printf(" number of hard links: %d\n", file_stats.st_nlink);
printf(" user ID of owner: %d\n", file_stats.st_uid);
printf(" group ID of owner: %d\n", file_stats.st_gid);
printf(" device type (if inode device): %lld\n",file_stats.st_rdev);
printf(" total size, in bytes: %ld\n", file_stats.st_size);
printf(" blocksize for filesystem I/O: %ld\n", file_stats.st_blksize);
printf(" number of blocks allocated: %ld\n", file_stats.st_blocks);
printf(" time of last access: %ld : %s", file_stats.st_atime, ctime(&file_stats.st_atime));
printf(" time of last modification: %ld : %s", file_stats.st_mtime, ctime(&file_stats.st_mtime));
printf(" time of last change: %ld : %s", file_stats.st_ctime, ctime(&file_stats.st_ctime));
return 0;
}
디렉토리를 파일로 변경하는 방법이 있습니까 ?? 어떻게 C 프로그램에 의해 inode 구조를 수정 하는가?
파일을 삭제 한 다음 디렉토리를 만드는 특별한 이유가 있습니까? – Corbin
예. 파일로 취급하여 디렉토리에 대한 조작을하고 싶습니다. – Nimit
디렉토리가 이미 파일입니다. 당신은 정말로 무엇을하고 싶습니까? – Duck