From 8b41499c652a3ba5cfd121c0e1fc55a6b12641cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 16 Oct 2013 16:09:04 +0200 Subject: [PATCH] Fix conversions, add setMode() operation. --- run.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/run.cpp b/run.cpp index 1cf730a..7df59e0 100644 --- a/run.cpp +++ b/run.cpp @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { std::string arg; if (argc < 3) { - std::cout << "Usage: " << argv[0] << " [ DMLITE_CONFIGFILE [ s | d | h | (r|w|c) [PATH] | z [PATH [SIZE]] ] ]" << std::endl; + std::cout << "Usage: " << argv[0] << " [ DMLITE_CONFIGFILE [ s | d | h | (r|w|c) [PATH] | z [PATH [SIZE]] | m PATH mode ] ]" << std::endl; std::cout << " s ... stat" << std::endl; std::cout << " d ... opendir/readdir" << std::endl; std::cout << " r ... read" << std::endl; @@ -24,6 +24,7 @@ int main(int argc, char *argv[]) { std::cout << " w ... whereToWrite" << std::endl; std::cout << " c ... create" << std::endl; std::cout << " z ... setSize" << std::endl; + std::cout << " m ... setMode" << std::endl; } if (argc >= 2) conf = argv[1]; @@ -161,7 +162,7 @@ int main(int argc, char *argv[]) { operation = "create"; - if (argc >= 5) mode = atoll(arg.c_str()); + if (argc >= 5) mode = strtoull(arg.c_str(), NULL, 8); catalog->create(path, mode); break; @@ -172,11 +173,23 @@ int main(int argc, char *argv[]) { operation = "set size"; size = 20000; - if (argc >= 5) size = strtoull(arg.c_str(), NULL, 8); + if (argc >= 5) size = strtoull(arg.c_str(), NULL, 10); catalog->setSize(path, size); break; } + + case 'm': { + mode_t mode; + + operation = "set mode"; + + mode = 0644; + if (argc >= 5) mode = strtoull(arg.c_str(), NULL, 8); + catalog->setMode(path, mode); + + break; + } } } catch (dmlite::DmException& e) { std::cout << "Could not " << operation << "." << std::endl -- 1.8.2.3