diff --git a/headers/header_spec.txt b/headers/header_spec.txt index 0a01c138627760c0a6a488dc48e6aec1281d5653..7a5d5138ee15f2eb3a3935ab37c82d596fdd2abb 100644 --- a/headers/header_spec.txt +++ b/headers/header_spec.txt @@ -174,6 +174,7 @@ share/libc/__fc_define_eof.h: CEA_LGPL share/libc/__fc_define_fd_set_t.h: CEA_LGPL share/libc/__fc_define_file.h: CEA_LGPL share/libc/__fc_define_fpos_t.h: CEA_LGPL +share/libc/__fc_define_fs_cnt.h: CEA_LGPL share/libc/__fc_define_id_t.h: CEA_LGPL share/libc/__fc_define_ino_t.h: CEA_LGPL share/libc/__fc_define_intptr_t.h: CEA_LGPL @@ -289,6 +290,7 @@ share/libc/sys/shm.h: CEA_LGPL share/libc/sys/signal.h: CEA_LGPL share/libc/sys/socket.h: CEA_LGPL share/libc/sys/stat.h: CEA_LGPL +share/libc/sys/statvfs.h: CEA_LGPL share/libc/sys/time.h: CEA_LGPL share/libc/sys/times.h: CEA_LGPL share/libc/sys/timex.h: CEA_LGPL @@ -296,6 +298,7 @@ share/libc/sys/types.h: CEA_LGPL share/libc/sys/uio.h: CEA_LGPL share/libc/sys/un.h: CEA_LGPL share/libc/sys/utsname.h: CEA_LGPL +share/libc/sys/vfs.h: CEA_LGPL share/libc/sys/wait.h: CEA_LGPL share/libc/syslog.h: CEA_LGPL share/libc/termios.h: CEA_LGPL diff --git a/share/libc/__fc_define_fs_cnt.h b/share/libc/__fc_define_fs_cnt.h new file mode 100644 index 0000000000000000000000000000000000000000..0ea2e5ebc5eb7d39453f4a57e08ec5f37ee43edc --- /dev/null +++ b/share/libc/__fc_define_fs_cnt.h @@ -0,0 +1,38 @@ +/**************************************************************************/ +/* */ +/* This file is part of Frama-C. */ +/* */ +/* Copyright (C) 2007-2021 */ +/* CEA (Commissariat à l'énergie atomique et aux énergies */ +/* alternatives) */ +/* */ +/* you can redistribute it and/or modify it under the terms of the GNU */ +/* Lesser General Public License as published by the Free Software */ +/* Foundation, version 2.1. */ +/* */ +/* It is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Lesser General Public License for more details. */ +/* */ +/* See the GNU Lesser General Public License version 2.1 */ +/* for more details (enclosed in the file licenses/LGPLv2.1). */ +/* */ +/**************************************************************************/ + +#ifndef __FC_DEFINE_FS_CNT +#define __FC_DEFINE_FS_CNT +#include "features.h" +__PUSH_FC_STDLIB +__BEGIN_DECLS +#ifndef __fsblkcnt_t_defined +typedef unsigned long fsblkcnt_t; +#define __fsblkcnt_t_defined +#endif +#ifndef __fsfilcnt_t_defined +typedef unsigned long fsfilcnt_t; +#define __fsfilcnt_t_defined +#endif +__END_DECLS +__POP_FC_STDLIB +#endif diff --git a/share/libc/sys/statvfs.h b/share/libc/sys/statvfs.h new file mode 100644 index 0000000000000000000000000000000000000000..7a796e4db340dfc2a578d1a14b88dd02c1d50584 --- /dev/null +++ b/share/libc/sys/statvfs.h @@ -0,0 +1,55 @@ +/**************************************************************************/ +/* */ +/* This file is part of Frama-C. */ +/* */ +/* Copyright (C) 2007-2021 */ +/* CEA (Commissariat à l'énergie atomique et aux énergies */ +/* alternatives) */ +/* */ +/* you can redistribute it and/or modify it under the terms of the GNU */ +/* Lesser General Public License as published by the Free Software */ +/* Foundation, version 2.1. */ +/* */ +/* It is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Lesser General Public License for more details. */ +/* */ +/* See the GNU Lesser General Public License version 2.1 */ +/* for more details (enclosed in the file licenses/LGPLv2.1). */ +/* */ +/**************************************************************************/ + +#ifndef __FC_SYS_STATVFS_H__ +#define __FC_SYS_STATVFS_H__ + +#include "../features.h" +__PUSH_FC_STDLIB +__BEGIN_DECLS + +#include "../__fc_define_fs_cnt.h" + +struct statvfs { + unsigned long f_bsize; // File system block size. + unsigned long f_frsize; // Fundamental file system block size. + fsblkcnt_t f_blocks; // Total number of blocks on file system in units of + // f_frsize. + fsblkcnt_t f_bfree; // Total number of free blocks. + fsblkcnt_t f_bavail; // Number of free blocks available to + // non-privileged process. + fsfilcnt_t f_files; // Total number of file serial numbers. + fsfilcnt_t f_ffree; // Total number of free file serial numbers. + fsfilcnt_t f_favail; // Number of file serial numbers available to + // non-privileged process. + unsigned long f_fsid; // File system ID. + unsigned long f_flag; // Bit mask of f_flag values. + unsigned long f_namemax; // Maximum filename length. +}; + +extern int fstatvfs(int fildes, struct statvfs *buf); + +extern int statvfs(const char *restrict path, struct statvfs *restrict buf); + +__END_DECLS +__POP_FC_STDLIB +#endif diff --git a/share/libc/sys/vfs.h b/share/libc/sys/vfs.h new file mode 100644 index 0000000000000000000000000000000000000000..e36208870982ded797274ee6e7153b62b42be1be --- /dev/null +++ b/share/libc/sys/vfs.h @@ -0,0 +1,25 @@ +/**************************************************************************/ +/* */ +/* This file is part of Frama-C. */ +/* */ +/* Copyright (C) 2007-2021 */ +/* CEA (Commissariat à l'énergie atomique et aux énergies */ +/* alternatives) */ +/* */ +/* you can redistribute it and/or modify it under the terms of the GNU */ +/* Lesser General Public License as published by the Free Software */ +/* Foundation, version 2.1. */ +/* */ +/* It is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Lesser General Public License for more details. */ +/* */ +/* See the GNU Lesser General Public License version 2.1 */ +/* for more details (enclosed in the file licenses/LGPLv2.1). */ +/* */ +/**************************************************************************/ + +// This file is neither in the C standard nor in POSIX; +// it exists for compatibility purposes +#include "statvfs.h" diff --git a/tests/libc/fc_libc.c b/tests/libc/fc_libc.c index a1a67ca9bf4926c860af9cdbc073eef600b28594..8563ea2a4ed32ecd4b801324bf86699058099f5f 100644 --- a/tests/libc/fc_libc.c +++ b/tests/libc/fc_libc.c @@ -44,6 +44,7 @@ #include "__fc_define_fd_set_t.h" #include "__fc_define_file.h" #include "__fc_define_fpos_t.h" +#include "__fc_define_fs_cnt.h" #include "__fc_define_id_t.h" #include "__fc_define_ino_t.h" #include "__fc_define_intptr_t.h" @@ -132,6 +133,7 @@ #include "sys/signal.h" #include "sys/socket.h" #include "sys/stat.h" +#include "sys/statvfs.h" #include "sys/time.h" #include "sys/times.h" #include "sys/timex.h" @@ -139,6 +141,7 @@ #include "sys/uio.h" #include "sys/un.h" #include "sys/utsname.h" +#include "sys/vfs.h" #include "sys/wait.h" #include "termios.h" #include "tgmath.h" diff --git a/tests/libc/oracle/fc_libc.0.res.oracle b/tests/libc/oracle/fc_libc.0.res.oracle index 78e6ae2ca53e3ceb5a196176ee438cf604d5cd7e..4bd29442f2a0010f81c798585313bc45972f55a5 100644 --- a/tests/libc/oracle/fc_libc.0.res.oracle +++ b/tests/libc/oracle/fc_libc.0.res.oracle @@ -7,10 +7,10 @@ [eva] Initial state computed [eva:initial-state] Values of globals at initialization -[eva] tests/libc/fc_libc.c:155: assertion got status valid. -[eva] tests/libc/fc_libc.c:156: assertion got status valid. -[eva] tests/libc/fc_libc.c:157: assertion got status valid. [eva] tests/libc/fc_libc.c:158: assertion got status valid. +[eva] tests/libc/fc_libc.c:159: assertion got status valid. +[eva] tests/libc/fc_libc.c:160: assertion got status valid. +[eva] tests/libc/fc_libc.c:161: assertion got status valid. [eva] Recording results for main [eva] done for function main [eva] ====== VALUES COMPUTED ====== diff --git a/tests/libc/oracle/fc_libc.2.res.oracle b/tests/libc/oracle/fc_libc.2.res.oracle index b1e1247a43669f03d504de710fa2a4b5337ce754..06372c7bffc52bdd4752aa4f83bb1b3fc3a3277e 100644 --- a/tests/libc/oracle/fc_libc.2.res.oracle +++ b/tests/libc/oracle/fc_libc.2.res.oracle @@ -8,6 +8,7 @@ [kernel] Parsing share/libc/__fc_define_fd_set_t.h (with preprocessing) [kernel] Parsing share/libc/__fc_define_file.h (with preprocessing) [kernel] Parsing share/libc/__fc_define_fpos_t.h (with preprocessing) +[kernel] Parsing share/libc/__fc_define_fs_cnt.h (with preprocessing) [kernel] Parsing share/libc/__fc_define_id_t.h (with preprocessing) [kernel] Parsing share/libc/__fc_define_ino_t.h (with preprocessing) [kernel] Parsing share/libc/__fc_define_intptr_t.h (with preprocessing) @@ -106,6 +107,7 @@ skipping share/libc/complex.h [kernel] Parsing share/libc/sys/signal.h (with preprocessing) [kernel] Parsing share/libc/sys/socket.h (with preprocessing) [kernel] Parsing share/libc/sys/stat.h (with preprocessing) +[kernel] Parsing share/libc/sys/statvfs.h (with preprocessing) [kernel] Parsing share/libc/sys/time.h (with preprocessing) [kernel] Parsing share/libc/sys/times.h (with preprocessing) [kernel] Parsing share/libc/sys/timex.h (with preprocessing) @@ -113,6 +115,7 @@ skipping share/libc/complex.h [kernel] Parsing share/libc/sys/uio.h (with preprocessing) [kernel] Parsing share/libc/sys/un.h (with preprocessing) [kernel] Parsing share/libc/sys/utsname.h (with preprocessing) +[kernel] Parsing share/libc/sys/vfs.h (with preprocessing) [kernel] Parsing share/libc/sys/wait.h (with preprocessing) [kernel] Parsing share/libc/syslog.h (with preprocessing) [kernel] Parsing share/libc/termios.h (with preprocessing)