Use --blocksize instead of --blocksize-bytes, so we can (later) allow users to write "--blocksize 2M"

This commit is contained in:
Sebastian Messmer 2016-03-24 06:45:41 +00:00
parent 6e7004d485
commit 18d05d165e
3 changed files with 9 additions and 4 deletions

View File

@ -5,7 +5,7 @@ Version 0.9.3 (unreleased)
Furthermore, we won't ask for password confirmation when creating a file system but the password only has to be sent once to stdin.
* You can disable the automatic update check by setting CRYFS_NO_UPDATE_CHECK=true in your environment.
* Building CryFS from the GitHub tarball (i.e. when there is no .git directory present) works.
* The ciphertext block size is configurable. You can use the "--blocksize-bytes" command line argument. If not specified, CryFS will ask you for a block size when creating a file system.
* The ciphertext block size is configurable. You can use the "--blocksize" command line argument. If not specified, CryFS will ask you for a block size when creating a file system.
* Fix fstat (a bug in the fstat implementation caused problems with some text editors (e.g. nano) falsely thinking a file changed since they opened it).
* Fix rename (when trying to rename a file to an already existing file name, a bug deleted it instead).
* Rename operation allows overwriting existing files.

View File

@ -63,8 +63,8 @@ ProgramOptions Parser::parse(const vector<string> &supportedCiphers) const {
_checkValidCipher(*cipher, supportedCiphers);
}
optional<uint32_t> blocksizeBytes = none;
if (vm.count("blocksize-bytes")) {
blocksizeBytes = vm["blocksize-bytes"].as<uint32_t>();
if (vm.count("blocksize")) {
blocksizeBytes = vm["blocksize"].as<uint32_t>();
}
return ProgramOptions(baseDir, mountDir, configfile, foreground, unmountAfterIdleMinutes, logfile, cipher, blocksizeBytes, options.second);
@ -113,7 +113,7 @@ void Parser::_addAllowedOptions(po::options_description *desc) {
("config,c", po::value<string>(), "Configuration file")
("foreground,f", "Run CryFS in foreground.")
("cipher", po::value<string>(), "Cipher to use for encryption. See possible values by calling cryfs with --show-ciphers.")
("blocksize-bytes", po::value<uint32_t>(), "The block size used when storing ciphertext blocks (in bytes).")
("blocksize", po::value<uint32_t>(), "The block size used when storing ciphertext blocks (in bytes).")
("show-ciphers", "Show list of supported ciphers.")
("unmount-idle", po::value<double>(), "Automatically unmount after specified number of idle minutes.")
("logfile", po::value<string>(), "Specify the file to write log messages to. If this is not specified, log messages will go to stdout, or syslog if CryFS is running in the background.")

View File

@ -107,6 +107,11 @@ TEST_F(ProgramOptionsParserTest, UnmountAfterIdleMinutesGiven_Float) {
EXPECT_EQ(0.5, options.unmountAfterIdleMinutes().value());
}
TEST_F(ProgramOptionsParserTest, BlocksizeGiven) {
ProgramOptions options = parse({"./myExecutable", "/home/user/baseDir", "--blocksize", "10240", "/home/user/mountDir"});
EXPECT_EQ(10240u, options.blocksizeBytes().value());
}
TEST_F(ProgramOptionsParserTest, InvalidCipher) {
EXPECT_DEATH(
parse({"./myExecutable", "/home/user/baseDir", "--cipher", "invalid-cipher", "/home/user/mountDir"}),