1 /* Copyright (C) 2014 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
11 /* Functions to retrieve information about the filesystem
20 const struct file_system_type network_file_systems[] = {
21 {.name="NFS", .f_type=0x6969, .flag=1},
22 {.name="CIFS", .f_type=0xFF534D42, .flag=1},
24 /* The last entry must be name=NULL */
25 {.name=NULL, .f_type=0, .flag=0}
28 /* List of filesystem to skip the link count test */
29 const struct file_system_type skip_file_systems[] = {
30 {.name="BTRFS", .f_type=0x9123683E, .flag=1},
32 /* The last entry must be name=NULL */
33 {.name=NULL, .f_type=0, .flag=0}
36 short IsNFS(const char *dir_name)
38 #if !defined(WIN32) && (defined(Linux) || defined(FreeBSD) || defined(OpenBSD))
41 /* ignore NFS (0x6969) or CIFS (0xFF534D42) mounts */
42 if ( ! statfs(dir_name, &stfs) )
45 for ( i=0; network_file_systems[i].name != NULL; i++ ) {
47 if(strcasecmp(network_file_systems[i].name, stfs.f_fstypename) == 0) {
49 if(network_file_systems[i].f_type == stfs.f_type ) {
51 return network_file_systems[i].flag;
58 /* If the file exists, throw an error and retreat! If the file does not exist, there
59 * is no reason to spam the log with these errors. */
61 merror("ERROR: statfs('%s') produced error: %s", dir_name, strerror(errno));
67 "INFO: Attempted to check NFS status for '%s', but we don't know how on this OS.",
74 short skipFS(const char *dir_name)
76 #if !defined(WIN32) && (defined(Linux) || defined(FreeBSD) || defined(OpenBSD))
79 if ( ! statfs(dir_name, &stfs) )
82 for ( i=0; skip_file_systems[i].name != NULL; i++ ) {
84 if(strcasecmp(skip_file_systems[i].name, stfs.f_fstypename) == 0) {
86 if(skip_file_systems[i].f_type == stfs.f_type ) {
88 debug1("%s: Skipping dir (FS %s): %s ", ARGV0, skip_file_systems[i].name, dir_name);
89 return skip_file_systems[i].flag;
96 /* If the file exists, throw an error and retreat! If the file does not exist, there
97 * is no reason to spam the log with these errors. */
99 merror("ERROR: statfs('%s') produced error: %s", dir_name, strerror(errno));
105 "INFO: Attempted to check FS status for '%s', but we don't know how on this OS.",