2 * Copyright (C) 2014 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #if defined(__linux__)
25 #elif defined(__APPLE__) && defined(__MACH__)
29 #ifndef USE_MINGW /* O_BINARY is windows-specific flag */
33 static void usage(char *path)
35 fprintf(stderr, "%s -l <len>\n", basename(path));
36 fprintf(stderr, " <filename>\n");
39 int main(int argc, char **argv)
42 const char *filename = NULL;
46 while ((opt = getopt(argc, argv, "l:")) != -1) {
59 fprintf(stderr, "Expected filename after options\n");
64 filename = argv[optind++];
67 fprintf(stderr, "Unexpected argument: %s\n", argv[optind]);
72 if (strcmp(filename, "-")) {
73 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
82 exitcode = make_f2fs_sparse_fd(fd, len, NULL, NULL);
85 if (exitcode && strcmp(filename, "-"))