Reputation: 21
i use stat()
system call, and st_dev
and st_rdev
gives me somethong about device id that is fe02
and 0
command line stat
gives me Device: fe02h/65026d
why there is a difference? or is my code wrong?
here is mystat.c
code
#include <sys/stat.h>
#include <stdio.h>
int main(int args,char * argv[]){
struct stat buffers;
int status;
status = stat("/home/debian/",&buffers);
printf("return from stat(): %d\n",status);
printf("/home/debian\n");
printf("ID of device containing file: %x\n",buffers.st_dev);
printf("Inode number: %d\n",buffers.st_ino);
printf("File type and mode: %o\n",buffers.st_mode);
printf("Number of hard links: %d\n",buffers.st_nlink);
printf("User ID of owner: %d\n",buffers.st_uid);
printf("Group ID of owner: %d\n",buffers.st_gid);
printf("Device ID: %x\n",buffers.st_rdev);
printf("Total size, in bytes: %d\n",buffers.st_size);
printf("Block size for filesystem I/O: %d\n",buffers.st_blksize);
printf("Number of 512B blocks allcated: %d\n",buffers.st_blocks);
return 0;
}
here is ./mystat
output
return from stat(): 0
/home/debian
ID of device containing file: fe02
Inode number: 407113
File type and mode: 40755
Number of hard links: 13
User ID of owner: 1000
Group ID of owner: 1000
Device ID: 0
Total size, in bytes: 4096
Block size for filesystem I/O: 4096
Number of 512B blocks allcated: 8
and this is stat /home/debian/
output
File: /home/debian/
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fe02h/65026d Inode: 407113 Links: 13
Access: (0755/drwxr-xr-x) Uid: ( 1000/ debian) Gid: ( 1000/ debian)
Access: 2024-12-11 03:40:38.782991622 -0800
Modify: 2024-12-11 03:40:33.583142964 -0800
Change: 2024-12-11 03:40:33.583142964 -0800
Birth: 2022-09-25 14:08:13.430517983 -0700
Upvotes: 0
Views: 11