# [PATCH] Use dev_t for device id (st_dev) from stat in setup_git_directory_gently()

6 messages from 2010-07-13 to 2010-07-14. Participants: Raja R Harinath, Ævar Arnfjörð Bjarmason, Junio C Hamano.
Thread: https://gitlist.dev/t/24383

## Raja R Harinath, 2010-07-13 09:02

Subject: [PATCH] Use dev_t for device id (st_dev) from stat in setup_git_directory_gently()
Message-ID: <1279011720-21424-1-git-send-email-harinath@hurrynot.org>
URL: https://gitlist.dev/e/1279011720-21424-1-git-send-email-harinath%40hurrynot.org

```
The original declaration was int, which seems to cause trouble on my
machine.  It causes spurious "filesystem boundary" errors when running
the testsuite.  The cause seems to be

  $ stat -c%d .
  2147549952

which is too large for a 32-bit int type.

Using the correct type, dev_t, solves the issue.  (Because I'm
paranoid and forgetful, I checked -- yes, Unix v7 had dev_t.)

Other uses of st_dev seem to be reasonably safe.   fill_stat_cache_info
truncates it to an 'unsigned int', but that value seems to be used only
to validate the cache, and only if USE_STDEV is defined.
---
 setup.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/setup.c b/setup.c
index 7e04602..87c21f0 100644
--- a/setup.c
+++ b/setup.c
@@ -323,7 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	const char *gitdirenv;
 	const char *gitfile_dir;
 	int len, offset, ceil_offset, root_len;
-	int current_device = 0, one_filesystem = 1;
+	dev_t current_device = 0;
+	int one_filesystem = 1;
 	struct stat buf;
 
 	/*
-- 
1.7.2.rc2.11.g03e33

```

## Ævar Arnfjörð Bjarmason, 2010-07-13 09:26

Subject: Re: [PATCH] Use dev_t for device id (st_dev) from stat in setup_git_directory_gently()
Message-ID: <AANLkTiku82MylNMUX6P8be3xSLVg8g8aYsNWodaOM6LQ@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTiku82MylNMUX6P8be3xSLVg8g8aYsNWodaOM6LQ%40mail.gmail.com
In-Reply-To: <1279011720-21424-1-git-send-email-harinath@hurrynot.org>

```
On Tue, Jul 13, 2010 at 09:02, Raja R Harinath <harinath@hurrynot.org> wrote:
> The original declaration was int, which seems to cause trouble on my
> machine.

What OS/architecture is your machine running?

```

## Raja R Harinath, 2010-07-13 12:01

Subject: Re: [PATCH] Use dev_t for device id (st_dev) from stat in setup_git_directory_gently()
Message-ID: <87d3ur7fr1.fsf@hariville.hurrynot.org>
URL: https://gitlist.dev/e/87d3ur7fr1.fsf%40hariville.hurrynot.org
In-Reply-To: <AANLkTiku82MylNMUX6P8be3xSLVg8g8aYsNWodaOM6LQ@mail.gmail.com>

```
Hi,

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> On Tue, Jul 13, 2010 at 09:02, Raja R Harinath <harinath@hurrynot.org> wrote:
>> The original declaration was int, which seems to cause trouble on my
>> machine.
>
> What OS/architecture is your machine running?

Nothing fancy

  $ uname -a
  Linux hariville.hurrynot.org 2.6.35-rc3-00397-g123f94f #146 SMP PREEMPT Mon Jul 5 15:50:47 IST 2010 x86_64 GNU/Linux

  $ df .
  Filesystem           1K-blocks      Used Available Use% Mounted on
  /dev/sda1            959314384 389150456 521433560  43% /

- Hari

```

## Junio C Hamano, 2010-07-13 20:55

Subject: Re: [PATCH] Use dev_t for device id (st_dev) from stat in setup_git_directory_gently()
Message-ID: <7voceb2jaw.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7voceb2jaw.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1279011720-21424-1-git-send-email-harinath@hurrynot.org>

```
Raja R Harinath <harinath@hurrynot.org> writes:

> The original declaration was int, which seems to cause trouble on my
> machine.  It causes spurious "filesystem boundary" errors when running
> the testsuite.  The cause seems to be
>
>   $ stat -c%d .
>   2147549952
>
> which is too large for a 32-bit int type.
>
> Using the correct type, dev_t, solves the issue.  (Because I'm
> paranoid and forgetful, I checked -- yes, Unix v7 had dev_t.)
>
> Other uses of st_dev seem to be reasonably safe.   fill_stat_cache_info
> truncates it to an 'unsigned int', but that value seems to be used only
> to validate the cache, and only if USE_STDEV is defined.
> ---

Makes sense; thanks.

Sign-off?


>  setup.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/setup.c b/setup.c
> index 7e04602..87c21f0 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -323,7 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
>  	const char *gitdirenv;
>  	const char *gitfile_dir;
>  	int len, offset, ceil_offset, root_len;
> -	int current_device = 0, one_filesystem = 1;
> +	dev_t current_device = 0;
> +	int one_filesystem = 1;
>  	struct stat buf;
>  
>  	/*
> -- 
> 1.7.2.rc2.11.g03e33

```

## Raja R Harinath, 2010-07-14 01:08

Subject: Re: [PATCH] Use dev_t for device id (st_dev) from stat in setup_git_directory_gently()
Message-ID: <878w5elvk2.fsf@hariville.hurrynot.org>
URL: https://gitlist.dev/e/878w5elvk2.fsf%40hariville.hurrynot.org
In-Reply-To: <7voceb2jaw.fsf@alter.siamese.dyndns.org>

```
Hi,

Junio C Hamano <gitster@pobox.com> writes:

> Raja R Harinath <harinath@hurrynot.org> writes:
>
>> The original declaration was int, which seems to cause trouble on my
>> machine.  It causes spurious "filesystem boundary" errors when running
>> the testsuite.  The cause seems to be
>>
>>   $ stat -c%d .
>>   2147549952
>>
>> which is too large for a 32-bit int type.
>>
>> Using the correct type, dev_t, solves the issue.  (Because I'm
>> paranoid and forgetful, I checked -- yes, Unix v7 had dev_t.)
>>
>> Other uses of st_dev seem to be reasonably safe.   fill_stat_cache_info
>> truncates it to an 'unsigned int', but that value seems to be used only
>> to validate the cache, and only if USE_STDEV is defined.
>> ---
>
> Makes sense; thanks.
>
> Sign-off?

Signed-off-by: Raja R Harinath <harinath@hurrynot.org>

Do I need to resend?

>>  setup.c |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/setup.c b/setup.c
>> index 7e04602..87c21f0 100644
>> --- a/setup.c
>> +++ b/setup.c
>> @@ -323,7 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
>>  	const char *gitdirenv;
>>  	const char *gitfile_dir;
>>  	int len, offset, ceil_offset, root_len;
>> -	int current_device = 0, one_filesystem = 1;
>> +	dev_t current_device = 0;
>> +	int one_filesystem = 1;
>>  	struct stat buf;
>>  
>>  	/*
>> -- 
>> 1.7.2.rc2.11.g03e33

```

## Junio C Hamano, 2010-07-14 14:55

Subject: Re: [PATCH] Use dev_t for device id (st_dev) from stat in setup_git_directory_gently()
Message-ID: <7voceayuwz.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7voceayuwz.fsf%40alter.siamese.dyndns.org
In-Reply-To: <878w5elvk2.fsf@hariville.hurrynot.org>

```
Raja R Harinath <harinath@hurrynot.org> writes:

> Hi,
>
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Raja R Harinath <harinath@hurrynot.org> writes:
>>
>>> The original declaration was int, which seems to cause trouble on my
>>> machine.  It causes spurious "filesystem boundary" errors when running
>>> the testsuite.  The cause seems to be
>>>
>>>   $ stat -c%d .
>>>   2147549952
>>>
>>> which is too large for a 32-bit int type.
>>>
>>> Using the correct type, dev_t, solves the issue.  (Because I'm
>>> paranoid and forgetful, I checked -- yes, Unix v7 had dev_t.)
>>>
>>> Other uses of st_dev seem to be reasonably safe.   fill_stat_cache_info
>>> truncates it to an 'unsigned int', but that value seems to be used only
>>> to validate the cache, and only if USE_STDEV is defined.
>>> ---
>>
>> Makes sense; thanks.
>>
>> Sign-off?
>
> Signed-off-by: Raja R Harinath <harinath@hurrynot.org>
>
> Do I need to resend?

No.  Again thanks for a fix.

>>>  setup.c |    3 ++-
>>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/setup.c b/setup.c
>>> index 7e04602..87c21f0 100644
>>> --- a/setup.c
>>> +++ b/setup.c
>>> @@ -323,7 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
>>>  	const char *gitdirenv;
>>>  	const char *gitfile_dir;
>>>  	int len, offset, ceil_offset, root_len;
>>> -	int current_device = 0, one_filesystem = 1;
>>> +	dev_t current_device = 0;
>>> +	int one_filesystem = 1;
>>>  	struct stat buf;
>>>  
>>>  	/*
>>> -- 
>>> 1.7.2.rc2.11.g03e33
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

```
