Verify the presence of the file on /dev/shm

Asked 2 years ago, Updated 2 years ago, 40 views

Your system has tmpfs mounted at /dev/shm.
I copied the tar file to /dev/shm and expanded it.

root@xxx:~#ls-al/dev/shm/update
drwxrwxrwx2xuserxuser100 Oct 21 18:03.
drwxrwxrwt3 root root 100 Oct 21 18:03..
-rwxr-xr-x1xuserxuser1717 May 1302:35 bootmisc.sh
-rw -r --r -- 1xuser xuser 89 Jul 2306:14 mount.blacklist

You can see the file as shown in .
We are developing software in C language and checking the existence of files in stat().
USB memory, /home/root, etc. will return results successfully.

if(stat("/dev/shm/update/bootmisc.sh", &st)!=0){
   printf("file nothing\n";
}

When checked, = 0 is not returned.
Can't you check the file on tmpfs with stat()?
In that case, is there any alternative?

Thank you for your cooperation.

c

2022-09-30 19:49

1 Answers

I solved myself.

if(stat("/dev/shm/update/bootmisc.sh", &st)!=0){
printf("file nothing\n";
}

The reason was that there was a blank space at the beginning of "..." in the file name specification.
If there was a blank space, I thought they would skip it, so I couldn't get to the cause.

Sorry for the trouble.


2022-09-30 19:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.