File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 16
16
#include <sys/resource.h>
17
17
#include <sys/socket.h>
18
18
#include <sys/stat.h>
19
+ #include <sys/statfs.h>
19
20
#include <sys/time.h>
20
21
#include <sys/types.h>
21
22
#include <sys/wait.h>
@@ -956,10 +957,35 @@ int setup_redirects()
956
957
return 0 ;
957
958
}
958
959
960
+ int is_virtiofs (const char * path )
961
+ {
962
+ struct statfs fs ;
963
+
964
+ if (statfs (path , & fs ) != 0 ) {
965
+ perror ("statfs" );
966
+ return -1 ;
967
+ }
968
+
969
+ // virtiofs magic number: 0x65735546
970
+ return (fs .f_type == 0x65735546 ) ? 1 : 0 ;
971
+ }
972
+
959
973
void set_exit_code (int code )
960
974
{
961
975
int fd ;
962
976
int ret ;
977
+ int virtiofs_check ;
978
+
979
+ // Only use the ioctl if virtiofs is used for root filesystem
980
+ virtiofs_check = is_virtiofs ("/" );
981
+ if (virtiofs_check < 0 ) {
982
+ printf ("Warning: Could not determine filesystem type for root\n" );
983
+ }
984
+
985
+ if (virtiofs_check == 0 ) {
986
+ // Root filesystem is not virtiofs, skip the ioctl
987
+ return ;
988
+ }
963
989
964
990
fd = open ("/" , O_RDONLY );
965
991
if (fd < 0 ) {
You can’t perform that action at this time.
0 commit comments