Commit | Line | Data |
---|---|---|
ebac4655 JA |
1 | /* |
2 | * fio - the flexible io tester | |
3 | * | |
4 | * Copyright (C) 2005 Jens Axboe <axboe@suse.de> | |
2e1df07d | 5 | * Copyright (C) 2006-2012 Jens Axboe <axboe@kernel.dk> |
ebac4655 | 6 | * |
8e9fe637 JA |
7 | * The license below covers all files distributed with fio unless otherwise |
8 | * noted in the file itself. | |
9 | * | |
ebac4655 | 10 | * This program is free software; you can redistribute it and/or modify |
8e9fe637 JA |
11 | * it under the terms of the GNU General Public License version 2 as |
12 | * published by the Free Software Foundation. | |
ebac4655 JA |
13 | * |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | */ | |
ebac4655 | 24 | #include <unistd.h> |
dbe1125e | 25 | #include <locale.h> |
a5b01f1b | 26 | #include <time.h> |
ebac4655 JA |
27 | |
28 | #include "fio.h" | |
210f43b3 | 29 | #include "hash.h" |
2e5cdb11 | 30 | #include "smalloc.h" |
4f5af7b2 | 31 | #include "verify.h" |
a917a8b3 | 32 | #include "trim.h" |
7c9b1bce | 33 | #include "diskutil.h" |
07b3232d | 34 | #include "profile.h" |
d54a144d | 35 | #include "lib/rand.h" |
91aea6ec | 36 | #include "memalign.h" |
dd366728 | 37 | #include "client.h" |
009b1be4 | 38 | #include "server.h" |
ebac4655 | 39 | |
cfc99db7 JA |
40 | unsigned long page_mask; |
41 | unsigned long page_size; | |
d529ee19 | 42 | |
0ad5edcc JA |
43 | static int endian_check(void) |
44 | { | |
45 | union { | |
46 | uint8_t c[8]; | |
47 | uint64_t v; | |
48 | } u; | |
49 | int le = 0, be = 0; | |
50 | ||
51 | u.v = 0x12; | |
52 | if (u.c[7] == 0x12) | |
53 | be = 1; | |
54 | else if (u.c[0] == 0x12) | |
55 | le = 1; | |
56 | ||
57 | #if defined(FIO_LITTLE_ENDIAN) | |
58 | if (be) | |
59 | return 1; | |
60 | #elif defined(FIO_BIG_ENDIAN) | |
61 | if (le) | |
62 | return 1; | |
63 | #else | |
64 | return 1; | |
65 | #endif | |
66 | ||
67 | if (!le && !be) | |
68 | return 1; | |
69 | ||
70 | return 0; | |
71 | } | |
72 | ||
50d16976 JA |
73 | int main(int argc, char *argv[], char *envp[]) |
74 | { | |
75 | long ps; | |
76 | ||
0ad5edcc JA |
77 | if (endian_check()) { |
78 | log_err("fio: endianness settings appear wrong.\n"); | |
79 | log_err("fio: please report this to fio@vger.kernel.org\n"); | |
80 | return 1; | |
81 | } | |
82 | ||
50d16976 JA |
83 | arch_init(envp); |
84 | ||
85 | sinit(); | |
86 | ||
87 | /* | |
88 | * We need locale for number printing, if it isn't set then just | |
89 | * go with the US format. | |
90 | */ | |
91 | if (!getenv("LC_NUMERIC")) | |
92 | setlocale(LC_NUMERIC, "en_US"); | |
93 | ||
94 | ps = sysconf(_SC_PAGESIZE); | |
95 | if (ps < 0) { | |
96 | log_err("Failed to get page size\n"); | |
97 | return 1; | |
98 | } | |
99 | ||
100 | page_size = ps; | |
101 | page_mask = ps - 1; | |
102 | ||
103 | fio_keywords_init(); | |
104 | ||
105 | if (parse_options(argc, argv)) | |
106 | return 1; | |
107 | ||
2e1df07d | 108 | if (nr_clients) |
dd366728 | 109 | return fio_handle_clients(&fio_client_ops); |
2e1df07d JA |
110 | else |
111 | return fio_backend(); | |
50d16976 | 112 | } |