diff options
author | Aaron <aaron@10gen.com> | 2011-01-03 14:04:58 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2011-01-03 14:05:36 -0800 |
commit | befcc2704c5347c0f707882bde2adbe9c9eca78f (patch) | |
tree | dfadb2d89cc6e505d32411a91775da012b60829c /shell/shell_utils.cpp | |
parent | 764400caa28e1063a97754e50f03c31be3726c95 (diff) | |
download | mongo-befcc2704c5347c0f707882bde2adbe9c9eca78f.tar.gz |
add fuzzFile() shell function
Diffstat (limited to 'shell/shell_utils.cpp')
-rw-r--r-- | shell/shell_utils.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/shell/shell_utils.cpp b/shell/shell_utils.cpp index b676a46cb15..981e2508577 100644 --- a/shell/shell_utils.cpp +++ b/shell/shell_utils.cpp @@ -47,6 +47,7 @@ #include "../util/text.h" #include "../util/heapcheck.h" #include "../util/time_support.h" +#include "../util/file.h" namespace mongo { @@ -274,6 +275,26 @@ namespace mongo { b.appendBool( "removed" , found ); return b.obj(); } + + /** + * @param args - [ name, byte index ] + * In this initial implementation, all bits in the specified byte are flipped. + */ + BSONObj fuzzFile(const BSONObj& args){ + uassert( 13619, "fuzzFile takes 2 arguments", args.nFields() == 2 ); + shared_ptr< File > f( new File() ); + f->open( args.getStringField( "0" ) ); + uassert( 13620, "couldn't open file to fuzz", !f->bad() && f->is_open() ); + + char c; + f->read( args.getIntField( "1" ), &c, 1 ); + c = ~c; + f->write( args.getIntField( "1" ), &c, 1 ); + + return undefined_; + // f close is implicit + } + map< int, pair< pid_t, int > > dbs; map< pid_t, int > shells; #ifdef _WIN32 @@ -875,6 +896,7 @@ namespace mongo { scope.injectNative( "getHostName" , getHostName ); scope.injectNative( "removeFile" , removeFile ); + scope.injectNative( "fuzzFile" , fuzzFile ); scope.injectNative( "listFiles" , listFiles ); scope.injectNative( "ls" , ls ); scope.injectNative( "pwd", pwd ); |