public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-developers@cygwin.com
Subject: Re: fstat and similar methods in fhandler_socket_local and fhandler_socket_unix
Date: Wed, 24 Feb 2021 18:06:56 +0100	[thread overview]
Message-ID: <YDaHsA7H3wZx6bKu@calimero.vinschen.de> (raw)
In-Reply-To: <db1bab02-ec13-8925-5932-9ed03ebc544d@cornell.edu>

On Feb 24 10:32, Ken Brown via Cygwin-developers wrote:
> On 2/24/2021 4:06 AM, Corinna Vinschen via Cygwin-developers wrote:
> > On Feb 22 15:01, Ken Brown via Cygwin-developers wrote:
> > > OK, I've got patches ready to go for fstat, fstatvfs, fchmod, fchown, facl,
> > > and link.  I have to test them, and then I'll send them to cygwin-patches.
> > > In the case of link, I think the only way an fhandler_socket's link method
> > > can be called is through link(2) being called on a socket file.  So the
> > > following should do the job:
> > > 
> > > diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
> > > index 21e1df172..f4aa12956 100644
> > > --- a/winsup/cygwin/fhandler.h
> > > +++ b/winsup/cygwin/fhandler.h
> > > @@ -611,7 +611,6 @@ class fhandler_socket: public fhandler_base
> > >     int __reg1 fchmod (mode_t newmode);
> > >     int __reg2 fchown (uid_t newuid, gid_t newgid);
> > >     int __reg3 facl (int, int, struct acl *);
> > > -  int __reg2 link (const char *);
> > >     off_t lseek (off_t, int)
> > >     {
> > >       set_errno (ESPIPE);
> > > diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
> > > index f22412650..08870cc6b 100644
> > > --- a/winsup/cygwin/fhandler_socket.cc
> > > +++ b/winsup/cygwin/fhandler_socket.cc
> > > @@ -357,9 +357,3 @@ fhandler_socket::facl (int cmd, int nentries, aclent_t *aclbufp)
> > >     set_errno (EOPNOTSUPP);
> > >     return -1;
> > >   }
> > > -
> > > -int
> > > -fhandler_socket::link (const char *newpath)
> > > -{
> > > -  return fhandler_base::link (newpath);
> > > -}
> > 
> > Hmm.  What about linkat (AT_EMPTY_PATH, socket, ...)?
> > 
> > This could be called for inet sockets as well as unnamed or abstract
> > unix sockets, in theory...
> 
> Thanks, I missed that case.  So we do need fhandler_socket::link.  The only
> question in my mind is what errno it should set.  I just tried the
> following:
> [...]
> On Linux I get
> 
>   linkat: Invalid cross-device link
> 
> So I think fhandler_socket::link should fail with EXDEV.  Probably it should
> continue to call fhandler_base::link, and the latter should fail with EXDEV
> instead of EPERM.  Or is there some case where EPERM is more appropriate?

fhandler_base::link returns EPERM because that covers "filesystem does
not support the creation of hard links", which is the most probable
case.  If we want to return EXDEV by default, the non-disk_file error
case will have to check if oldpath and newpath are on the same
filesystem.  I wonder if this is really worth the effort.


Corinna

  reply	other threads:[~2021-02-24 17:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-20 23:32 Ken Brown
2021-02-20 23:51 ` Ken Brown
2021-02-21 18:04   ` Ken Brown
2021-02-22  9:44     ` Corinna Vinschen
2021-02-22 20:01       ` Ken Brown
2021-02-24  9:06         ` Corinna Vinschen
2021-02-24 15:32           ` Ken Brown
2021-02-24 17:06             ` Corinna Vinschen [this message]
2021-02-24 17:27               ` Ken Brown
2021-02-25 13:18                 ` Ken Brown
2021-02-25 17:03                   ` Corinna Vinschen

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=YDaHsA7H3wZx6bKu@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-developers@cygwin.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).