readahead.c revision 87ce22cc0d097d9cd0297d0141eadba6c573c299
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2012 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <getopt.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "util.h"
#include "def.h"
#include "readahead-common.h"
static int help(void) {
printf("%s [OPTIONS...] collect [DIRECTORY]\n\n"
"Collect read-ahead data on early boot.\n\n"
" -h --help Show this help\n"
" --max-files=INT Maximum number of files to read ahead\n"
" --file-size-max=BYTES Maximum size of files to read ahead\n"
" --timeout=USEC Maximum time to spend collecting data\n\n\n",
printf("%s [OPTIONS...] replay [DIRECTORY]\n\n"
"Replay collected read-ahead data on early boot.\n\n"
" -h --help Show this help\n"
" --file-size-max=BYTES Maximum size of files to read ahead\n\n\n",
printf("%s [OPTIONS...] analyze [PACK FILE]\n\n"
"Analyze collected read-ahead data.\n\n"
" -h --help Show this help\n",
return 0;
}
enum {
ARG_FILES_MAX = 0x100,
};
};
int c;
switch (c) {
case 'h':
help();
return 0;
case ARG_FILES_MAX:
return -EINVAL;
}
break;
case ARG_FILE_SIZE_MAX: {
unsigned long long ull;
return -EINVAL;
}
break;
}
case ARG_TIMEOUT:
return -EINVAL;
}
break;
case '?':
return -EINVAL;
default:
log_error("Unknown option code %c", c);
return -EINVAL;
}
}
help();
return -EINVAL;
}
return 1;
}
int r;
log_open();
umask(0022);
if (r <= 0)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
return EXIT_FAILURE;
}