| 1 | /* |
| 2 | * AIDE (Advanced Intrusion Detection Environment) |
| 3 | * |
| 4 | * Copyright (C) 2016,2020,2021,2024,2025 Hannes von Haugwitz |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of the |
| 9 | * License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #ifndef _FILE_H_INCLUDED |
| 22 | #define _FILE_H_INCLUDED |
| 23 | |
| 24 | #include "config.h" |
| 25 | #include <sys/stat.h> |
| 26 | #include <limits.h> |
| 27 | |
| 28 | #define FT_TYPE unsigned int |
| 29 | #define FT_NULL 0U |
| 30 | |
| 31 | #define FT_REG (1U<<0) /* file */ |
| 32 | #define FT_DIR (1U<<1) /* dir */ |
| 33 | #define FT_FIFO (1U<<2) /* fifo */ |
| 34 | #define FT_LNK (1U<<3) /* link */ |
| 35 | #define FT_BLK (1U<<4) /* block device */ |
| 36 | #define FT_CHR (1U<<5) /* char device */ |
| 37 | #define FT_SOCK (1U<<6) /* socket */ |
| 38 | #define FT_DOOR (1U<<7) /* door */ |
| 39 | #define FT_PORT (1U<<8) /* port */ |
| 40 | |
| 41 | char get_f_type_char_from_f_type(FT_TYPE); |
| 42 | char *get_f_type_string_from_f_type(FT_TYPE); |
| 43 | char get_f_type_char_from_perm(mode_t); |
| 44 | char *get_f_type_string_from_perm(mode_t); |
| 45 | FT_TYPE get_f_type_from_char(char); |
| 46 | FT_TYPE get_f_type_from_perm(mode_t); |
| 47 | |
| 48 | #ifdef HAVE_FSTYPE |
| 49 | #define FS_TYPE unsigned long |
| 50 | |
| 51 | typedef struct { |
| 52 | char *str; |
| 53 | unsigned int magic; |
| 54 | } filesystem_t; |
| 55 | |
| 56 | FS_TYPE get_fs_type_from_string(const char *); |
| 57 | int generate_fs_type_string(FS_TYPE, char*); |
| 58 | char * get_fs_type_string_from_magic(FS_TYPE); |
| 59 | |
| 60 | extern filesystem_t filesystems[]; |
| 61 | extern int num_filesystems; |
| 62 | #endif |
| 63 | |
| 64 | typedef struct file_t { |
| 65 | char* name; |
| 66 | FT_TYPE type; |
| 67 | #ifdef HAVE_FSTYPE |
| 68 | FS_TYPE fs_type; |
| 69 | #endif |
| 70 | } file_t; |
| 71 | |
| 72 | #endif |