[PATCH 5/5] xfstests: test 197, add a testcase for d_off truncation

Eric Sandeen sandeen at sandeen.net
Tue Dec 30 22:00:17 CST 2008


Christoph Hellwig wrote:

> Make sure our directory offsets fit into a 32 bit value.
> Based on a report by John Stanley.
> 
> 
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> 

...

> +struct linux_dirent64 {
> +	uint64_t	d_ino;
> +	int64_t		d_off;
> +	unsigned short	d_reclen;
> +	unsigned char	d_type;
> +        char		d_name[0];
> +};

...

> +		for (bpos = 0; bpos < nread;) {
> +			d = (struct linux_dirent64 *) (buf + bpos);
> +			/*
> +			 * Can't use off_t here xfsqa is compiled with
> +			 * -D_FILE_OFFSET_BITS=64
> +			 */
> +			if (d->d_off != (long)d->d_off) {

So can this test only fail on a 32-bit arch?  I haven't paid enough
attention to the original bug... sorry if that's a dumb question.  :)

-Eric

> +	                        fprintf(stderr, "detected d_off truncation "
> +						"d_name = %s, d_off = %lld\n",
> +						d->d_name, (long long)d->d_off);
> +        	                exit(EXIT_FAILURE);
> +                	}
> +			bpos += d->d_reclen;
> +		}
> +	}
> +
> +	exit(EXIT_SUCCESS);
> +}




More information about the xfs mailing list