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 } 41 42 return sbuf.f_type; 43 } 44 45 const char *tst_fs_type_name(long f_type) 46 { 47 switch (f_type) { 48 case TST_TMPFS_MAGIC: 49 return "TMPFS"; 50 case TST_NFS_MAGIC: 51 return "NFS"; 52 case TST_V9FS_MAGIC: 53 return "9P"; 54 case TST_RAMFS_MAGIC: 55 return "RAMFS"; 56 case TST_BTRFS_MAGIC: 57 return "BTRFS"; 58 case TST_XFS_MAGIC: 59 return "XFS"; 60 case TST_EXT2_OLD_MAGIC: 61 return "EXT2"; 62 case TST_EXT234_MAGIC: 63 return "EXT2/EXT3/EXT4"; 64 case TST_MINIX_MAGIC: 65 case TST_MINIX_MAGIC2: 66 case TST_MINIX2_MAGIC: 67 case TST_MINIX2_MAGIC2: 68 case TST_MINIX3_MAGIC: 69 return "MINIX"; 70 case TST_UDF_MAGIC: 71 return "UDF"; 72 case TST_SYSV2_MAGIC: 73 case TST_SYSV4_MAGIC: 74 return "SYSV"; 75 case TST_UFS_MAGIC: 76 case TST_UFS2_MAGIC: 77 return "UFS"; 78 case TST_F2FS_MAGIC: 79 return "F2FS"; 80 case TST_NILFS_MAGIC: 81 return "NILFS"; 82 case TST_EXOFS_MAGIC: 83 return "EXOFS"; 84 default: 85 return "Unknown"; 86 } 87 } 88