public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* xfsprogs/libhandle : How to get the handle for a symbolic link ?
@ 2010-06-01 11:48 DENIEL Philippe
  2010-06-01 23:29 ` Dave Chinner
  0 siblings, 1 reply; 4+ messages in thread
From: DENIEL Philippe @ 2010-06-01 11:48 UTC (permalink / raw)
  To: xfs

Hi,

I am currently developing a user space nfs server with various backends. 
One of this backend module use xfsprogss's libhandle to implement XFS 
support. I could do almost everything with open_by_handle and 
fd_to_handle, used jointly with ATFILE_SOURCE functions, but I do have a 
problem with symbolic links. To build an xfs object's handle, I get its 
parent handle (now problem to this) then I call "openat" to get the fd 
to the object before calling fd_to_handle. This works ok, but not for 
symbolic link : the openat with follow the link. I added the O_NOFOLLOW 
flag to openat, but now openat return ELOOP instead.
I know there is a readlink_by_handle function in libhandle. How could I 
build the related handle to be used as argument to it (I mean, how to 
build a handle that refers to the symlink itself, not the object it 
points to).

    Regards

       Philippe

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: xfsprogs/libhandle : How to get the handle for a symbolic link ?
  2010-06-01 11:48 xfsprogs/libhandle : How to get the handle for a symbolic link ? DENIEL Philippe
@ 2010-06-01 23:29 ` Dave Chinner
  2010-06-02  7:20   ` DENIEL Philippe
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2010-06-01 23:29 UTC (permalink / raw)
  To: DENIEL Philippe; +Cc: xfs

On Tue, Jun 01, 2010 at 01:48:22PM +0200, DENIEL Philippe wrote:
> Hi,
> 
> I am currently developing a user space nfs server with various
> backends. One of this backend module use xfsprogss's libhandle to
> implement XFS support. I could do almost everything with
> open_by_handle and fd_to_handle, used jointly with ATFILE_SOURCE
> functions, but I do have a problem with symbolic links. To build an
> xfs object's handle, I get its parent handle (now problem to this)
> then I call "openat" to get the fd to the object before calling
> fd_to_handle. This works ok, but not for symbolic link : the openat
> with follow the link. I added the O_NOFOLLOW flag to openat, but now
> openat return ELOOP instead.
> I know there is a readlink_by_handle function in libhandle. How
> could I build the related handle to be used as argument to it (I
> mean, how to build a handle that refers to the symlink itself, not
> the object it points to).

Doesn't path_to_handle() do what you want? From the man page:

	"... If the final component of the path name is a symbolic
	link, the handle returned is that of the link itself."

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: xfsprogs/libhandle : How to get the handle for a symbolic link ?
  2010-06-01 23:29 ` Dave Chinner
@ 2010-06-02  7:20   ` DENIEL Philippe
  2010-06-02 10:06     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: DENIEL Philippe @ 2010-06-02  7:20 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs

Hi Dave,

In fact, path_to_handle does not do the work correctly. Its code is this 
(extract from xfsprogs-3.0.3 sources) :

    int
    path_to_handle(
            char            *path,          /* input,  path to convert */
            void            **hanp,         /* output, pointer to data */
            size_t          *hlen)          /* output, size of returned
    data */
    {
            int             fd;
            int             result;
            comarg_t        obj;

            fd = open(path, O_RDONLY);
            if (fd < 0)
                    return -1;

            obj.path = path;
            result = obj_to_handle(path, fd, XFS_IOC_PATH_TO_HANDLE,
                                    obj, hanp, hlen);
            close(fd);
            return result;
    }

As you see, it performs a open at the beginning, which will results in 
opening the file pointed by the symlink or returns ENOENT if the path 
"inside" the symlink does not exist. I tried using open with O_NOFOLLOW 
option, but it changed nothing, I got ELOOP when opening the file (which 
is a regular behavior so far).
Any other ideas ?

    Philippe



Dave Chinner a écrit :
> On Tue, Jun 01, 2010 at 01:48:22PM +0200, DENIEL Philippe wrote:
>   
>> Hi,
>>
>> I am currently developing a user space nfs server with various
>> backends. One of this backend module use xfsprogss's libhandle to
>> implement XFS support. I could do almost everything with
>> open_by_handle and fd_to_handle, used jointly with ATFILE_SOURCE
>> functions, but I do have a problem with symbolic links. To build an
>> xfs object's handle, I get its parent handle (now problem to this)
>> then I call "openat" to get the fd to the object before calling
>> fd_to_handle. This works ok, but not for symbolic link : the openat
>> with follow the link. I added the O_NOFOLLOW flag to openat, but now
>> openat return ELOOP instead.
>> I know there is a readlink_by_handle function in libhandle. How
>> could I build the related handle to be used as argument to it (I
>> mean, how to build a handle that refers to the symlink itself, not
>> the object it points to).
>>     
>
> Doesn't path_to_handle() do what you want? From the man page:
>
> 	"... If the final component of the path name is a symbolic
> 	link, the handle returned is that of the link itself."
>
> Cheers,
>
> Dave.
>   

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: xfsprogs/libhandle : How to get the handle for a symbolic link ?
  2010-06-02  7:20   ` DENIEL Philippe
@ 2010-06-02 10:06     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2010-06-02 10:06 UTC (permalink / raw)
  To: DENIEL Philippe; +Cc: xfs

On Wed, Jun 02, 2010 at 09:20:31AM +0200, DENIEL Philippe wrote:
> Hi Dave,
>
> In fact, path_to_handle does not do the work correctly. Its code is this  
> (extract from xfsprogs-3.0.3 sources) :

This is fixed as of xfsprogs 3.1.0.  I would recommend to update to the
latests xfsprogs (3.1.2) anyway.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2010-06-02 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-01 11:48 xfsprogs/libhandle : How to get the handle for a symbolic link ? DENIEL Philippe
2010-06-01 23:29 ` Dave Chinner
2010-06-02  7:20   ` DENIEL Philippe
2010-06-02 10:06     ` Christoph Hellwig

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