public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* btrfsctl exit with 1 when succeed
@ 2009-11-11  6:16 Gong, Zhipeng
  2009-12-25  0:19 ` TARUISI Hiroaki
  0 siblings, 1 reply; 4+ messages in thread
From: Gong, Zhipeng @ 2009-11-11  6:16 UTC (permalink / raw)
  To: linux-btrfs@vger.kernel.org

We'd like to use btrfsctl in a shell script, however, btrfsctl exit wit=
h 1 even if the operation is successful, which is opposite to the usual=
 shell command convention.
Why btrfsctl add this conversion in the end?
=A0=A0=A0=A0=A0=A0=A0=A0 if (ret)
=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0 exit(0);
=A0=A0=A0=A0=A0=A0=A0=A0 else
=A0=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0 exit(1);

Thanks
Zhipeng
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: btrfsctl exit with 1 when succeed
  2009-11-11  6:16 btrfsctl exit with 1 when succeed Gong, Zhipeng
@ 2009-12-25  0:19 ` TARUISI Hiroaki
  2009-12-25  9:25   ` Goffredo Baroncelli
  0 siblings, 1 reply; 4+ messages in thread
From: TARUISI Hiroaki @ 2009-12-25  0:19 UTC (permalink / raw)
  To: zhipeng.gong; +Cc: linux-btrfs, chris.mason

I also want to know why this conversion is needed.
This might be a typo, I think.

Could someone tell us why?
Can we fix this conversion? Or shouldn't we fix it
considering back-compatibility?

Regards,
taruisi

(2009/11/11 15:16), Gong, Zhipeng wrote:
> We'd like to use btrfsctl in a shell script, however, btrfsctl exit with 1 even if the operation is successful, which is opposite to the usual shell command convention.
> Why btrfsctl add this conversion in the end?
>          if (ret)
>                   exit(0);
>          else
>                   exit(1);
> 
> Thanks
> Zhipeng
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: btrfsctl exit with 1 when succeed
  2009-12-25  0:19 ` TARUISI Hiroaki
@ 2009-12-25  9:25   ` Goffredo Baroncelli
  2009-12-27 23:39     ` TARUISI Hiroaki
  0 siblings, 1 reply; 4+ messages in thread
From: Goffredo Baroncelli @ 2009-12-25  9:25 UTC (permalink / raw)
  To: TARUISI Hiroaki; +Cc: linux-btrfs, zhipeng.gong

On Friday 25 December 2009, TARUISI Hiroaki wrote:
> I also want to know why this conversion is needed.
> This might be a typo, I think.
> 
> Could someone tell us why?
> Can we fix this conversion? Or shouldn't we fix it
> considering back-compatibility?
> 

It is even worse: the result code returned by btrfsctl is not coherent.
btrfsctl returns always 1 except:
- after a devices scan (in this case the result is _always_ 0)
- if the ioctl returns a value greater than 0 

In other all cases (error in the command line, the device btrfs-control 
doesn't exists, error in opening a file) the return code is 1.

That doesn't permit to differentiate an error from a good return. 

BR
Goffredo


> Regards,
> taruisi
> 
> (2009/11/11 15:16), Gong, Zhipeng wrote:
> > We'd like to use btrfsctl in a shell script, however, btrfsctl exit with 1 
even if the operation is successful, which is opposite to the usual shell 
command convention.
> > Why btrfsctl add this conversion in the end?
> >          if (ret)
> >                   exit(0);
> >          else
> >                   exit(1);
> > 
> > Thanks
> > Zhipeng
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: btrfsctl exit with 1 when succeed
  2009-12-25  9:25   ` Goffredo Baroncelli
@ 2009-12-27 23:39     ` TARUISI Hiroaki
  0 siblings, 0 replies; 4+ messages in thread
From: TARUISI Hiroaki @ 2009-12-27 23:39 UTC (permalink / raw)
  To: kreijack; +Cc: linux-btrfs, zhipeng.gong, chris.mason

Thank you, I don't think of a devices scan.

After all, I wonder why. Return codes must be
coherent so that we can know good from no-good
by them. In this spec, it's very hard to make
shell scripts with btrfsctl. If there isn't good
reason, we need to fix it, I think.

(2009/12/25 18:25), Goffredo Baroncelli wrote:
> On Friday 25 December 2009, TARUISI Hiroaki wrote:
>> I also want to know why this conversion is needed.
>> This might be a typo, I think.
>>
>> Could someone tell us why?
>> Can we fix this conversion? Or shouldn't we fix it
>> considering back-compatibility?
>>
> 
> It is even worse: the result code returned by btrfsctl is not coherent.
> btrfsctl returns always 1 except:
> - after a devices scan (in this case the result is _always_ 0)
> - if the ioctl returns a value greater than 0 
> 
> In other all cases (error in the command line, the device btrfs-control 
> doesn't exists, error in opening a file) the return code is 1.
> 
> That doesn't permit to differentiate an error from a good return. 
> 
> BR
> Goffredo
> 
> 
>> Regards,
>> taruisi
>>
>> (2009/11/11 15:16), Gong, Zhipeng wrote:
>>> We'd like to use btrfsctl in a shell script, however, btrfsctl exit with 1 
> even if the operation is successful, which is opposite to the usual shell 
> command convention.
>>> Why btrfsctl add this conversion in the end?
>>>          if (ret)
>>>                   exit(0);
>>>          else
>>>                   exit(1);
>>>
>>> Thanks
>>> Zhipeng
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> 
> 


-- 
taruisi


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-27 23:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-11  6:16 btrfsctl exit with 1 when succeed Gong, Zhipeng
2009-12-25  0:19 ` TARUISI Hiroaki
2009-12-25  9:25   ` Goffredo Baroncelli
2009-12-27 23:39     ` TARUISI Hiroaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox