On Thu, May 28, 2015 at 3:03 AM, Torsten Bögershausen <tbo...@web.de> wrote:
> On 2015-05-27 15.33, Paul Tan wrote:
>> +/**
>> + * xopen() is the same as open(), but it die()s if the open() fails.
>> + */
>> +int xopen(const char *path, int flags, mode_t mode)
>> +{
>> +     int fd;
>> +
>> +     assert(path);
>> +     fd = open(path, flags, mode);
>> +     if (fd < 0) {
>> +             if ((flags & O_WRONLY) || (flags & O_RDWR))
>> +                     die_errno(_("could not open '%s' for writing"), path);
> This is only partly true:
> it could be either "writing" or "read write".

Ah right, I see now that the POSIX spec allows for, and encourages
O_RDONLY | O_WRONLY == O_RDWR.

> I don't know if the info "for reading" or "for writing" is needed/helpful at 
> all,
> or if a simple "could not open" would be enough.

Yeah, I agree that it may not be helpful, but I noticed that most
error messages in git are of the form "unable to open X for writing",
"unable to open X for reading", "could not create X" etc. Or rather I
thought I noticed, but it now seems to me that there are quite a lot
of uses of "could not open X" as well.

I guess I will remove the distinction.

Thanks,
Paul
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to