OpenCoverage

df.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/df.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* df - summarize free disk space-
2 Copyright (C) 1991-2018 Free Software Foundation, Inc.-
3-
4 This program is free software: you can redistribute it and/or modify-
5 it under the terms of the GNU General Public License as published by-
6 the Free Software Foundation, either version 3 of the License, or-
7 (at your option) any later version.-
8-
9 This program is distributed in the hope that it will be useful,-
10 but WITHOUT ANY WARRANTY; without even the implied warranty of-
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
12 GNU General Public License for more details.-
13-
14 You should have received a copy of the GNU General Public License-
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */-
16-
17/* Written by David MacKenzie <djm@gnu.ai.mit.edu>.-
18 --human-readable option added by lm@sgi.com.-
19 --si and large file support added by eggert@twinsun.com. */-
20-
21#include <config.h>-
22#include <stdio.h>-
23#include <sys/types.h>-
24#include <getopt.h>-
25#include <assert.h>-
26-
27#include "system.h"-
28#include "canonicalize.h"-
29#include "die.h"-
30#include "error.h"-
31#include "fsusage.h"-
32#include "human.h"-
33#include "mbsalign.h"-
34#include "mbswidth.h"-
35#include "mountlist.h"-
36#include "quote.h"-
37#include "find-mount-point.h"-
38#include "hash.h"-
39-
40/* The official name of this program (e.g., no 'g' prefix). */-
41#define PROGRAM_NAME "df"-
42-
43#define AUTHORS \-
44 proper_name ("Torbjorn Granlund"), \-
45 proper_name ("David MacKenzie"), \-
46 proper_name ("Paul Eggert")-
47-
48struct devlist-
49{-
50 dev_t dev_num;-
51 struct mount_entry *me;-
52 struct devlist *next;-
53};-
54-
55/* Filled with device numbers of examined file systems to avoid-
56 duplicates in output. */-
57static Hash_table *devlist_table;-
58-
59/* If true, show even file systems with zero size or-
60 uninteresting types. */-
61static bool show_all_fs;-
62-
63/* If true, show only local file systems. */-
64static bool show_local_fs;-
65-
66/* If true, output data for each file system corresponding to a-
67 command line argument -- even if it's a dummy (automounter) entry. */-
68static bool show_listed_fs;-
69-
70/* Human-readable options for output. */-
71static int human_output_opts;-
72-
73/* The units to use when printing sizes. */-
74static uintmax_t output_block_size;-
75-
76/* True if a file system has been processed for output. */-
77static bool file_systems_processed;-
78-
79/* If true, invoke the 'sync' system call before getting any usage data.-
80 Using this option can make df very slow, especially with many or very-
81 busy disks. Note that this may make a difference on some systems ---
82 SunOS 4.1.3, for one. It is *not* necessary on GNU/Linux. */-
83static bool require_sync;-
84-
85/* Desired exit status. */-
86static int exit_status;-
87-
88/* A file system type to display. */-
89-
90struct fs_type_list-
91{-
92 char *fs_name;-
93 struct fs_type_list *fs_next;-
94};-
95-
96/* Linked list of file system types to display.-
97 If 'fs_select_list' is NULL, list all types.-
98 This table is generated dynamically from command-line options,-
99 rather than hardcoding into the program what it thinks are the-
100 valid file system types; let the user specify any file system type-
101 they want to, and if there are any file systems of that type, they-
102 will be shown.-
103-
104 Some file system types:-
105 4.2 4.3 ufs nfs swap ignore io vm efs dbg */-
106-
107static struct fs_type_list *fs_select_list;-
108-
109/* Linked list of file system types to omit.-
110 If the list is empty, don't exclude any types. */-
111-
112static struct fs_type_list *fs_exclude_list;-
113-
114/* Linked list of mounted file systems. */-
115static struct mount_entry *mount_list;-
116-
117/* If true, print file system type as well. */-
118static bool print_type;-
119-
120/* If true, print a grand total at the end. */-
121static bool print_grand_total;-
122-
123/* Grand total data. */-
124static struct fs_usage grand_fsu;-
125-
126/* Display modes. */-
127enum-
128{-
129 DEFAULT_MODE,-
130 INODES_MODE,-
131 HUMAN_MODE,-
132 POSIX_MODE,-
133 OUTPUT_MODE-
134};-
135static int header_mode = DEFAULT_MODE;-
136-
137/* Displayable fields. */-
138typedef enum-
139{-
140 SOURCE_FIELD, /* file system */-
141 FSTYPE_FIELD, /* FS type */-
142 SIZE_FIELD, /* FS size */-
143 USED_FIELD, /* FS size used */-
144 AVAIL_FIELD, /* FS size available */-
145 PCENT_FIELD, /* percent used */-
146 ITOTAL_FIELD, /* inode total */-
147 IUSED_FIELD, /* inodes used */-
148 IAVAIL_FIELD, /* inodes available */-
149 IPCENT_FIELD, /* inodes used in percent */-
150 TARGET_FIELD, /* mount point */-
151 FILE_FIELD, /* specified file name */-
152 INVALID_FIELD /* validation marker */-
153} display_field_t;-
154-
155/* Flag if a field contains a block, an inode or another value. */-
156typedef enum-
157{-
158 BLOCK_FLD, /* Block values field */-
159 INODE_FLD, /* Inode values field */-
160 OTHER_FLD /* Neutral field, e.g. target */-
161} field_type_t;-
162-
163/* Attributes of a display field. */-
164struct field_data_t-
165{-
166 display_field_t field;-
167 char const *arg;-
168 field_type_t field_type;-
169 const char *caption;/* NULL means to use the default header of this field. */-
170 size_t width; /* Auto adjusted (up) widths used to align columns. */-
171 mbs_align_t align; /* Alignment for this field. */-
172 bool used;-
173};-
174-
175/* Header strings, minimum width and alignment for the above fields. */-
176static struct field_data_t field_data[] = {-
177 [SOURCE_FIELD] = { SOURCE_FIELD,-
178 "source", OTHER_FLD, N_("Filesystem"), 14, MBS_ALIGN_LEFT, false },-
179-
180 [FSTYPE_FIELD] = { FSTYPE_FIELD,-
181 "fstype", OTHER_FLD, N_("Type"), 4, MBS_ALIGN_LEFT, false },-
182-
183 [SIZE_FIELD] = { SIZE_FIELD,-
184 "size", BLOCK_FLD, N_("blocks"), 5, MBS_ALIGN_RIGHT, false },-
185-
186 [USED_FIELD] = { USED_FIELD,-
187 "used", BLOCK_FLD, N_("Used"), 5, MBS_ALIGN_RIGHT, false },-
188-
189 [AVAIL_FIELD] = { AVAIL_FIELD,-
190 "avail", BLOCK_FLD, N_("Available"), 5, MBS_ALIGN_RIGHT, false },-
191-
192 [PCENT_FIELD] = { PCENT_FIELD,-
193 "pcent", BLOCK_FLD, N_("Use%"), 4, MBS_ALIGN_RIGHT, false },-
194-
195 [ITOTAL_FIELD] = { ITOTAL_FIELD,-
196 "itotal", INODE_FLD, N_("Inodes"), 5, MBS_ALIGN_RIGHT, false },-
197-
198 [IUSED_FIELD] = { IUSED_FIELD,-
199 "iused", INODE_FLD, N_("IUsed"), 5, MBS_ALIGN_RIGHT, false },-
200-
201 [IAVAIL_FIELD] = { IAVAIL_FIELD,-
202 "iavail", INODE_FLD, N_("IFree"), 5, MBS_ALIGN_RIGHT, false },-
203-
204 [IPCENT_FIELD] = { IPCENT_FIELD,-
205 "ipcent", INODE_FLD, N_("IUse%"), 4, MBS_ALIGN_RIGHT, false },-
206-
207 [TARGET_FIELD] = { TARGET_FIELD,-
208 "target", OTHER_FLD, N_("Mounted on"), 0, MBS_ALIGN_LEFT, false },-
209-
210 [FILE_FIELD] = { FILE_FIELD,-
211 "file", OTHER_FLD, N_("File"), 0, MBS_ALIGN_LEFT, false }-
212};-
213-
214static char const *all_args_string =-
215 "source,fstype,itotal,iused,iavail,ipcent,size,"-
216 "used,avail,pcent,file,target";-
217-
218/* Storage for the definition of output columns. */-
219static struct field_data_t **columns;-
220-
221/* The current number of output columns. */-
222static size_t ncolumns;-
223-
224/* Field values. */-
225struct field_values_t-
226{-
227 uintmax_t input_units;-
228 uintmax_t output_units;-
229 uintmax_t total;-
230 uintmax_t available;-
231 bool negate_available;-
232 uintmax_t available_to_root;-
233 uintmax_t used;-
234 bool negate_used;-
235};-
236-
237/* Storage for pointers for each string (cell of table). */-
238static char ***table;-
239-
240/* The current number of processed rows (including header). */-
241static size_t nrows;-
242-
243/* For long options that have no equivalent short option, use a-
244 non-character as a pseudo short option, starting with CHAR_MAX + 1. */-
245enum-
246{-
247 NO_SYNC_OPTION = CHAR_MAX + 1,-
248 SYNC_OPTION,-
249 TOTAL_OPTION,-
250 OUTPUT_OPTION-
251};-
252-
253static struct option const long_options[] =-
254{-
255 {"all", no_argument, NULL, 'a'},-
256 {"block-size", required_argument, NULL, 'B'},-
257 {"inodes", no_argument, NULL, 'i'},-
258 {"human-readable", no_argument, NULL, 'h'},-
259 {"si", no_argument, NULL, 'H'},-
260 {"local", no_argument, NULL, 'l'},-
261 {"output", optional_argument, NULL, OUTPUT_OPTION},-
262 {"portability", no_argument, NULL, 'P'},-
263 {"print-type", no_argument, NULL, 'T'},-
264 {"sync", no_argument, NULL, SYNC_OPTION},-
265 {"no-sync", no_argument, NULL, NO_SYNC_OPTION},-
266 {"total", no_argument, NULL, TOTAL_OPTION},-
267 {"type", required_argument, NULL, 't'},-
268 {"exclude-type", required_argument, NULL, 'x'},-
269 {GETOPT_HELP_OPTION_DECL},-
270 {GETOPT_VERSION_OPTION_DECL},-
271 {NULL, 0, NULL, 0}-
272};-
273-
274/* Replace problematic chars with '?'.-
275 Since only control characters are currently considered,-
276 this should work in all encodings. */-
277-
278static char*-
279hide_problematic_chars (char *cell)-
280{-
281 char *p = cell;-
282 while (*p)
*pDescription
TRUEevaluated 9734 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1712 times by 1 test
Evaluated by:
  • df
1712-9734
283 {-
284 if (iscntrl (to_uchar (*p)))
((*__ctype_b_l...int) _IScntrl)Description
TRUEnever evaluated
FALSEevaluated 9734 times by 1 test
Evaluated by:
  • df
0-9734
285 *p = '?';
never executed: *p = '?';
0
286 p++;-
287 }
executed 9734 times by 1 test: end of block
Executed by:
  • df
9734
288 return cell;
executed 1712 times by 1 test: return cell;
Executed by:
  • df
1712
289}-
290-
291/* Dynamically allocate a row of pointers in TABLE, which-
292 can then be accessed with standard 2D array notation. */-
293-
294static void-
295alloc_table_row (void)-
296{-
297 nrows++;-
298 table = xnrealloc (table, nrows, sizeof (char **));-
299 table[nrows - 1] = xnmalloc (ncolumns, sizeof (char *));-
300}
executed 315 times by 1 test: end of block
Executed by:
  • df
315
301-
302/* Output each cell in the table, accounting for the-
303 alignment and max width of each column. */-
304-
305static void-
306print_table (void)-
307{-
308 size_t row;-
309-
310 for (row = 0; row < nrows; row++)
row < nrowsDescription
TRUEevaluated 311 times by 1 test
Evaluated by:
  • df
FALSEevaluated 67 times by 1 test
Evaluated by:
  • df
67-311
311 {-
312 size_t col;-
313 for (col = 0; col < ncolumns; col++)
col < ncolumnsDescription
TRUEevaluated 1688 times by 1 test
Evaluated by:
  • df
FALSEevaluated 311 times by 1 test
Evaluated by:
  • df
311-1688
314 {-
315 char *cell = table[row][col];-
316-
317 /* Note the SOURCE_FIELD used to be displayed on it's own line-
318 if (!posix_format && mbswidth (cell) > 20), but that-
319 functionality was probably more problematic than helpful,-
320 hence changed in commit v8.10-40-g99679ff. */-
321 if (col != 0)
col != 0Description
TRUEevaluated 1377 times by 1 test
Evaluated by:
  • df
FALSEevaluated 311 times by 1 test
Evaluated by:
  • df
311-1377
322 putchar (' ');
executed 1377 times by 1 test: putchar_unlocked (' ');
Executed by:
  • df
1377
323-
324 int flags = 0;-
325 if (col == ncolumns - 1) /* The last one. */
col == ncolumns - 1Description
TRUEevaluated 311 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1377 times by 1 test
Evaluated by:
  • df
311-1377
326 flags = MBA_NO_RIGHT_PAD;
executed 311 times by 1 test: flags = MBA_NO_RIGHT_PAD;
Executed by:
  • df
311
327-
328 size_t width = columns[col]->width;-
329 cell = ambsalign (cell, &width, columns[col]->align, flags);-
330 /* When ambsalign fails, output unaligned data. */-
331 fputs (cell ? cell : table[row][col], stdout);-
332 free (cell);-
333-
334 IF_LINT (free (table[row][col]));-
335 }
executed 1688 times by 1 test: end of block
Executed by:
  • df
1688
336 putchar ('\n');-
337 IF_LINT (free (table[row]));-
338 }
executed 311 times by 1 test: end of block
Executed by:
  • df
311
339-
340 IF_LINT (free (table));-
341}
executed 67 times by 1 test: end of block
Executed by:
  • df
67
342-
343/* Dynamically allocate a struct field_t in COLUMNS, which-
344 can then be accessed with standard array notation. */-
345-
346static void-
347alloc_field (int f, const char *c)-
348{-
349 ncolumns++;-
350 columns = xnrealloc (columns, ncolumns, sizeof (struct field_data_t *));-
351 columns[ncolumns - 1] = &field_data[f];-
352 if (c != NULL)
c != ((void *)0)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • df
FALSEevaluated 382 times by 1 test
Evaluated by:
  • df
8-382
353 columns[ncolumns - 1]->caption = c;
executed 8 times by 1 test: columns[ncolumns - 1]->caption = c;
Executed by:
  • df
8
354-
355 if (field_data[f].used)
field_data[f].usedDescription
TRUEnever evaluated
FALSEevaluated 390 times by 1 test
Evaluated by:
  • df
0-390
356 assert (!"field used");
never executed: (( !"field used" ) ? (void) (0) : __assert_fail ( "!\"field used\"" , "src/df.c", 356, __PRETTY_FUNCTION__)) ;
0
357-
358 /* Mark field as used. */-
359 field_data[f].used = true;-
360}
executed 390 times by 1 test: end of block
Executed by:
  • df
390
361-
362-
363/* Given a string, ARG, containing a comma-separated list of arguments-
364 to the --output option, add the appropriate fields to columns. */-
365static void-
366decode_output_arg (char const *arg)-
367{-
368 char *arg_writable = xstrdup (arg);-
369 char *s = arg_writable;-
370 do-
371 {-
372 /* find next comma */-
373 char *comma = strchr (s, ',');
__builtin_constant_p ( ',' )Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
!__builtin_constant_p ( s )Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
( ',' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 46 times by 1 test
Evaluated by:
  • df
0-46
374-
375 /* If we found a comma, put a NUL in its place and advance. */-
376 if (comma)
commaDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • df
FALSEevaluated 18 times by 1 test
Evaluated by:
  • df
18-28
377 *comma++ = 0;
executed 28 times by 1 test: *comma++ = 0;
Executed by:
  • df
28
378-
379 /* process S. */-
380 display_field_t field = INVALID_FIELD;-
381 for (unsigned int i = 0; i < ARRAY_CARDINALITY (field_data); i++)
i < (sizeof (f...*(field_data))Description
TRUEevaluated 302 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-302
382 {-
383 if (STREQ (field_data[i].arg, s))
never executed: __result = (((const unsigned char *) (const char *) ( field_data[i].arg ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( s ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • df
FALSEevaluated 256 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-256
384 {-
385 field = i;-
386 break;
executed 46 times by 1 test: break;
Executed by:
  • df
46
387 }-
388 }
executed 256 times by 1 test: end of block
Executed by:
  • df
256
389 if (field == INVALID_FIELD)
field == INVALID_FIELDDescription
TRUEnever evaluated
FALSEevaluated 46 times by 1 test
Evaluated by:
  • df
0-46
390 {-
391 error (0, 0, _("option --output: field %s unknown"), quote (s));-
392 usage (EXIT_FAILURE);-
393 }
never executed: end of block
0
394-
395 if (field_data[field].used)
field_data[field].usedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 44 times by 1 test
Evaluated by:
  • df
2-44
396 {-
397 /* Prevent the fields from being used more than once. */-
398 error (0, 0, _("option --output: field %s used more than once"),-
399 quote (field_data[field].arg));-
400 usage (EXIT_FAILURE);-
401 }
never executed: end of block
0
402-
403 switch (field)-
404 {-
405 case SOURCE_FIELD:
executed 10 times by 1 test: case SOURCE_FIELD:
Executed by:
  • df
10
406 case FSTYPE_FIELD:
executed 3 times by 1 test: case FSTYPE_FIELD:
Executed by:
  • df
3
407 case USED_FIELD:
executed 2 times by 1 test: case USED_FIELD:
Executed by:
  • df
2
408 case PCENT_FIELD:
executed 2 times by 1 test: case PCENT_FIELD:
Executed by:
  • df
2
409 case ITOTAL_FIELD:
executed 2 times by 1 test: case ITOTAL_FIELD:
Executed by:
  • df
2
410 case IUSED_FIELD:
executed 2 times by 1 test: case IUSED_FIELD:
Executed by:
  • df
2
411 case IAVAIL_FIELD:
executed 2 times by 1 test: case IAVAIL_FIELD:
Executed by:
  • df
2
412 case IPCENT_FIELD:
executed 2 times by 1 test: case IPCENT_FIELD:
Executed by:
  • df
2
413 case TARGET_FIELD:
executed 11 times by 1 test: case TARGET_FIELD:
Executed by:
  • df
11
414 case FILE_FIELD:
executed 3 times by 1 test: case FILE_FIELD:
Executed by:
  • df
3
415 alloc_field (field, NULL);-
416 break;
executed 39 times by 1 test: break;
Executed by:
  • df
39
417-
418 case SIZE_FIELD:
executed 3 times by 1 test: case SIZE_FIELD:
Executed by:
  • df
3
419 alloc_field (field, N_("Size"));-
420 break;
executed 3 times by 1 test: break;
Executed by:
  • df
3
421-
422 case AVAIL_FIELD:
executed 2 times by 1 test: case AVAIL_FIELD:
Executed by:
  • df
2
423 alloc_field (field, N_("Avail"));-
424 break;
executed 2 times by 1 test: break;
Executed by:
  • df
2
425-
426 default:
never executed: default:
0
427 assert (!"invalid field");-
428 }
never executed: end of block
0
429 s = comma;-
430 }
executed 44 times by 1 test: end of block
Executed by:
  • df
44
431 while (s);
sDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • df
FALSEevaluated 16 times by 1 test
Evaluated by:
  • df
16-28
432-
433 free (arg_writable);-
434}
executed 16 times by 1 test: end of block
Executed by:
  • df
16
435-
436/* Get the appropriate columns for the mode. */-
437static void-
438get_field_list (void)-
439{-
440 switch (header_mode)-
441 {-
442 case DEFAULT_MODE:
executed 51 times by 1 test: case DEFAULT_MODE:
Executed by:
  • df
51
443 alloc_field (SOURCE_FIELD, NULL);-
444 if (print_type)
print_typeDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 48 times by 1 test
Evaluated by:
  • df
3-48
445 alloc_field (FSTYPE_FIELD, NULL);
executed 3 times by 1 test: alloc_field (FSTYPE_FIELD, ((void *)0) );
Executed by:
  • df
3
446 alloc_field (SIZE_FIELD, NULL);-
447 alloc_field (USED_FIELD, NULL);-
448 alloc_field (AVAIL_FIELD, NULL);-
449 alloc_field (PCENT_FIELD, NULL);-
450 alloc_field (TARGET_FIELD, NULL);-
451 break;
executed 51 times by 1 test: break;
Executed by:
  • df
51
452-
453 case HUMAN_MODE:
never executed: case HUMAN_MODE:
0
454 alloc_field (SOURCE_FIELD, NULL);-
455 if (print_type)
print_typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
456 alloc_field (FSTYPE_FIELD, NULL);
never executed: alloc_field (FSTYPE_FIELD, ((void *)0) );
0
457-
458 alloc_field (SIZE_FIELD, N_("Size"));-
459 alloc_field (USED_FIELD, NULL);-
460 alloc_field (AVAIL_FIELD, N_("Avail"));-
461 alloc_field (PCENT_FIELD, NULL);-
462 alloc_field (TARGET_FIELD, NULL);-
463 break;
never executed: break;
0
464-
465 case INODES_MODE:
executed 3 times by 1 test: case INODES_MODE:
Executed by:
  • df
3
466 alloc_field (SOURCE_FIELD, NULL);-
467 if (print_type)
print_typeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
1-2
468 alloc_field (FSTYPE_FIELD, NULL);
executed 1 time by 1 test: alloc_field (FSTYPE_FIELD, ((void *)0) );
Executed by:
  • df
1
469 alloc_field (ITOTAL_FIELD, NULL);-
470 alloc_field (IUSED_FIELD, NULL);-
471 alloc_field (IAVAIL_FIELD, NULL);-
472 alloc_field (IPCENT_FIELD, NULL);-
473 alloc_field (TARGET_FIELD, NULL);-
474 break;
executed 3 times by 1 test: break;
Executed by:
  • df
3
475-
476 case POSIX_MODE:
executed 3 times by 1 test: case POSIX_MODE:
Executed by:
  • df
3
477 alloc_field (SOURCE_FIELD, NULL);-
478 if (print_type)
print_typeDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
0-3
479 alloc_field (FSTYPE_FIELD, NULL);
never executed: alloc_field (FSTYPE_FIELD, ((void *)0) );
0
480 alloc_field (SIZE_FIELD, NULL);-
481 alloc_field (USED_FIELD, NULL);-
482 alloc_field (AVAIL_FIELD, NULL);-
483 alloc_field (PCENT_FIELD, N_("Capacity"));-
484 alloc_field (TARGET_FIELD, NULL);-
485 break;
executed 3 times by 1 test: break;
Executed by:
  • df
3
486-
487 case OUTPUT_MODE:
executed 14 times by 1 test: case OUTPUT_MODE:
Executed by:
  • df
14
488 if (!ncolumns)
!ncolumnsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 13 times by 1 test
Evaluated by:
  • df
1-13
489 {-
490 /* Add all fields if --output was given without a field list. */-
491 decode_output_arg (all_args_string);-
492 }
executed 1 time by 1 test: end of block
Executed by:
  • df
1
493 break;
executed 14 times by 1 test: break;
Executed by:
  • df
14
494-
495 default:
never executed: default:
0
496 assert (!"invalid header_mode");-
497 }
never executed: end of block
0
498}-
499-
500/* Obtain the appropriate header entries. */-
501-
502static void-
503get_header (void)-
504{-
505 size_t col;-
506-
507 alloc_table_row ();-
508-
509 for (col = 0; col < ncolumns; col++)
col < ncolumnsDescription
TRUEevaluated 386 times by 1 test
Evaluated by:
  • df
FALSEevaluated 71 times by 1 test
Evaluated by:
  • df
71-386
510 {-
511 char *cell = NULL;-
512 char const *header = _(columns[col]->caption);-
513-
514 if (columns[col]->field == SIZE_FIELD
columns[col]->... == SIZE_FIELDDescription
TRUEevaluated 57 times by 1 test
Evaluated by:
  • df
FALSEevaluated 329 times by 1 test
Evaluated by:
  • df
57-329
515 && (header_mode == DEFAULT_MODE
header_mode == DEFAULT_MODEDescription
TRUEevaluated 51 times by 1 test
Evaluated by:
  • df
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
6-51
516 || (header_mode == OUTPUT_MODE
header_mode == OUTPUT_MODEDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
3
517 && !(human_output_opts & human_autoscale))))
!(human_output...man_autoscale)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
1-2
518 {-
519 char buf[LONGEST_HUMAN_READABLE + 1];-
520-
521 int opts = (human_suppress_point_zero-
522 | human_autoscale | human_SI-
523 | (human_output_opts-
524 & (human_group_digits | human_base_1024 | human_B)));-
525-
526 /* Prefer the base that makes the human-readable value more exact,-
527 if there is a difference. */-
528-
529 uintmax_t q1000 = output_block_size;-
530 uintmax_t q1024 = output_block_size;-
531 bool divisible_by_1000;-
532 bool divisible_by_1024;-
533-
534 do-
535 {-
536 divisible_by_1000 = q1000 % 1000 == 0; q1000 /= 1000;-
537 divisible_by_1024 = q1024 % 1024 == 0; q1024 /= 1024;-
538 }
executed 52 times by 1 test: end of block
Executed by:
  • df
52
539 while (divisible_by_1000 & divisible_by_1024);
divisible_by_1...isible_by_1024Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • df
0-52
540-
541 if (divisible_by_1000 < divisible_by_1024)
divisible_by_1...isible_by_1024Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-52
542 opts |= human_base_1024;
executed 52 times by 1 test: opts |= human_base_1024;
Executed by:
  • df
52
543 if (divisible_by_1024 < divisible_by_1000)
divisible_by_1...isible_by_1000Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • df
0-52
544 opts &= ~human_base_1024;
never executed: opts &= ~human_base_1024;
0
545 if (! (opts & human_base_1024))
! (opts & human_base_1024)Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • df
0-52
546 opts |= human_B;
never executed: opts |= human_B;
0
547-
548 char *num = human_readable (output_block_size, buf, opts, 1, 1);-
549-
550 /* Reset the header back to the default in OUTPUT_MODE. */-
551 header = _("blocks");-
552-
553 /* TRANSLATORS: this is the "1K-blocks" header in "df" output. */-
554 if (asprintf (&cell, _("%s-%s"), num, header) == -1)
asprintf (&cel... header) == -1Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • df
0-52
555 cell = NULL;
never executed: cell = ((void *)0) ;
0
556 }
executed 52 times by 1 test: end of block
Executed by:
  • df
52
557 else if (header_mode == POSIX_MODE && columns[col]->field == SIZE_FIELD)
header_mode == POSIX_MODEDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • df
FALSEevaluated 316 times by 1 test
Evaluated by:
  • df
columns[col]->... == SIZE_FIELDDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 15 times by 1 test
Evaluated by:
  • df
3-316
558 {-
559 char buf[INT_BUFSIZE_BOUND (uintmax_t)];-
560 char *num = umaxtostr (output_block_size, buf);-
561-
562 /* TRANSLATORS: this is the "1024-blocks" header in "df -P". */-
563 if (asprintf (&cell, _("%s-%s"), num, header) == -1)
asprintf (&cel... header) == -1Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
0-3
564 cell = NULL;
never executed: cell = ((void *)0) ;
0
565 }
executed 3 times by 1 test: end of block
Executed by:
  • df
3
566 else-
567 cell = strdup (header);
executed 331 times by 1 test: cell = (__extension__ (__builtin_constant_p ( header ) && ((size_t)(const void *)(( header ) + 1) - (size_t)(const void *)( header ) == 1) ? (((const char *) ( header ))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen ( header ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)) __retval = (char *) memcpy (__retval, header , __len); __retval; })) : __strdup ( header ))) ;
Executed by:
  • df
never executed: __retval = (char *) memcpy (__retval, header , __len);
__retval != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( header )Description
TRUEnever evaluated
FALSEevaluated 331 times by 1 test
Evaluated by:
  • df
((size_t)(cons...header ) == 1)Description
TRUEnever evaluated
FALSEnever evaluated
0-331
568-
569 if (!cell)
!cellDescription
TRUEnever evaluated
FALSEevaluated 386 times by 1 test
Evaluated by:
  • df
0-386
570 xalloc_die ();
never executed: xalloc_die ();
0
571-
572 hide_problematic_chars (cell);-
573-
574 table[nrows - 1][col] = cell;-
575-
576 columns[col]->width = MAX (columns[col]->width, mbswidth (cell, 0));
(( columns[col...h (cell, 0) ))Description
TRUEevaluated 123 times by 1 test
Evaluated by:
  • df
FALSEevaluated 263 times by 1 test
Evaluated by:
  • df
123-263
577 }
executed 386 times by 1 test: end of block
Executed by:
  • df
386
578}
executed 71 times by 1 test: end of block
Executed by:
  • df
71
579-
580/* Is FSTYPE a type of file system that should be listed? */-
581-
582static bool _GL_ATTRIBUTE_PURE-
583selected_fstype (const char *fstype)-
584{-
585 const struct fs_type_list *fsp;-
586-
587 if (fs_select_list == NULL || fstype == NULL)
fs_select_list == ((void *)0)Description
TRUEevaluated 1025 times by 1 test
Evaluated by:
  • df
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
fstype == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
0-1025
588 return true;
executed 1025 times by 1 test: return 1 ;
Executed by:
  • df
1025
589 for (fsp = fs_select_list; fsp; fsp = fsp->fs_next)
fspDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • df
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
3-4
590 if (STREQ (fstype, fsp->fs_name))
never executed: __result = (((const unsigned char *) (const char *) ( fstype ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( fsp->fs_name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-4
591 return true;
never executed: return 1 ;
0
592 return false;
executed 3 times by 1 test: return 0 ;
Executed by:
  • df
3
593}-
594-
595/* Is FSTYPE a type of file system that should be omitted? */-
596-
597static bool _GL_ATTRIBUTE_PURE-
598excluded_fstype (const char *fstype)-
599{-
600 const struct fs_type_list *fsp;-
601-
602 if (fs_exclude_list == NULL || fstype == NULL)
fs_exclude_list == ((void *)0)Description
TRUEevaluated 1025 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
fstype == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0-1025
603 return false;
executed 1025 times by 1 test: return 0 ;
Executed by:
  • df
1025
604 for (fsp = fs_exclude_list; fsp; fsp = fsp->fs_next)
fspDescription
TRUEnever evaluated
FALSEnever evaluated
0
605 if (STREQ (fstype, fsp->fs_name))
never executed: __result = (((const unsigned char *) (const char *) ( fstype ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( fsp->fs_name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
606 return true;
never executed: return 1 ;
0
607 return false;
never executed: return 0 ;
0
608}-
609-
610static size_t-
611devlist_hash (void const *x, size_t table_size)-
612{-
613 struct devlist const *p = x;-
614 return (uintmax_t) p->dev_num % table_size;
executed 1127 times by 1 test: return (uintmax_t) p->dev_num % table_size;
Executed by:
  • df
1127
615}-
616-
617static bool-
618devlist_compare (void const *x, void const *y)-
619{-
620 struct devlist const *a = x;-
621 struct devlist const *b = y;-
622 return a->dev_num == b->dev_num;
executed 87 times by 1 test: return a->dev_num == b->dev_num;
Executed by:
  • df
87
623}-
624-
625static struct devlist *-
626devlist_for_dev (dev_t dev)-
627{-
628 if (devlist_table == NULL)
devlist_table == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 525 times by 1 test
Evaluated by:
  • df
0-525
629 return NULL;
never executed: return ((void *)0) ;
0
630 struct devlist dev_entry;-
631 dev_entry.dev_num = dev;-
632 return hash_lookup (devlist_table, &dev_entry);
executed 525 times by 1 test: return hash_lookup (devlist_table, &dev_entry);
Executed by:
  • df
525
633}-
634-
635static void-
636devlist_free (void *p)-
637{-
638 free (p);-
639}
executed 567 times by 1 test: end of block
Executed by:
  • df
567
640-
641/* Filter mount list by skipping duplicate entries.-
642 In the case of duplicates - based on the device number - the mount entry-
643 with a '/' in its me_devname (i.e., not pseudo name like tmpfs) wins.-
644 If both have a real devname (e.g. bind mounts), then that with the shorter-
645 me_mountdir wins. With DEVICES_ONLY == true (set with df -a), only update-
646 the global devlist_table, rather than filtering the global mount_list. */-
647-
648static void-
649filter_mount_list (bool devices_only)-
650{-
651 struct mount_entry *me;-
652-
653 /* Temporary list to keep entries ordered. */-
654 struct devlist *device_list = NULL;-
655 int mount_list_size = 0;-
656-
657 for (me = mount_list; me; me = me->me_next)
meDescription
TRUEevaluated 623 times by 1 test
Evaluated by:
  • df
FALSEevaluated 27 times by 1 test
Evaluated by:
  • df
27-623
658 mount_list_size++;
executed 623 times by 1 test: mount_list_size++;
Executed by:
  • df
623
659-
660 devlist_table = hash_initialize (mount_list_size, NULL,-
661 devlist_hash,-
662 devlist_compare,-
663 devlist_free);-
664 if (devlist_table == NULL)
devlist_table == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • df
0-27
665 xalloc_die ();
never executed: xalloc_die ();
0
666-
667 /* Sort all 'wanted' entries into the list device_list. */-
668 for (me = mount_list; me;)
meDescription
TRUEevaluated 623 times by 1 test
Evaluated by:
  • df
FALSEevaluated 27 times by 1 test
Evaluated by:
  • df
27-623
669 {-
670 struct stat buf;-
671 struct mount_entry *discard_me = NULL;-
672-
673 /* Avoid stating remote file systems as that may hang.-
674 On Linux we probably have me_dev populated from /proc/self/mountinfo,-
675 however we still stat() in case another device was mounted later. */-
676 if ((me->me_remote && show_local_fs)
me->me_remoteDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • df
FALSEevaluated 608 times by 1 test
Evaluated by:
  • df
show_local_fsDescription
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • df
0-608
677 || (me->me_dummy && !show_all_fs && !show_listed_fs)
me->me_dummyDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • df
FALSEevaluated 491 times by 1 test
Evaluated by:
  • df
!show_all_fsDescription
TRUEevaluated 126 times by 1 test
Evaluated by:
  • df
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
!show_listed_fsDescription
TRUEevaluated 126 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-491
678 || (!selected_fstype (me->me_type) || excluded_fstype (me->me_type))
!selected_fstype (me->me_type)Description
TRUEnever evaluated
FALSEevaluated 497 times by 1 test
Evaluated by:
  • df
excluded_fstype (me->me_type)Description
TRUEnever evaluated
FALSEevaluated 497 times by 1 test
Evaluated by:
  • df
0-497
679 || -1 == stat (me->me_mountdir, &buf))
-1 == stat (me...ountdir, &buf)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEevaluated 491 times by 1 test
Evaluated by:
  • df
6-491
680 {-
681 /* If remote, and showing just local, or FS type is excluded,-
682 add ME for filtering later.-
683 If stat failed; add ME to be able to complain about it later. */-
684 buf.st_dev = me->me_dev;-
685 }
executed 132 times by 1 test: end of block
Executed by:
  • df
132
686 else-
687 {-
688 /* If we've already seen this device... */-
689 struct devlist *seen_dev = devlist_for_dev (buf.st_dev);-
690-
691 if (seen_dev)
seen_devDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • df
FALSEevaluated 466 times by 1 test
Evaluated by:
  • df
25-466
692 {-
693 bool target_nearer_root = strlen (seen_dev->me->me_mountdir)-
694 > strlen (me->me_mountdir);-
695 /* With bind mounts, prefer items nearer the root of the source */-
696 bool source_below_root = seen_dev->me->me_mntroot != NULL
seen_dev->me->...!= ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 25 times by 1 test
Evaluated by:
  • df
0-25
697 && me->me_mntroot != NULL
me->me_mntroot != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
698 && (strlen (seen_dev->me->me_mntroot)
(strlen (seen_...->me_mntroot))Description
TRUEnever evaluated
FALSEnever evaluated
0
699 < strlen (me->me_mntroot));
(strlen (seen_...->me_mntroot))Description
TRUEnever evaluated
FALSEnever evaluated
0
700 if (! print_grand_total
! print_grand_totalDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
5-20
701 && me->me_remote && seen_dev->me->me_remote
me->me_remoteDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • df
FALSEevaluated 12 times by 1 test
Evaluated by:
  • df
seen_dev->me->me_remoteDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-12
702 && ! STREQ (seen_dev->me->me_devname, me->me_devname))
never executed: __result = (((const unsigned char *) (const char *) ( seen_dev->me->me_devname ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( me->me_devname ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
! ( __extensio...)))); }) == 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • df
FALSEevaluated 4 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-4
703 {-
704 /* Don't discard remote entries with different locations,-
705 as these are more likely to be explicitly mounted.-
706 However avoid this when producing a total to give-
707 a more accurate value in that case. */-
708 }
executed 4 times by 1 test: end of block
Executed by:
  • df
4
709 else if ((strchr (me->me_devname, '/')
(__extension__...name , '/' )))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • df
FALSEevaluated 11 times by 1 test
Evaluated by:
  • df
__builtin_constant_p ( '/' )Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
!__builtin_con...->me_devname )Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
( '/' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 21 times by 1 test
Evaluated by:
  • df
0-21
710 /* let "real" devices with '/' in the name win. */-
711 && ! strchr (seen_dev->me->me_devname, '/'))
! (__extension...name , '/' )))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
__builtin_constant_p ( '/' )Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
!__builtin_con...->me_devname )Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
( '/' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • df
0-10
712 /* let points towards the root of the device win. */-
713 || (target_nearer_root && ! source_below_root)
target_nearer_rootDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEevaluated 11 times by 1 test
Evaluated by:
  • df
! source_below_rootDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-11
714 /* let an entry overmounted on a new device win... */-
715 || (! STREQ (seen_dev->me->me_devname, me->me_devname)
never executed: __result = (((const unsigned char *) (const char *) ( seen_dev->me->me_devname ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( me->me_devname ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
! ( __extensio...)))); }) == 0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-6
716 /* ... but only when matching an existing mnt point,-
717 to avoid problematic replacement when given-
718 inaccurate mount lists, seen with some chroot-
719 environments for example. */-
720 && STREQ (me->me_mountdir,
never executed: __result = (((const unsigned char *) (const char *) ( me->me_mountdir ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( seen_dev->me->me_mountdir ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-6
721 seen_dev->me->me_mountdir)))-
722 {-
723 /* Discard mount entry for existing device. */-
724 discard_me = seen_dev->me;-
725 seen_dev->me = me;-
726 }
executed 16 times by 1 test: end of block
Executed by:
  • df
16
727 else-
728 {-
729 /* Discard mount entry currently being processed. */-
730 discard_me = me;-
731 }
executed 5 times by 1 test: end of block
Executed by:
  • df
5
732-
733 }-
734 }
executed 491 times by 1 test: end of block
Executed by:
  • df
491
735-
736 if (discard_me)
discard_meDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • df
FALSEevaluated 602 times by 1 test
Evaluated by:
  • df
21-602
737 {-
738 me = me->me_next;-
739 if (! devices_only)
! devices_onlyDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • df
FALSEevaluated 4 times by 1 test
Evaluated by:
  • df
4-17
740 free_mount_entry (discard_me);
executed 17 times by 1 test: free_mount_entry (discard_me);
Executed by:
  • df
17
741 }
executed 21 times by 1 test: end of block
Executed by:
  • df
21
742 else-
743 {-
744 /* Add the device number to the device_table. */-
745 struct devlist *devlist = xmalloc (sizeof *devlist);-
746 devlist->me = me;-
747 devlist->dev_num = buf.st_dev;-
748 devlist->next = device_list;-
749 device_list = devlist;-
750 if (hash_insert (devlist_table, devlist) == NULL)
hash_insert (d...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 602 times by 1 test
Evaluated by:
  • df
0-602
751 xalloc_die ();
never executed: xalloc_die ();
0
752-
753 me = me->me_next;-
754 }
executed 602 times by 1 test: end of block
Executed by:
  • df
602
755 }-
756-
757 /* Finally rebuild the mount_list from the devlist. */-
758 if (! devices_only) {
! devices_onlyDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • df
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
2-25
759 mount_list = NULL;-
760 while (device_list)
device_listDescription
TRUEevaluated 571 times by 1 test
Evaluated by:
  • df
FALSEevaluated 25 times by 1 test
Evaluated by:
  • df
25-571
761 {-
762 /* Add the mount entry. */-
763 me = device_list->me;-
764 me->me_next = mount_list;-
765 mount_list = me;-
766 device_list = device_list->next;-
767 }
executed 571 times by 1 test: end of block
Executed by:
  • df
571
768-
769 hash_free (devlist_table);-
770 devlist_table = NULL;-
771 }
executed 25 times by 1 test: end of block
Executed by:
  • df
25
772}
executed 27 times by 1 test: end of block
Executed by:
  • df
27
773-
774-
775/* Search a mount entry list for device id DEV.-
776 Return the corresponding mount entry if found or NULL if not. */-
777-
778static struct mount_entry const * _GL_ATTRIBUTE_PURE-
779me_for_dev (dev_t dev)-
780{-
781 struct devlist *dl = devlist_for_dev (dev);-
782 if (dl)
dlDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
1-33
783 return dl->me;
executed 33 times by 1 test: return dl->me;
Executed by:
  • df
33
784-
785 return NULL;
executed 1 time by 1 test: return ((void *)0) ;
Executed by:
  • df
1
786}-
787-
788/* Return true if N is a known integer value. On many file systems,-
789 UINTMAX_MAX represents an unknown value; on AIX, UINTMAX_MAX - 1-
790 represents unknown. Use a rule that works on AIX file systems, and-
791 that almost-always works on other types. */-
792static bool-
793known_value (uintmax_t n)-
794{-
795 return n < UINTMAX_MAX - 1;
executed 2136 times by 1 test: return n < (18446744073709551615UL) - 1;
Executed by:
  • df
2136
796}-
797-
798/* Like human_readable (N, BUF, human_output_opts, INPUT_UNITS, OUTPUT_UNITS),-
799 except:-
800-
801 - If NEGATIVE, then N represents a negative number,-
802 expressed in two's complement.-
803 - Otherwise, return "-" if N is unknown. */-
804-
805static char const *-
806df_readable (bool negative, uintmax_t n, char *buf,-
807 uintmax_t input_units, uintmax_t output_units)-
808{-
809 if (! known_value (n) && !negative)
! known_value (n)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEevaluated 634 times by 1 test
Evaluated by:
  • df
!negativeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-634
810 return "-";
executed 6 times by 1 test: return "-";
Executed by:
  • df
6
811 else-
812 {-
813 char *p = human_readable (negative ? -n : n, buf + negative,-
814 human_output_opts, input_units, output_units);-
815 if (negative)
negativeDescription
TRUEnever evaluated
FALSEevaluated 634 times by 1 test
Evaluated by:
  • df
0-634
816 *--p = '-';
never executed: *--p = '-';
0
817 return p;
executed 634 times by 1 test: return p;
Executed by:
  • df
634
818 }-
819}-
820-
821/* Logical equivalence */-
822#define LOG_EQ(a, b) (!(a) == !(b))-
823-
824/* Add integral value while using uintmax_t for value part and separate-
825 negation flag. It adds value of SRC and SRC_NEG to DEST and DEST_NEG.-
826 The result will be in DEST and DEST_NEG. See df_readable to understand-
827 how the negation flag is used. */-
828static void-
829add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg,-
830 uintmax_t src, bool src_neg)-
831{-
832 if (LOG_EQ (*dest_neg, src_neg))
(!(*dest_neg) == !(src_neg))Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-20
833 {-
834 *dest += src;-
835 return;
executed 20 times by 1 test: return;
Executed by:
  • df
20
836 }-
837-
838 if (*dest_neg)
*dest_negDescription
TRUEnever evaluated
FALSEnever evaluated
0
839 *dest = -*dest;
never executed: *dest = -*dest;
0
840-
841 if (src_neg)
src_negDescription
TRUEnever evaluated
FALSEnever evaluated
0
842 src = -src;
never executed: src = -src;
0
843-
844 if (src < *dest)
src < *destDescription
TRUEnever evaluated
FALSEnever evaluated
0
845 *dest -= src;
never executed: *dest -= src;
0
846 else-
847 {-
848 *dest = src - *dest;-
849 *dest_neg = src_neg;-
850 }
never executed: end of block
0
851-
852 if (*dest_neg)
*dest_negDescription
TRUEnever evaluated
FALSEnever evaluated
0
853 *dest = -*dest;
never executed: *dest = -*dest;
0
854}
never executed: end of block
0
855-
856/* Return true if S ends in a string that may be a 36-byte UUID,-
857 i.e., of the form HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH, where-
858 each H is an upper or lower case hexadecimal digit. */-
859static bool _GL_ATTRIBUTE_PURE-
860has_uuid_suffix (char const *s)-
861{-
862 size_t len = strlen (s);-
863 return (36 < len
executed 196 times by 1 test: return (36 < len && __builtin_strspn ( s + len - 36 , "-0123456789abcdefABCDEF" ) == 36);
Executed by:
  • df
196
864 && strspn (s + len - 36, "-0123456789abcdefABCDEF") == 36);
executed 196 times by 1 test: return (36 < len && __builtin_strspn ( s + len - 36 , "-0123456789abcdefABCDEF" ) == 36);
Executed by:
  • df
196
865}-
866-
867/* Obtain the block values BV and inode values IV-
868 from the file system usage FSU. */-
869static void-
870get_field_values (struct field_values_t *bv,-
871 struct field_values_t *iv,-
872 const struct fs_usage *fsu)-
873{-
874 /* Inode values. */-
875 iv->input_units = iv->output_units = 1;-
876 iv->total = fsu->fsu_files;-
877 iv->available = iv->available_to_root = fsu->fsu_ffree;-
878 iv->negate_available = false;-
879-
880 iv->used = UINTMAX_MAX;-
881 iv->negate_used = false;-
882 if (known_value (iv->total) && known_value (iv->available_to_root))
known_value (iv->total)Description
TRUEevaluated 242 times by 1 test
Evaluated by:
  • df
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
known_value (i...lable_to_root)Description
TRUEevaluated 242 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-242
883 {-
884 iv->used = iv->total - iv->available_to_root;-
885 iv->negate_used = (iv->total < iv->available_to_root);-
886 }
executed 242 times by 1 test: end of block
Executed by:
  • df
242
887-
888 /* Block values. */-
889 bv->input_units = fsu->fsu_blocksize;-
890 bv->output_units = output_block_size;-
891 bv->total = fsu->fsu_blocks;-
892 bv->available = fsu->fsu_bavail;-
893 bv->available_to_root = fsu->fsu_bfree;-
894 bv->negate_available = (fsu->fsu_bavail_top_bit_set
fsu->fsu_bavail_top_bit_setDescription
TRUEnever evaluated
FALSEevaluated 244 times by 1 test
Evaluated by:
  • df
0-244
895 && known_value (fsu->fsu_bavail));
known_value (fsu->fsu_bavail)Description
TRUEnever evaluated
FALSEnever evaluated
0
896-
897 bv->used = UINTMAX_MAX;-
898 bv->negate_used = false;-
899 if (known_value (bv->total) && known_value (bv->available_to_root))
known_value (bv->total)Description
TRUEevaluated 242 times by 1 test
Evaluated by:
  • df
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
known_value (b...lable_to_root)Description
TRUEevaluated 242 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-242
900 {-
901 bv->used = bv->total - bv->available_to_root;-
902 bv->negate_used = (bv->total < bv->available_to_root);-
903 }
executed 242 times by 1 test: end of block
Executed by:
  • df
242
904}
executed 244 times by 1 test: end of block
Executed by:
  • df
244
905-
906/* Add block and inode values to grand total. */-
907static void-
908add_to_grand_total (struct field_values_t *bv, struct field_values_t *iv)-
909{-
910 if (known_value (iv->total))
known_value (iv->total)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-20
911 grand_fsu.fsu_files += iv->total;
executed 20 times by 1 test: grand_fsu.fsu_files += iv->total;
Executed by:
  • df
20
912 if (known_value (iv->available))
known_value (iv->available)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-20
913 grand_fsu.fsu_ffree += iv->available;
executed 20 times by 1 test: grand_fsu.fsu_ffree += iv->available;
Executed by:
  • df
20
914-
915 if (known_value (bv->total))
known_value (bv->total)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-20
916 grand_fsu.fsu_blocks += bv->input_units * bv->total;
executed 20 times by 1 test: grand_fsu.fsu_blocks += bv->input_units * bv->total;
Executed by:
  • df
20
917 if (known_value (bv->available_to_root))
known_value (b...lable_to_root)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-20
918 grand_fsu.fsu_bfree += bv->input_units * bv->available_to_root;
executed 20 times by 1 test: grand_fsu.fsu_bfree += bv->input_units * bv->available_to_root;
Executed by:
  • df
20
919 if (known_value (bv->available))
known_value (bv->available)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-20
920 add_uint_with_neg_flag (&grand_fsu.fsu_bavail,
executed 20 times by 1 test: add_uint_with_neg_flag (&grand_fsu.fsu_bavail, &grand_fsu.fsu_bavail_top_bit_set, bv->input_units * bv->available, bv->negate_available);
Executed by:
  • df
20
921 &grand_fsu.fsu_bavail_top_bit_set,
executed 20 times by 1 test: add_uint_with_neg_flag (&grand_fsu.fsu_bavail, &grand_fsu.fsu_bavail_top_bit_set, bv->input_units * bv->available, bv->negate_available);
Executed by:
  • df
20
922 bv->input_units * bv->available,
executed 20 times by 1 test: add_uint_with_neg_flag (&grand_fsu.fsu_bavail, &grand_fsu.fsu_bavail_top_bit_set, bv->input_units * bv->available, bv->negate_available);
Executed by:
  • df
20
923 bv->negate_available);
executed 20 times by 1 test: add_uint_with_neg_flag (&grand_fsu.fsu_bavail, &grand_fsu.fsu_bavail_top_bit_set, bv->input_units * bv->available, bv->negate_available);
Executed by:
  • df
20
924}
executed 20 times by 1 test: end of block
Executed by:
  • df
20
925-
926/* Obtain a space listing for the disk device with absolute file name DISK.-
927 If MOUNT_POINT is non-NULL, it is the name of the root of the-
928 file system on DISK.-
929 If STAT_FILE is non-null, it is the name of a file within the file-
930 system that the user originally asked for; this provides better-
931 diagnostics, and sometimes it provides better results on networked-
932 file systems that give different free-space results depending on-
933 where in the file system you probe.-
934 If FSTYPE is non-NULL, it is the type of the file system on DISK.-
935 If MOUNT_POINT is non-NULL, then DISK may be NULL -- certain systems may-
936 not be able to produce statistics in this case.-
937 ME_DUMMY and ME_REMOTE are the mount entry flags.-
938 Caller must set PROCESS_ALL to true when iterating over all entries, as-
939 when df is invoked with no non-option argument. See below for details. */-
940-
941static void-
942get_dev (char const *disk, char const *mount_point, char const* file,-
943 char const *stat_file, char const *fstype,-
944 bool me_dummy, bool me_remote,-
945 const struct fs_usage *force_fsu,-
946 bool process_all)-
947{-
948 if (me_remote && show_local_fs)
me_remoteDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • df
FALSEevaluated 647 times by 1 test
Evaluated by:
  • df
show_local_fsDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • df
0-647
949 return;
never executed: return;
0
950-
951 if (me_dummy && !show_all_fs && !show_listed_fs)
me_dummyDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • df
FALSEevaluated 525 times by 1 test
Evaluated by:
  • df
!show_all_fsDescription
TRUEevaluated 126 times by 1 test
Evaluated by:
  • df
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
!show_listed_fsDescription
TRUEevaluated 126 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-525
952 return;
executed 126 times by 1 test: return;
Executed by:
  • df
126
953-
954 if (!selected_fstype (fstype) || excluded_fstype (fstype))
!selected_fstype (fstype)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 528 times by 1 test
Evaluated by:
  • df
excluded_fstype (fstype)Description
TRUEnever evaluated
FALSEevaluated 528 times by 1 test
Evaluated by:
  • df
0-528
955 return;
executed 3 times by 1 test: return;
Executed by:
  • df
3
956-
957 /* Ignore relative MOUNT_POINTs, which are present for example-
958 in /proc/mounts on Linux with network namespaces. */-
959 if (!force_fsu && mount_point && ! IS_ABSOLUTE_FILE_NAME (mount_point))
!force_fsuDescription
TRUEevaluated 522 times by 1 test
Evaluated by:
  • df
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
mount_pointDescription
TRUEevaluated 522 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
(((mount_point)[0]) == '/')Description
TRUEevaluated 517 times by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
0 != 0Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
0-522
960 return;
executed 5 times by 1 test: return;
Executed by:
  • df
5
961-
962 /* If MOUNT_POINT is NULL, then the file system is not mounted, and this-
963 program reports on the file system that the special file is on.-
964 It would be better to report on the unmounted file system,-
965 but statfs doesn't do that on most systems. */-
966 if (!stat_file)
!stat_fileDescription
TRUEevaluated 488 times by 1 test
Evaluated by:
  • df
FALSEevaluated 35 times by 1 test
Evaluated by:
  • df
35-488
967 stat_file = mount_point ? mount_point : disk;
executed 488 times by 1 test: stat_file = mount_point ? mount_point : disk;
Executed by:
  • df
mount_pointDescription
TRUEevaluated 488 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-488
968-
969 struct fs_usage fsu;-
970 if (force_fsu)
force_fsuDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEevaluated 517 times by 1 test
Evaluated by:
  • df
6-517
971 fsu = *force_fsu;
executed 6 times by 1 test: fsu = *force_fsu;
Executed by:
  • df
6
972 else if (get_fs_usage (stat_file, disk, &fsu))
get_fs_usage (...e, disk, &fsu)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 516 times by 1 test
Evaluated by:
  • df
1-516
973 {-
974 /* If we can't access a system provided entry due-
975 to it not being present (now), or due to permissions,-
976 just output placeholder values rather than failing. */-
977 if (process_all && (errno == EACCES || errno == ENOENT))
process_allDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEnever evaluated
(*__errno_location ()) == 13Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
(*__errno_location ()) == 2Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-1
978 {-
979 if (! show_all_fs)
! show_all_fsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-1
980 return;
executed 1 time by 1 test: return;
Executed by:
  • df
1
981-
982 fstype = "-";-
983 fsu.fsu_bavail_top_bit_set = false;-
984 fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree =-
985 fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX;-
986 }
never executed: end of block
0
987 else-
988 {-
989 error (0, errno, "%s", quotef (stat_file));-
990 exit_status = EXIT_FAILURE;-
991 return;
never executed: return;
0
992 }-
993 }-
994 else if (process_all && show_all_fs)
process_allDescription
TRUEevaluated 474 times by 1 test
Evaluated by:
  • df
FALSEevaluated 42 times by 1 test
Evaluated by:
  • df
show_all_fsDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • df
FALSEevaluated 440 times by 1 test
Evaluated by:
  • df
34-474
995 {-
996 /* Ensure we don't output incorrect stats for over-mounted directories.-
997 Discard stats when the device name doesn't match. Though don't-
998 discard when used and current mount entries are both remote due-
999 to the possibility of aliased host names or exports. */-
1000 struct stat sb;-
1001 if (stat (stat_file, &sb) == 0)
stat (stat_file, &sb) == 0Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-34
1002 {-
1003 struct mount_entry const * dev_me = me_for_dev (sb.st_dev);-
1004 if (dev_me && ! STREQ (dev_me->me_devname, disk)
never executed: __result = (((const unsigned char *) (const char *) ( dev_me->me_devname ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( disk ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
dev_meDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
! ( __extensio...)))); }) == 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 30 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-33
1005 && (! dev_me->me_remote || ! me_remote))
! dev_me->me_remoteDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
! me_remoteDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
0-2
1006 {-
1007 fstype = "-";-
1008 fsu.fsu_bavail_top_bit_set = false;-
1009 fsu.fsu_blocksize = fsu.fsu_blocks = fsu.fsu_bfree =-
1010 fsu.fsu_bavail = fsu.fsu_files = fsu.fsu_ffree = UINTMAX_MAX;-
1011 }
executed 2 times by 1 test: end of block
Executed by:
  • df
2
1012 }
executed 34 times by 1 test: end of block
Executed by:
  • df
34
1013 }
executed 34 times by 1 test: end of block
Executed by:
  • df
34
1014-
1015 if (fsu.fsu_blocks == 0 && !show_all_fs && !show_listed_fs)
fsu.fsu_blocks == 0Description
TRUEevaluated 297 times by 1 test
Evaluated by:
  • df
FALSEevaluated 225 times by 1 test
Evaluated by:
  • df
!show_all_fsDescription
TRUEevaluated 278 times by 1 test
Evaluated by:
  • df
FALSEevaluated 19 times by 1 test
Evaluated by:
  • df
!show_listed_fsDescription
TRUEevaluated 278 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-297
1016 return;
executed 278 times by 1 test: return;
Executed by:
  • df
278
1017-
1018 if (! force_fsu)
! force_fsuDescription
TRUEevaluated 238 times by 1 test
Evaluated by:
  • df
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
6-238
1019 file_systems_processed = true;
executed 238 times by 1 test: file_systems_processed = 1 ;
Executed by:
  • df
238
1020-
1021 alloc_table_row ();-
1022-
1023 if (! disk)
! diskDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEevaluated 239 times by 1 test
Evaluated by:
  • df
5-239
1024 disk = "-"; /* unknown */
executed 5 times by 1 test: disk = "-";
Executed by:
  • df
5
1025-
1026 if (! file)
! fileDescription
TRUEevaluated 202 times by 1 test
Evaluated by:
  • df
FALSEevaluated 42 times by 1 test
Evaluated by:
  • df
42-202
1027 file = "-"; /* unspecified */
executed 202 times by 1 test: file = "-";
Executed by:
  • df
202
1028-
1029 char *dev_name = xstrdup (disk);-
1030 char *resolved_dev;-
1031-
1032 /* On some systems, dev_name is a long-named symlink like-
1033 /dev/disk/by-uuid/828fc648-9f30-43d8-a0b1-f7196a2edb66 pointing to a-
1034 much shorter and more useful name like /dev/sda1. It may also look-
1035 like /dev/mapper/luks-828fc648-9f30-43d8-a0b1-f7196a2edb66 and point to-
1036 /dev/dm-0. When process_all is true and dev_name is a symlink whose-
1037 name ends with a UUID use the resolved name instead. */-
1038 if (process_all
process_allDescription
TRUEevaluated 196 times by 1 test
Evaluated by:
  • df
FALSEevaluated 48 times by 1 test
Evaluated by:
  • df
48-196
1039 && has_uuid_suffix (dev_name)
has_uuid_suffix (dev_name)Description
TRUEnever evaluated
FALSEevaluated 196 times by 1 test
Evaluated by:
  • df
0-196
1040 && (resolved_dev = canonicalize_filename_mode (dev_name, CAN_EXISTING)))
(resolved_dev ...CAN_EXISTING))Description
TRUEnever evaluated
FALSEnever evaluated
0
1041 {-
1042 free (dev_name);-
1043 dev_name = resolved_dev;-
1044 }
never executed: end of block
0
1045-
1046 if (! fstype)
! fstypeDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • df
FALSEevaluated 233 times by 1 test
Evaluated by:
  • df
11-233
1047 fstype = "-"; /* unknown */
executed 11 times by 1 test: fstype = "-";
Executed by:
  • df
11
1048-
1049 struct field_values_t block_values;-
1050 struct field_values_t inode_values;-
1051 get_field_values (&block_values, &inode_values, &fsu);-
1052-
1053 /* Add to grand total unless processing grand total line. */-
1054 if (print_grand_total && ! force_fsu)
print_grand_totalDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • df
FALSEevaluated 218 times by 1 test
Evaluated by:
  • df
! force_fsuDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • df
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
6-218
1055 add_to_grand_total (&block_values, &inode_values);
executed 20 times by 1 test: add_to_grand_total (&block_values, &inode_values);
Executed by:
  • df
20
1056-
1057 size_t col;-
1058 for (col = 0; col < ncolumns; col++)
col < ncolumnsDescription
TRUEevaluated 1326 times by 1 test
Evaluated by:
  • df
FALSEevaluated 244 times by 1 test
Evaluated by:
  • df
244-1326
1059 {-
1060 char buf[LONGEST_HUMAN_READABLE + 2];-
1061 char *cell;-
1062-
1063 struct field_values_t *v;-
1064 switch (columns[col]->field_type)-
1065 {-
1066 case BLOCK_FLD:
executed 805 times by 1 test: case BLOCK_FLD:
Executed by:
  • df
805
1067 v = &block_values;-
1068 break;
executed 805 times by 1 test: break;
Executed by:
  • df
805
1069 case INODE_FLD:
executed 48 times by 1 test: case INODE_FLD:
Executed by:
  • df
48
1070 v = &inode_values;-
1071 break;
executed 48 times by 1 test: break;
Executed by:
  • df
48
1072 case OTHER_FLD:
executed 473 times by 1 test: case OTHER_FLD:
Executed by:
  • df
473
1073 v = NULL;-
1074 break;
executed 473 times by 1 test: break;
Executed by:
  • df
473
1075 default:
never executed: default:
0
1076 v = NULL; /* Avoid warnings where assert() is not __noreturn__. */-
1077 assert (!"bad field_type");-
1078 }
never executed: end of block
0
1079-
1080 switch (columns[col]->field)-
1081 {-
1082 case SOURCE_FIELD:
executed 224 times by 1 test: case SOURCE_FIELD:
Executed by:
  • df
224
1083 cell = xstrdup (dev_name);-
1084 break;
executed 224 times by 1 test: break;
Executed by:
  • df
224
1085-
1086 case FSTYPE_FIELD:
executed 13 times by 1 test: case FSTYPE_FIELD:
Executed by:
  • df
13
1087 cell = xstrdup (fstype);-
1088 break;
executed 13 times by 1 test: break;
Executed by:
  • df
13
1089-
1090 case SIZE_FIELD:
executed 202 times by 1 test: case SIZE_FIELD:
Executed by:
  • df
202
1091 case ITOTAL_FIELD:
executed 12 times by 1 test: case ITOTAL_FIELD:
Executed by:
  • df
12
1092 cell = xstrdup (df_readable (false, v->total, buf,-
1093 v->input_units, v->output_units));-
1094 break;
executed 214 times by 1 test: break;
Executed by:
  • df
214
1095-
1096 case USED_FIELD:
executed 201 times by 1 test: case USED_FIELD:
Executed by:
  • df
201
1097 case IUSED_FIELD:
executed 12 times by 1 test: case IUSED_FIELD:
Executed by:
  • df
12
1098 cell = xstrdup (df_readable (v->negate_used, v->used, buf,-
1099 v->input_units, v->output_units));-
1100 break;
executed 213 times by 1 test: break;
Executed by:
  • df
213
1101-
1102 case AVAIL_FIELD:
executed 201 times by 1 test: case AVAIL_FIELD:
Executed by:
  • df
201
1103 case IAVAIL_FIELD:
executed 12 times by 1 test: case IAVAIL_FIELD:
Executed by:
  • df
12
1104 cell = xstrdup (df_readable (v->negate_available, v->available, buf,-
1105 v->input_units, v->output_units));-
1106 break;
executed 213 times by 1 test: break;
Executed by:
  • df
213
1107-
1108 case PCENT_FIELD:
executed 201 times by 1 test: case PCENT_FIELD:
Executed by:
  • df
201
1109 case IPCENT_FIELD:
executed 12 times by 1 test: case IPCENT_FIELD:
Executed by:
  • df
12
1110 {-
1111 double pct = -1;-
1112 if (! known_value (v->used) || ! known_value (v->available))
! known_value (v->used)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 211 times by 1 test
Evaluated by:
  • df
! known_value (v->available)Description
TRUEnever evaluated
FALSEevaluated 211 times by 1 test
Evaluated by:
  • df
0-211
1113 ;
executed 2 times by 1 test: ;
Executed by:
  • df
2
1114 else if (!v->negate_used
!v->negate_usedDescription
TRUEevaluated 211 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-211
1115 && v->used <= TYPE_MAXIMUM (uintmax_t) / 100
v->used <= ((u...2 + 1))) / 100Description
TRUEevaluated 211 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-211
1116 && v->used + v->available != 0
v->used + v->available != 0Description
TRUEevaluated 192 times by 1 test
Evaluated by:
  • df
FALSEevaluated 19 times by 1 test
Evaluated by:
  • df
19-192
1117 && (v->used + v->available < v->used)
(v->used + v->...gate_availableDescription
TRUEevaluated 192 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-192
1118 == v->negate_available)
(v->used + v->...gate_availableDescription
TRUEevaluated 192 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-192
1119 {-
1120 uintmax_t u100 = v->used * 100;-
1121 uintmax_t nonroot_total = v->used + v->available;-
1122 pct = u100 / nonroot_total + (u100 % nonroot_total != 0);-
1123 }
executed 192 times by 1 test: end of block
Executed by:
  • df
192
1124 else-
1125 {-
1126 /* The calculation cannot be done easily with integer-
1127 arithmetic. Fall back on floating point. This can suffer-
1128 from minor rounding errors, but doing it exactly requires-
1129 multiple precision arithmetic, and it's not worth the-
1130 aggravation. */-
1131 double u = v->negate_used ? - (double) - v->used : v->used;
v->negate_usedDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • df
0-19
1132 double a = v->negate_available
v->negate_availableDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • df
0-19
1133 ? - (double) - v->available : v->available;-
1134 double nonroot_total = u + a;-
1135 if (nonroot_total)
nonroot_totalDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • df
0-19
1136 {-
1137 long int lipct = pct = u * 100 / nonroot_total;-
1138 double ipct = lipct;-
1139-
1140 /* Like 'pct = ceil (dpct);', but avoid ceil so that-
1141 the math library needn't be linked. */-
1142 if (ipct - 1 < pct && pct <= ipct + 1)
ipct - 1 < pctDescription
TRUEnever evaluated
FALSEnever evaluated
pct <= ipct + 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1143 pct = ipct + (ipct < pct);
never executed: pct = ipct + (ipct < pct);
0
1144 }
never executed: end of block
0
1145 }
executed 19 times by 1 test: end of block
Executed by:
  • df
19
1146-
1147 if (0 <= pct)
0 <= pctDescription
TRUEevaluated 192 times by 1 test
Evaluated by:
  • df
FALSEevaluated 21 times by 1 test
Evaluated by:
  • df
21-192
1148 {-
1149 if (asprintf (&cell, "%.0f%%", pct) == -1)
asprintf (&cel...%", pct) == -1Description
TRUEnever evaluated
FALSEevaluated 192 times by 1 test
Evaluated by:
  • df
0-192
1150 cell = NULL;
never executed: cell = ((void *)0) ;
0
1151 }
executed 192 times by 1 test: end of block
Executed by:
  • df
192
1152 else-
1153 cell = strdup ("-");
executed 21 times by 1 test: cell = (__extension__ (__builtin_constant_p ( "-" ) && ((size_t)(const void *)(( "-" ) + 1) - (size_t)(const void *)( "-" ) == 1) ? (((const char *) ( "-" ))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen ( "-" ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void *)0)) __retval = (char *) memcpy (__retval, "-" , __len); __retval; })) : __strdup ( "-" ))) ;
Executed by:
  • df
executed 21 times by 1 test: __retval = (char *) memcpy (__retval, "-" , __len);
Executed by:
  • df
__retval != ((void *)0)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
((const char *... ))[0] == '\0'Description
TRUEnever evaluated
FALSEevaluated 21 times by 1 test
Evaluated by:
  • df
__builtin_constant_p ( "-" )Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
((size_t)(cons...)( "-" ) == 1)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-21
1154-
1155 if (!cell)
!cellDescription
TRUEnever evaluated
FALSEevaluated 213 times by 1 test
Evaluated by:
  • df
0-213
1156 xalloc_die ();
never executed: xalloc_die ();
0
1157-
1158 break;
executed 213 times by 1 test: break;
Executed by:
  • df
213
1159 }-
1160-
1161 case FILE_FIELD:
executed 4 times by 1 test: case FILE_FIELD:
Executed by:
  • df
4
1162 cell = xstrdup (file);-
1163 break;
executed 4 times by 1 test: break;
Executed by:
  • df
4
1164-
1165 case TARGET_FIELD:
executed 232 times by 1 test: case TARGET_FIELD:
Executed by:
  • df
232
1166#ifdef HIDE_AUTOMOUNT_PREFIX-
1167 /* Don't print the first directory name in MOUNT_POINT if it's an-
1168 artifact of an automounter. This is a bit too aggressive to be-
1169 the default. */-
1170 if (STRNCMP_LIT (mount_point, "/auto/") == 0)-
1171 mount_point += 5;-
1172 else if (STRNCMP_LIT (mount_point, "/tmp_mnt/") == 0)-
1173 mount_point += 8;-
1174#endif-
1175 cell = xstrdup (mount_point);-
1176 break;
executed 232 times by 1 test: break;
Executed by:
  • df
232
1177-
1178 default:
never executed: default:
0
1179 assert (!"unhandled field");-
1180 }
never executed: end of block
0
1181-
1182 if (!cell)
!cellDescription
TRUEnever evaluated
FALSEevaluated 1326 times by 1 test
Evaluated by:
  • df
0-1326
1183 assert (!"empty cell");
never executed: (( !"empty cell" ) ? (void) (0) : __assert_fail ( "!\"empty cell\"" , "src/df.c", 1183, __PRETTY_FUNCTION__)) ;
0
1184-
1185 hide_problematic_chars (cell);-
1186 columns[col]->width = MAX (columns[col]->width, mbswidth (cell, 0));
(( columns[col...h (cell, 0) ))Description
TRUEevaluated 1189 times by 1 test
Evaluated by:
  • df
FALSEevaluated 137 times by 1 test
Evaluated by:
  • df
137-1189
1187 table[nrows - 1][col] = cell;-
1188 }
executed 1326 times by 1 test: end of block
Executed by:
  • df
1326
1189 free (dev_name);-
1190}
executed 244 times by 1 test: end of block
Executed by:
  • df
244
1191-
1192/* Scan the mount list returning the _last_ device found for MOUNT.-
1193 NULL is returned if MOUNT not found. The result is malloced. */-
1194static char *-
1195last_device_for_mount (char const* mount)-
1196{-
1197 struct mount_entry const *me;-
1198 struct mount_entry const *le = NULL;-
1199-
1200 for (me = mount_list; me; me = me->me_next)
meDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • df
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
2-52
1201 {-
1202 if (STREQ (me->me_mountdir, mount))
never executed: __result = (((const unsigned char *) (const char *) ( me->me_mountdir ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( mount ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 50 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-50
1203 le = me;
executed 2 times by 1 test: le = me;
Executed by:
  • df
2
1204 }
executed 52 times by 1 test: end of block
Executed by:
  • df
52
1205-
1206 if (le)
leDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-2
1207 {-
1208 char *devname = le->me_devname;-
1209 char *canon_dev = canonicalize_file_name (devname);-
1210 if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev))
canon_devDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
(((canon_dev)[0]) == '/')Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0 != 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2
1211 return canon_dev;
executed 2 times by 1 test: return canon_dev;
Executed by:
  • df
2
1212 free (canon_dev);-
1213 return xstrdup (le->me_devname);
never executed: return xstrdup (le->me_devname);
0
1214 }-
1215 else-
1216 return NULL;
never executed: return ((void *)0) ;
0
1217}-
1218-
1219/* If DISK corresponds to a mount point, show its usage-
1220 and return true. Otherwise, return false. */-
1221static bool-
1222get_disk (char const *disk)-
1223{-
1224 struct mount_entry const *me;-
1225 struct mount_entry const *best_match = NULL;-
1226 bool best_match_accessible = false;-
1227 bool eclipsed_device = false;-
1228 char const *file = disk;-
1229-
1230 char *resolved = canonicalize_file_name (disk);-
1231 if (resolved && IS_ABSOLUTE_FILE_NAME (resolved))
resolvedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
(((resolved)[0]) == '/')Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0 != 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2
1232 disk = resolved;
executed 2 times by 1 test: disk = resolved;
Executed by:
  • df
2
1233-
1234 size_t best_match_len = SIZE_MAX;-
1235 for (me = mount_list; me; me = me->me_next)
meDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-12
1236 {-
1237 /* TODO: Should cache canon_dev in the mount_entry struct. */-
1238 char *devname = me->me_devname;-
1239 char *canon_dev = canonicalize_file_name (me->me_devname);-
1240 if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev))
canon_devDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 10 times by 1 test
Evaluated by:
  • df
(((canon_dev)[0]) == '/')Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0 != 0Description
TRUEnever evaluated
FALSEnever evaluated
0-10
1241 devname = canon_dev;
executed 2 times by 1 test: devname = canon_dev;
Executed by:
  • df
2
1242-
1243 if (STREQ (disk, devname))
never executed: __result = (((const unsigned char *) (const char *) ( disk ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( devname ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 10 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-10
1244 {-
1245 char *last_device = last_device_for_mount (me->me_mountdir);-
1246 eclipsed_device = last_device && ! STREQ (last_device, devname);
never executed: __result = (((const unsigned char *) (const char *) ( last_device ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( devname ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
last_deviceDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
! ( __extensio...)))); }) == 0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2
1247 size_t len = strlen (me->me_mountdir);-
1248-
1249 if (! eclipsed_device
! eclipsed_deviceDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-2
1250 && (! best_match_accessible || len < best_match_len))
! best_match_accessibleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
len < best_match_lenDescription
TRUEnever evaluated
FALSEnever evaluated
0-2
1251 {-
1252 struct stat disk_stats;-
1253 bool this_match_accessible = false;-
1254-
1255 if (stat (me->me_mountdir, &disk_stats) == 0)
stat (me->me_m...sk_stats) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-2
1256 best_match_accessible = this_match_accessible = true;
executed 2 times by 1 test: best_match_accessible = this_match_accessible = 1 ;
Executed by:
  • df
2
1257-
1258 if (this_match_accessible
this_match_accessibleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-2
1259 || (! best_match_accessible && len < best_match_len))
! best_match_accessibleDescription
TRUEnever evaluated
FALSEnever evaluated
len < best_match_lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1260 {-
1261 best_match = me;-
1262 if (len == 1) /* Traditional root. */
len == 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-2
1263 {-
1264 free (last_device);-
1265 free (canon_dev);-
1266 break;
executed 2 times by 1 test: break;
Executed by:
  • df
2
1267 }-
1268 else-
1269 best_match_len = len;
never executed: best_match_len = len;
0
1270 }-
1271 }
never executed: end of block
0
1272-
1273 free (last_device);-
1274 }
never executed: end of block
0
1275-
1276 free (canon_dev);-
1277 }
executed 10 times by 1 test: end of block
Executed by:
  • df
10
1278-
1279 free (resolved);-
1280-
1281 if (best_match)
best_matchDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-2
1282 {-
1283 get_dev (best_match->me_devname, best_match->me_mountdir, file, NULL,-
1284 best_match->me_type, best_match->me_dummy,-
1285 best_match->me_remote, NULL, false);-
1286 return true;
executed 2 times by 1 test: return 1 ;
Executed by:
  • df
2
1287 }-
1288 else if (eclipsed_device)
eclipsed_deviceDescription
TRUEnever evaluated
FALSEnever evaluated
0
1289 {-
1290 error (0, 0, _("cannot access %s: over-mounted by another device"),-
1291 quoteaf (file));-
1292 exit_status = EXIT_FAILURE;-
1293 return true;
never executed: return 1 ;
0
1294 }-
1295-
1296 return false;
never executed: return 0 ;
0
1297}-
1298-
1299/* Figure out which device file or directory POINT is mounted on-
1300 and show its disk usage.-
1301 STATP must be the result of 'stat (POINT, STATP)'. */-
1302static void-
1303get_point (const char *point, const struct stat *statp)-
1304{-
1305 struct stat disk_stats;-
1306 struct mount_entry *me;-
1307 struct mount_entry const *best_match = NULL;-
1308-
1309 /* Calculate the real absolute file name for POINT, and use that to find-
1310 the mount point. This avoids statting unavailable mount points,-
1311 which can hang df. */-
1312 char *resolved = canonicalize_file_name (point);-
1313 if (resolved && resolved[0] == '/')
resolvedDescription
TRUEevaluated 43 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
resolved[0] == '/'Description
TRUEevaluated 43 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-43
1314 {-
1315 size_t resolved_len = strlen (resolved);-
1316 size_t best_match_len = 0;-
1317-
1318 for (me = mount_list; me; me = me->me_next)
meDescription
TRUEevaluated 994 times by 1 test
Evaluated by:
  • df
FALSEevaluated 43 times by 1 test
Evaluated by:
  • df
43-994
1319 {-
1320 if (!STREQ (me->me_type, "lofs")
never executed: __result = (((const unsigned char *) (const char *) ( me->me_type ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "lofs" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
!( __extension...)))); }) == 0)Description
TRUEevaluated 994 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-994
1321 && (!best_match || best_match->me_dummy || !me->me_dummy))
!best_matchDescription
TRUEevaluated 228 times by 1 test
Evaluated by:
  • df
FALSEevaluated 766 times by 1 test
Evaluated by:
  • df
best_match->me_dummyDescription
TRUEnever evaluated
FALSEevaluated 766 times by 1 test
Evaluated by:
  • df
!me->me_dummyDescription
TRUEevaluated 652 times by 1 test
Evaluated by:
  • df
FALSEevaluated 114 times by 1 test
Evaluated by:
  • df
0-766
1322 {-
1323 size_t len = strlen (me->me_mountdir);-
1324 if (best_match_len <= len && len <= resolved_len
best_match_len <= lenDescription
TRUEevaluated 880 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
len <= resolved_lenDescription
TRUEevaluated 858 times by 1 test
Evaluated by:
  • df
FALSEevaluated 22 times by 1 test
Evaluated by:
  • df
0-880
1325 && (len == 1 /* root file system */
len == 1Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • df
FALSEevaluated 820 times by 1 test
Evaluated by:
  • df
38-820
1326 || ((len == resolved_len || resolved[len] == '/')
len == resolved_lenDescription
TRUEnever evaluated
FALSEevaluated 820 times by 1 test
Evaluated by:
  • df
resolved[len] == '/'Description
TRUEevaluated 74 times by 1 test
Evaluated by:
  • df
FALSEevaluated 746 times by 1 test
Evaluated by:
  • df
0-820
1327 && STREQ_LEN (me->me_mountdir, resolved, len))))
never executed: __result = (((const unsigned char *) (const char *) ( me->me_mountdir ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( resolved ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( (__extension... len ))) == 0)Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • df
__builtin_constant_p ( len )Description
TRUEnever evaluated
FALSEevaluated 74 times by 1 test
Evaluated by:
  • df
__builtin_cons...>me_mountdir )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( me->m...ze_t) ( len ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...p ( resolved )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( resol...ze_t) ( len ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-74
1328 {-
1329 best_match = me;-
1330 best_match_len = len;-
1331 }
executed 38 times by 1 test: end of block
Executed by:
  • df
38
1332 }
executed 880 times by 1 test: end of block
Executed by:
  • df
880
1333 }
executed 994 times by 1 test: end of block
Executed by:
  • df
994
1334 }
executed 43 times by 1 test: end of block
Executed by:
  • df
43
1335 free (resolved);-
1336 if (best_match
best_matchDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
5-38
1337 && (stat (best_match->me_mountdir, &disk_stats) != 0
stat (best_mat...sk_stats) != 0Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • df
0-38
1338 || disk_stats.st_dev != statp->st_dev))
disk_stats.st_... statp->st_devDescription
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • df
0-38
1339 best_match = NULL;
never executed: best_match = ((void *)0) ;
0
1340-
1341 if (! best_match)
! best_matchDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEevaluated 38 times by 1 test
Evaluated by:
  • df
5-38
1342 for (me = mount_list; me; me = me->me_next)
meDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
0-5
1343 {-
1344 if (me->me_dev == (dev_t) -1)
me->me_dev == (dev_t) -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1345 {-
1346 if (stat (me->me_mountdir, &disk_stats) == 0)
stat (me->me_m...sk_stats) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1347 me->me_dev = disk_stats.st_dev;
never executed: me->me_dev = disk_stats.st_dev;
0
1348 else-
1349 {-
1350 /* Report only I/O errors. Other errors might be-
1351 caused by shadowed mount points, which means POINT-
1352 can't possibly be on this file system. */-
1353 if (errno == EIO)
(*__errno_location ()) == 5Description
TRUEnever evaluated
FALSEnever evaluated
0
1354 {-
1355 error (0, errno, "%s", quotef (me->me_mountdir));-
1356 exit_status = EXIT_FAILURE;-
1357 }
never executed: end of block
0
1358-
1359 /* So we won't try and fail repeatedly. */-
1360 me->me_dev = (dev_t) -2;-
1361 }
never executed: end of block
0
1362 }-
1363-
1364 if (statp->st_dev == me->me_dev
statp->st_dev == me->me_devDescription
TRUEnever evaluated
FALSEnever evaluated
0
1365 && !STREQ (me->me_type, "lofs")
never executed: __result = (((const unsigned char *) (const char *) ( me->me_type ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "lofs" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
!( __extension...)))); }) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1366 && (!best_match || best_match->me_dummy || !me->me_dummy))
!best_matchDescription
TRUEnever evaluated
FALSEnever evaluated
best_match->me_dummyDescription
TRUEnever evaluated
FALSEnever evaluated
!me->me_dummyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1367 {-
1368 /* Skip bogus mtab entries. */-
1369 if (stat (me->me_mountdir, &disk_stats) != 0
stat (me->me_m...sk_stats) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1370 || disk_stats.st_dev != me->me_dev)
disk_stats.st_... != me->me_devDescription
TRUEnever evaluated
FALSEnever evaluated
0
1371 me->me_dev = (dev_t) -2;
never executed: me->me_dev = (dev_t) -2;
0
1372 else-
1373 best_match = me;
never executed: best_match = me;
0
1374 }-
1375 }
never executed: end of block
0
1376-
1377 if (best_match)
best_matchDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
5-38
1378 get_dev (best_match->me_devname, best_match->me_mountdir, point, point,
executed 38 times by 1 test: get_dev (best_match->me_devname, best_match->me_mountdir, point, point, best_match->me_type, best_match->me_dummy, best_match->me_remote, ((void *)0) , 0 );
Executed by:
  • df
38
1379 best_match->me_type, best_match->me_dummy, best_match->me_remote,
executed 38 times by 1 test: get_dev (best_match->me_devname, best_match->me_mountdir, point, point, best_match->me_type, best_match->me_dummy, best_match->me_remote, ((void *)0) , 0 );
Executed by:
  • df
38
1380 NULL, false);
executed 38 times by 1 test: get_dev (best_match->me_devname, best_match->me_mountdir, point, point, best_match->me_type, best_match->me_dummy, best_match->me_remote, ((void *)0) , 0 );
Executed by:
  • df
38
1381 else-
1382 {-
1383 /* We couldn't find the mount entry corresponding to POINT. Go ahead and-
1384 print as much info as we can; methods that require the device to be-
1385 present will fail at a later point. */-
1386-
1387 /* Find the actual mount point. */-
1388 char *mp = find_mount_point (point, statp);-
1389 if (mp)
mpDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-5
1390 {-
1391 get_dev (NULL, mp, point, NULL, NULL, false, false, NULL, false);-
1392 free (mp);-
1393 }
executed 5 times by 1 test: end of block
Executed by:
  • df
5
1394 }
executed 5 times by 1 test: end of block
Executed by:
  • df
5
1395}-
1396-
1397/* Determine what kind of node NAME is and show the disk usage-
1398 for it. STATP is the results of 'stat' on NAME. */-
1399-
1400static void-
1401get_entry (char const *name, struct stat const *statp)-
1402{-
1403 if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
(((( statp->st... == (0060000))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 43 times by 1 test
Evaluated by:
  • df
(((( statp->st... == (0020000))Description
TRUEnever evaluated
FALSEevaluated 43 times by 1 test
Evaluated by:
  • df
0-43
1404 && get_disk (name))
get_disk (name)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-2
1405 return;
executed 2 times by 1 test: return;
Executed by:
  • df
2
1406-
1407 get_point (name, statp);-
1408}
executed 43 times by 1 test: end of block
Executed by:
  • df
43
1409-
1410/* Show all mounted file systems, except perhaps those that are of-
1411 an unselected type or are empty. */-
1412-
1413static void-
1414get_all_entries (void)-
1415{-
1416 struct mount_entry *me;-
1417-
1418 filter_mount_list (show_all_fs);-
1419-
1420 for (me = mount_list; me; me = me->me_next)
meDescription
TRUEevaluated 606 times by 1 test
Evaluated by:
  • df
FALSEevaluated 27 times by 1 test
Evaluated by:
  • df
27-606
1421 get_dev (me->me_devname, me->me_mountdir, NULL, NULL, me->me_type,
executed 606 times by 1 test: get_dev (me->me_devname, me->me_mountdir, ((void *)0) , ((void *)0) , me->me_type, me->me_dummy, me->me_remote, ((void *)0) , 1 );
Executed by:
  • df
606
1422 me->me_dummy, me->me_remote, NULL, true);
executed 606 times by 1 test: get_dev (me->me_devname, me->me_mountdir, ((void *)0) , ((void *)0) , me->me_type, me->me_dummy, me->me_remote, ((void *)0) , 1 );
Executed by:
  • df
606
1423}
executed 27 times by 1 test: end of block
Executed by:
  • df
27
1424-
1425/* Add FSTYPE to the list of file system types to display. */-
1426-
1427static void-
1428add_fs_type (const char *fstype)-
1429{-
1430 struct fs_type_list *fsp;-
1431-
1432 fsp = xmalloc (sizeof *fsp);-
1433 fsp->fs_name = (char *) fstype;-
1434 fsp->fs_next = fs_select_list;-
1435 fs_select_list = fsp;-
1436}
executed 8 times by 1 test: end of block
Executed by:
  • df
8
1437-
1438/* Add FSTYPE to the list of file system types to be omitted. */-
1439-
1440static void-
1441add_excluded_fs_type (const char *fstype)-
1442{-
1443 struct fs_type_list *fsp;-
1444-
1445 fsp = xmalloc (sizeof *fsp);-
1446 fsp->fs_name = (char *) fstype;-
1447 fsp->fs_next = fs_exclude_list;-
1448 fs_exclude_list = fsp;-
1449}
executed 4 times by 1 test: end of block
Executed by:
  • df
4
1450-
1451void-
1452usage (int status)-
1453{-
1454 if (status != EXIT_SUCCESS)
status != 0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • df
FALSEevaluated 28 times by 1 test
Evaluated by:
  • df
11-28
1455 emit_try_help ();
executed 11 times by 1 test: end of block
Executed by:
  • df
11
1456 else-
1457 {-
1458 printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);-
1459 fputs (_("\-
1460Show information about the file system on which each FILE resides,\n\-
1461or all file systems by default.\n\-
1462"), stdout);-
1463-
1464 emit_mandatory_arg_note ();-
1465-
1466 /* TRANSLATORS: The thousands and decimal separators are best-
1467 adjusted to an appropriate default for your locale. */-
1468 fputs (_("\-
1469 -a, --all include pseudo, duplicate, inaccessible file systems\n\-
1470 -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,\n\-
1471 '-BM' prints sizes in units of 1,048,576 bytes;\n\-
1472 see SIZE format below\n\-
1473 -h, --human-readable print sizes in powers of 1024 (e.g., 1023M)\n\-
1474 -H, --si print sizes in powers of 1000 (e.g., 1.1G)\n\-
1475"), stdout);-
1476 fputs (_("\-
1477 -i, --inodes list inode information instead of block usage\n\-
1478 -k like --block-size=1K\n\-
1479 -l, --local limit listing to local file systems\n\-
1480 --no-sync do not invoke sync before getting usage info (default)\-
1481\n\-
1482"), stdout);-
1483 fputs (_("\-
1484 --output[=FIELD_LIST] use the output format defined by FIELD_LIST,\n\-
1485 or print all fields if FIELD_LIST is omitted.\n\-
1486 -P, --portability use the POSIX output format\n\-
1487 --sync invoke sync before getting usage info\n\-
1488"), stdout);-
1489 fputs (_("\-
1490 --total elide all entries insignificant to available space,\n\-
1491 and produce a grand total\n\-
1492"), stdout);-
1493 fputs (_("\-
1494 -t, --type=TYPE limit listing to file systems of type TYPE\n\-
1495 -T, --print-type print file system type\n\-
1496 -x, --exclude-type=TYPE limit listing to file systems not of type TYPE\n\-
1497 -v (ignored)\n\-
1498"), stdout);-
1499 fputs (HELP_OPTION_DESCRIPTION, stdout);-
1500 fputs (VERSION_OPTION_DESCRIPTION, stdout);-
1501 emit_blocksize_note ("DF");-
1502 emit_size_note ();-
1503 fputs (_("\n\-
1504FIELD_LIST is a comma-separated list of columns to be included. Valid\n\-
1505field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',\n\-
1506'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).\n\-
1507"), stdout);-
1508 emit_ancillary_info (PROGRAM_NAME);-
1509 }
executed 28 times by 1 test: end of block
Executed by:
  • df
28
1510 exit (status);
executed 39 times by 1 test: exit (status);
Executed by:
  • df
39
1511}-
1512-
1513int-
1514main (int argc, char **argv)-
1515{-
1516 struct stat *stats IF_LINT ( = 0);-
1517-
1518 initialize_main (&argc, &argv);-
1519 set_program_name (argv[0]);-
1520 setlocale (LC_ALL, "");-
1521 bindtextdomain (PACKAGE, LOCALEDIR);-
1522 textdomain (PACKAGE);-
1523-
1524 atexit (close_stdout);-
1525-
1526 fs_select_list = NULL;-
1527 fs_exclude_list = NULL;-
1528 show_all_fs = false;-
1529 show_listed_fs = false;-
1530 human_output_opts = -1;-
1531 print_type = false;-
1532 file_systems_processed = false;-
1533 exit_status = EXIT_SUCCESS;-
1534 print_grand_total = false;-
1535 grand_fsu.fsu_blocksize = 1;-
1536-
1537 /* If true, use the POSIX output format. */-
1538 bool posix_format = false;-
1539-
1540 const char *msg_mut_excl = _("options %s and %s are mutually exclusive");-
1541-
1542 while (true)-
1543 {-
1544 int oi = -1;-
1545 int c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:", long_options,-
1546 &oi);-
1547 if (c == -1)
c == -1Description
TRUEevaluated 85 times by 1 test
Evaluated by:
  • df
FALSEevaluated 176 times by 1 test
Evaluated by:
  • df
85-176
1548 break;
executed 85 times by 1 test: break;
Executed by:
  • df
85
1549-
1550 switch (c)-
1551 {-
1552 case 'a':
executed 6 times by 1 test: case 'a':
Executed by:
  • df
6
1553 show_all_fs = true;-
1554 break;
executed 6 times by 1 test: break;
Executed by:
  • df
6
1555 case 'B':
executed 4 times by 1 test: case 'B':
Executed by:
  • df
4
1556 {-
1557 enum strtol_error e = human_options (optarg, &human_output_opts,-
1558 &output_block_size);-
1559 if (e != LONGINT_OK)
e != LONGINT_OKDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • df
FALSEevaluated 2 times by 1 test
Evaluated by:
  • df
2
1560 xstrtol_fatal (e, oi, c, long_options, optarg);
executed 2 times by 1 test: xstrtol_fatal (e, oi, c, long_options, optarg);
Executed by:
  • df
2
1561 }-
1562 break;
executed 2 times by 1 test: break;
Executed by:
  • df
2
1563 case 'i':
executed 9 times by 1 test: case 'i':
Executed by:
  • df
9
1564 if (header_mode == OUTPUT_MODE)
header_mode == OUTPUT_MODEDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 8 times by 1 test
Evaluated by:
  • df
1-8
1565 {-
1566 error (0, 0, msg_mut_excl, "-i", "--output");-
1567 usage (EXIT_FAILURE);-
1568 }
never executed: end of block
0
1569 header_mode = INODES_MODE;-
1570 break;
executed 8 times by 1 test: break;
Executed by:
  • df
8
1571 case 'h':
executed 4 times by 1 test: case 'h':
Executed by:
  • df
4
1572 human_output_opts = human_autoscale | human_SI | human_base_1024;-
1573 output_block_size = 1;-
1574 break;
executed 4 times by 1 test: break;
Executed by:
  • df
4
1575 case 'H':
executed 2 times by 1 test: case 'H':
Executed by:
  • df
2
1576 human_output_opts = human_autoscale | human_SI;-
1577 output_block_size = 1;-
1578 break;
executed 2 times by 1 test: break;
Executed by:
  • df
2
1579 case 'k':
executed 1 time by 1 test: case 'k':
Executed by:
  • df
1
1580 human_output_opts = 0;-
1581 output_block_size = 1024;-
1582 break;
executed 1 time by 1 test: break;
Executed by:
  • df
1
1583 case 'l':
executed 36 times by 1 test: case 'l':
Executed by:
  • df
36
1584 show_local_fs = true;-
1585 break;
executed 36 times by 1 test: break;
Executed by:
  • df
36
1586 case 'm': /* obsolescent, exists for BSD compatibility */
never executed: case 'm':
0
1587 human_output_opts = 0;-
1588 output_block_size = 1024 * 1024;-
1589 break;
never executed: break;
0
1590 case 'T':
executed 10 times by 1 test: case 'T':
Executed by:
  • df
10
1591 if (header_mode == OUTPUT_MODE)
header_mode == OUTPUT_MODEDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 9 times by 1 test
Evaluated by:
  • df
1-9
1592 {-
1593 error (0, 0, msg_mut_excl, "-T", "--output");-
1594 usage (EXIT_FAILURE);-
1595 }
never executed: end of block
0
1596 print_type = true;-
1597 break;
executed 9 times by 1 test: break;
Executed by:
  • df
9
1598 case 'P':
executed 8 times by 1 test: case 'P':
Executed by:
  • df
8
1599 if (header_mode == OUTPUT_MODE)
header_mode == OUTPUT_MODEDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 7 times by 1 test
Evaluated by:
  • df
1-7
1600 {-
1601 error (0, 0, msg_mut_excl, "-P", "--output");-
1602 usage (EXIT_FAILURE);-
1603 }
never executed: end of block
0
1604 posix_format = true;-
1605 break;
executed 7 times by 1 test: break;
Executed by:
  • df
7
1606 case SYNC_OPTION:
executed 1 time by 1 test: case SYNC_OPTION:
Executed by:
  • df
1
1607 require_sync = true;-
1608 break;
executed 1 time by 1 test: break;
Executed by:
  • df
1
1609 case NO_SYNC_OPTION:
executed 1 time by 1 test: case NO_SYNC_OPTION:
Executed by:
  • df
1
1610 require_sync = false;-
1611 break;
executed 1 time by 1 test: break;
Executed by:
  • df
1
1612-
1613 case 'F':
never executed: case 'F':
0
1614 /* Accept -F as a synonym for -t for compatibility with Solaris. */-
1615 case 't':
executed 8 times by 1 test: case 't':
Executed by:
  • df
8
1616 add_fs_type (optarg);-
1617 break;
executed 8 times by 1 test: break;
Executed by:
  • df
8
1618-
1619 case 'v': /* For SysV compatibility. */
executed 1 time by 1 test: case 'v':
Executed by:
  • df
1
1620 /* ignore */-
1621 break;
executed 1 time by 1 test: break;
Executed by:
  • df
1
1622 case 'x':
executed 4 times by 1 test: case 'x':
Executed by:
  • df
4
1623 add_excluded_fs_type (optarg);-
1624 break;
executed 4 times by 1 test: break;
Executed by:
  • df
4
1625-
1626 case OUTPUT_OPTION:
executed 25 times by 1 test: case OUTPUT_OPTION:
Executed by:
  • df
25
1627 if (header_mode == INODES_MODE)
header_mode == INODES_MODEDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 24 times by 1 test
Evaluated by:
  • df
1-24
1628 {-
1629 error (0, 0, msg_mut_excl, "-i", "--output");-
1630 usage (EXIT_FAILURE);-
1631 }
never executed: end of block
0
1632 if (posix_format && header_mode == DEFAULT_MODE)
posix_formatDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 23 times by 1 test
Evaluated by:
  • df
header_mode == DEFAULT_MODEDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEnever evaluated
0-23
1633 {-
1634 error (0, 0, msg_mut_excl, "-P", "--output");-
1635 usage (EXIT_FAILURE);-
1636 }
never executed: end of block
0
1637 if (print_type)
print_typeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 22 times by 1 test
Evaluated by:
  • df
1-22
1638 {-
1639 error (0, 0, msg_mut_excl, "-T", "--output");-
1640 usage (EXIT_FAILURE);-
1641 }
never executed: end of block
0
1642 header_mode = OUTPUT_MODE;-
1643 if (optarg)
optargDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
5-17
1644 decode_output_arg (optarg);
executed 17 times by 1 test: decode_output_arg (optarg);
Executed by:
  • df
17
1645 break;
executed 20 times by 1 test: break;
Executed by:
  • df
20
1646-
1647 case TOTAL_OPTION:
executed 10 times by 1 test: case TOTAL_OPTION:
Executed by:
  • df
10
1648 print_grand_total = true;-
1649 break;
executed 10 times by 1 test: break;
Executed by:
  • df
10
1650-
1651 case_GETOPT_HELP_CHAR;
never executed: break;
executed 28 times by 1 test: case GETOPT_HELP_CHAR:
Executed by:
  • df
0-28
1652 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
executed 15 times by 1 test: exit ( 0 );
Executed by:
  • df
never executed: break;
executed 15 times by 1 test: case GETOPT_VERSION_CHAR:
Executed by:
  • df
0-15
1653-
1654 default:
executed 3 times by 1 test: default:
Executed by:
  • df
3
1655 usage (EXIT_FAILURE);-
1656 }
never executed: end of block
0
1657 }-
1658-
1659 if (human_output_opts == -1)
human_output_opts == -1Description
TRUEevaluated 81 times by 1 test
Evaluated by:
  • df
FALSEevaluated 4 times by 1 test
Evaluated by:
  • df
4-81
1660 {-
1661 if (posix_format)
posix_formatDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 78 times by 1 test
Evaluated by:
  • df
3-78
1662 {-
1663 human_output_opts = 0;-
1664 output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024);
getenv ("POSIXLY_CORRECT")Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
0-3
1665 }
executed 3 times by 1 test: end of block
Executed by:
  • df
3
1666 else-
1667 human_options (getenv ("DF_BLOCK_SIZE"),
executed 78 times by 1 test: human_options (getenv ("DF_BLOCK_SIZE"), &human_output_opts, &output_block_size);
Executed by:
  • df
78
1668 &human_output_opts, &output_block_size);
executed 78 times by 1 test: human_options (getenv ("DF_BLOCK_SIZE"), &human_output_opts, &output_block_size);
Executed by:
  • df
78
1669 }-
1670-
1671 if (header_mode == INODES_MODE || header_mode == OUTPUT_MODE)
header_mode == INODES_MODEDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEevaluated 80 times by 1 test
Evaluated by:
  • df
header_mode == OUTPUT_MODEDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • df
FALSEevaluated 66 times by 1 test
Evaluated by:
  • df
5-80
1672 ;
executed 19 times by 1 test: ;
Executed by:
  • df
19
1673 else if (human_output_opts & human_autoscale)
human_output_o...uman_autoscaleDescription
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • df
0-66
1674 header_mode = HUMAN_MODE;
never executed: header_mode = HUMAN_MODE;
0
1675 else if (posix_format)
posix_formatDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 63 times by 1 test
Evaluated by:
  • df
3-63
1676 header_mode = POSIX_MODE;
executed 3 times by 1 test: header_mode = POSIX_MODE;
Executed by:
  • df
3
1677-
1678 /* Fail if the same file system type was both selected and excluded. */-
1679 {-
1680 bool match = false;-
1681 struct fs_type_list *fs_incl;-
1682 for (fs_incl = fs_select_list; fs_incl; fs_incl = fs_incl->fs_next)
fs_inclDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEevaluated 85 times by 1 test
Evaluated by:
  • df
6-85
1683 {-
1684 struct fs_type_list *fs_excl;-
1685 for (fs_excl = fs_exclude_list; fs_excl; fs_excl = fs_excl->fs_next)
fs_exclDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
0-6
1686 {-
1687 if (STREQ (fs_incl->fs_name, fs_excl->fs_name))
never executed: __result = (((const unsigned char *) (const char *) ( fs_incl->fs_name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( fs_excl->fs_name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1688 {-
1689 error (0, 0,-
1690 _("file system type %s both selected and excluded"),-
1691 quote (fs_incl->fs_name));-
1692 match = true;-
1693 break;
never executed: break;
0
1694 }-
1695 }
never executed: end of block
0
1696 }
executed 6 times by 1 test: end of block
Executed by:
  • df
6
1697 if (match)
matchDescription
TRUEnever evaluated
FALSEevaluated 85 times by 1 test
Evaluated by:
  • df
0-85
1698 return EXIT_FAILURE;
never executed: return 1 ;
0
1699 }-
1700-
1701 assume (0 < optind);-
1702-
1703 if (optind < argc)
optind < argcDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • df
FALSEevaluated 37 times by 1 test
Evaluated by:
  • df
37-48
1704 {-
1705 /* stat each of the given entries to make sure any corresponding-
1706 partition is automounted. This must be done before reading the-
1707 file system table. */-
1708 stats = xnmalloc (argc - optind, sizeof *stats);-
1709 for (int i = optind; i < argc; ++i)
i < argcDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • df
FALSEevaluated 48 times by 1 test
Evaluated by:
  • df
48-50
1710 {-
1711 if (stat (argv[i], &stats[i - optind]))
stat (argv[i],...s[i - optind])Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 49 times by 1 test
Evaluated by:
  • df
1-49
1712 {-
1713 error (0, errno, "%s", quotef (argv[i]));-
1714 exit_status = EXIT_FAILURE;-
1715 argv[i] = NULL;-
1716 }
executed 1 time by 1 test: end of block
Executed by:
  • df
1
1717 else if (! S_ISFIFO (stats[i - optind].st_mode))
! (((( stats[i... == (0010000))Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
1-48
1718 {-
1719 /* open() is needed to automount in some cases. */-
1720 int fd = open (argv[i], O_RDONLY | O_NOCTTY);-
1721 if (0 <= fd)
0 <= fdDescription
TRUEevaluated 45 times by 1 test
Evaluated by:
  • df
FALSEevaluated 3 times by 1 test
Evaluated by:
  • df
3-45
1722 close (fd);
executed 45 times by 1 test: close (fd);
Executed by:
  • df
45
1723 }
executed 48 times by 1 test: end of block
Executed by:
  • df
48
1724 }
executed 50 times by 1 test: end of block
Executed by:
  • df
50
1725 }
executed 48 times by 1 test: end of block
Executed by:
  • df
48
1726-
1727 mount_list =-
1728 read_file_system_list ((fs_select_list != NULL-
1729 || fs_exclude_list != NULL-
1730 || print_type-
1731 || field_data[FSTYPE_FIELD].used-
1732 || show_local_fs));-
1733-
1734 if (mount_list == NULL)
mount_list == ((void *)0)Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • df
FALSEevaluated 66 times by 1 test
Evaluated by:
  • df
19-66
1735 {-
1736 /* Couldn't read the table of mounted file systems.-
1737 Fail if df was invoked with no file name arguments,-
1738 or when either of -a, -l, -t or -x is used with file name-
1739 arguments. Otherwise, merely give a warning and proceed. */-
1740 int status = 0;-
1741 if ( ! (optind < argc)
! (optind < argc)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • df
FALSEevaluated 9 times by 1 test
Evaluated by:
  • df
9-10
1742 || (show_all_fs
show_all_fsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 8 times by 1 test
Evaluated by:
  • df
1-8
1743 || show_local_fs
show_local_fsDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 7 times by 1 test
Evaluated by:
  • df
1-7
1744 || fs_select_list != NULL
fs_select_list != ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 6 times by 1 test
Evaluated by:
  • df
1-6
1745 || fs_exclude_list != NULL))
fs_exclude_list != ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • df
FALSEevaluated 5 times by 1 test
Evaluated by:
  • df
1-5
1746 {-
1747 status = EXIT_FAILURE;-
1748 }
executed 14 times by 1 test: end of block
Executed by:
  • df
14
1749 const char *warning = (status == 0 ? _("Warning: ") : "");
status == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • df
FALSEevaluated 14 times by 1 test
Evaluated by:
  • df
5-14
1750 error (status, errno, "%s%s", warning,-
1751 _("cannot read table of mounted file systems"));-
1752 }
executed 5 times by 1 test: end of block
Executed by:
  • df
5
1753-
1754 if (require_sync)
require_syncDescription
TRUEnever evaluated
FALSEevaluated 71 times by 1 test
Evaluated by:
  • df
0-71
1755 sync ();
never executed: sync ();
0
1756-
1757 get_field_list ();-
1758 get_header ();-
1759-
1760 if (optind < argc)
optind < argcDescription
TRUEevaluated 44 times by 1 test
Evaluated by:
  • df
FALSEevaluated 27 times by 1 test
Evaluated by:
  • df
27-44
1761 {-
1762 /* Display explicitly requested empty file systems. */-
1763 show_listed_fs = true;-
1764-
1765 for (int i = optind; i < argc; ++i)
i < argcDescription
TRUEevaluated 46 times by 1 test
Evaluated by:
  • df
FALSEevaluated 44 times by 1 test
Evaluated by:
  • df
44-46
1766 if (argv[i])
argv[i]Description
TRUEevaluated 45 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
1-45
1767 get_entry (argv[i], &stats[i - optind]);
executed 45 times by 1 test: get_entry (argv[i], &stats[i - optind]);
Executed by:
  • df
45
1768-
1769 IF_LINT (free (stats));-
1770 }
executed 44 times by 1 test: end of block
Executed by:
  • df
44
1771 else-
1772 get_all_entries ();
executed 27 times by 1 test: get_all_entries ();
Executed by:
  • df
27
1773-
1774 if (file_systems_processed)
file_systems_processedDescription
TRUEevaluated 67 times by 1 test
Evaluated by:
  • df
FALSEevaluated 4 times by 1 test
Evaluated by:
  • df
4-67
1775 {-
1776 if (print_grand_total)
print_grand_totalDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • df
FALSEevaluated 61 times by 1 test
Evaluated by:
  • df
6-61
1777 get_dev ("total",
executed 6 times by 1 test: get_dev ("total", (field_data[SOURCE_FIELD].used ? "-" : "total"), ((void *)0) , ((void *)0) , ((void *)0) , 0 , 0 , &grand_fsu, 0 );
Executed by:
  • df
6
1778 (field_data[SOURCE_FIELD].used ? "-" : "total"),
executed 6 times by 1 test: get_dev ("total", (field_data[SOURCE_FIELD].used ? "-" : "total"), ((void *)0) , ((void *)0) , ((void *)0) , 0 , 0 , &grand_fsu, 0 );
Executed by:
  • df
6
1779 NULL, NULL, NULL, false, false, &grand_fsu, false);
executed 6 times by 1 test: get_dev ("total", (field_data[SOURCE_FIELD].used ? "-" : "total"), ((void *)0) , ((void *)0) , ((void *)0) , 0 , 0 , &grand_fsu, 0 );
Executed by:
  • df
6
1780-
1781 print_table ();-
1782 }
executed 67 times by 1 test: end of block
Executed by:
  • df
67
1783 else-
1784 {-
1785 /* Print the "no FS processed" diagnostic only if there was no preceding-
1786 diagnostic, e.g., if all have been excluded. */-
1787 if (exit_status == EXIT_SUCCESS)
exit_status == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • df
FALSEevaluated 1 time by 1 test
Evaluated by:
  • df
1-3
1788 die (EXIT_FAILURE, 0, _("no file systems processed"));
executed 3 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"no file systems processed\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "no file systems processed" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "no file systems processed" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • df
3
1789 }
executed 1 time by 1 test: end of block
Executed by:
  • df
1
1790-
1791 IF_LINT (free (columns));-
1792-
1793 return exit_status;
executed 68 times by 1 test: return exit_status;
Executed by:
  • df
68
1794}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2