trinity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Jones <davej@codemonkey.org.uk>
To: tyson.w.smith@gmail.com
Cc: trinity@vger.kernel.org, tysmith@motorola.com
Subject: Re: [PATCH 1/7] add random_pathstring()
Date: Tue, 17 Mar 2015 10:26:07 -0400	[thread overview]
Message-ID: <20150317142607.GA17556@codemonkey.org.uk> (raw)
In-Reply-To: <1426537521-54786-1-git-send-email-tyson.w.smith@gmail.com>

On Mon, Mar 16, 2015 at 01:25:21PM -0700, tyson.w.smith@gmail.com wrote:
 > From: Tyson Smith <tyson.w.smith@gmail.com>
 > 
 > This will generate a path that will likely not exist but may
 > look somewhat valid or totally crazy depending on rand.

We kinda tried this before. It stressed the negative dentry code
a little (perhaps a little too much tbh), but never really found
anything interesting, and just caused trinity to crap garbage
filenames all over the tmp dir.

Not sure it's worth trying this again. If we do, we should
make it a lot less likely to happen, like 1 in a 100 or something.


 > +	switch(rand() % 5) {

Someone recently added a handy ONE_IN macro :)

 > +	case 0:
 > +		// single repeating random ASCII character
 > +		(void) memset(path, (rand() % 95) + 32, rand() % len);
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 1:
 > +		// random ASCII characters 32(space) -> 126(~)
 > +		for (i=0; i < len; i++)
 > +			path[i] = (char) ((rand() % 95) + 32);
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 2:
 > +		// random . or /
 > +		for (i=0; i < len; i++)
 > +			path[i] = RAND_BOOL() ? '.' : '/';
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 3:
 > +		// format strings
 > +		for (i=0; i < (len - 2); i+=2) {
 > +			path[i] = '%';
 > +			path[i+1] = fmts[rand() % 3];
 > +		}
 > +		path[len-1] = '\0';
 > +		break;
 > +	case 4:
 > +		// junk
 > +		for (i=0; i < len; i++)
 > +			path[i] = (char) RAND_BYTE();
 > +		path[len-1] = '\0';
 > +		break;
 > +	}

This should probably just be a generate_rand_bytes() call,
with enhancements to that function if necessary.

	Dave

      reply	other threads:[~2015-03-17 14:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 20:25 [PATCH 1/7] add random_pathstring() tyson.w.smith
2015-03-17 14:26 ` Dave Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150317142607.GA17556@codemonkey.org.uk \
    --to=davej@codemonkey.org.uk \
    --cc=trinity@vger.kernel.org \
    --cc=tysmith@motorola.com \
    --cc=tyson.w.smith@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).