1 /* 2 * Copyright (c) 2005-2014 Linux Test Project 3 * 4 * Cyril Hrubis <chrubis (at) suse.cz> 2014 5 * Michal Simek <monstr (at) monstr.eu> 2009 6 * Kumar Gala <galak (at) kernel.crashing.org> 2007 7 * Ricky Ng-Adam <rngadam (at) yahoo.com> 2005 8 * 9 * This program is free software; you can redistribute it and/or modify it 10 * under the terms of version 2 of the GNU General Public License as 11 * published by the Free Software Foundation. 12 * 13 * This program is distributed in the hope that it would be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * Further, this software is distributed without any warranty that it is 18 * free of the rightful claim of any third person regarding infringement 19 * or the like. Any license provided herein, whether implied or 20 * otherwise, applies only to this software file. Patent licenses, if 21 * any, provided herein do not apply to combinations of this program with 22 * other software, or any other product whatsoever. 23 * 24 * You should have received a copy of the GNU General Public License along 25 * with this program; if not, write the Free Software Foundation, Inc., 26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 27 */ 28 29 #include <sys/vfs.h> 30 #include "test.h" 31 #include "tst_fs.h" 32 33 long tst_fs_type_(void (*cleanup)(void), const char *path) 34 { 35 struct statfs sbuf; 36 37 if (statfs(path, &sbuf)) { 38 tst_brkm(TBROK | TERRNO, cleanup, 39 "tst_fs_type: Failed to statfs(%s)", path); 40 return 0; 41 } 42 43 return sbuf.f_type; 44 } 45 46 const char *tst_fs_type_name(long f_type) 47 { 48 switch (f_type) { 49 case TST_TMPFS_MAGIC: 50 return "TMPFS"; 51 case TST_NFS_MAGIC: 52 return "NFS"; 53 case TST_V9FS_MAGIC: 54 return "9P"; 55 case TST_RAMFS_MAGIC: 56 return "RAMFS"; 57 case TST_BTRFS_MAGIC: 58 return "BTRFS"; 59 case TST_XFS_MAGIC: 60 return "XFS"; 61 case TST_EXT2_OLD_MAGIC: 62 return "EXT2"; 63 case TST_EXT234_MAGIC: 64 return "EXT2/EXT3/EXT4"; 65 case TST_MINIX_MAGIC: 66 case TST_MINIX_MAGIC2: 67 case TST_MINIX2_MAGIC: 68 case TST_MINIX2_MAGIC2: 69 case TST_MINIX3_MAGIC: 70 return "MINIX"; 71 case TST_UDF_MAGIC: 72 return "UDF"; 73 case TST_SYSV2_MAGIC: 74 case TST_SYSV4_MAGIC: 75 return "SYSV"; 76 case TST_UFS_MAGIC: 77 case TST_UFS2_MAGIC: 78 return "UFS"; 79 case TST_F2FS_MAGIC: 80 return "F2FS"; 81 case TST_NILFS_MAGIC: 82 return "NILFS"; 83 case TST_EXOFS_MAGIC: 84 return "EXOFS"; 85 default: 86 return "Unknown"; 87 } 88 } 89