xfs
[Top] [All Lists]

Re: Errors from basic open_by_handle operations

To: Roger Willcocks <roger@xxxxxxxxxxxxxxxx>
Subject: Re: Errors from basic open_by_handle operations
From: Mark Hills <mark.hills@xxxxxxxxxxxxxx>
Date: Thu, 9 Apr 2015 15:34:22 +0100 (BST)
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1428588558.5198.483.camel@xxxxxxxxxxxxxxxxxxxxxxxx>
References: <1504091316590.18609@xxxxxxxxxxxxxxxxxxxxxxxxx> <1428588558.5198.483.camel@xxxxxxxxxxxxxxxxxxxxxxxx>
On Thu, 9 Apr 2015, Roger Willcocks wrote:

> The code below works here on a CentOS 6.4 box ('test' is a file at the
> root of the volume):
> 
> $ ./a.out
> hlen = 24
> fd = -1
> $ sudo ./a.out
> hlen = 24
> fd = 4

Yup, and I can reproduce that here on my system, thanks.

It seems the subtlety is rooted here:

>   if (path_to_fshandle("/mnt/disk1", &xfs_handle, &hlen) < 0)
>     exit(4);
> 
>   if (path_to_handle("/mnt/disk1/test", &xfs_handle, &hlen) < 0)
>     exit(5);

This code is correct, and it looks like it's necessary to do 
path_to_fshandle on the file system root, otherwise it does not satisfy 
the precondition of open_by_handle().

So what I was doing:

  path_to_fshandle("/mnt/disk1/test-file" ... );
  ...
  path_to_handle("/mnt/disk1/test-file" ... );

even though it reports the expected success (and returns the right file 
handles), is not enough to allow open_by_handle() to work on a file.

It does leave me needing to have prior knowledge of the mounted filesystem 
root (or look it up); handle_to_fshandle() doesn't achieve the same.

Definitely some oddities here -- but now I have enough to get me started 
though I hope.

Thanks for all the help, and perhaps I can look at some patches to the man 
page as I go.

Thanks

-- 
Mark

<Prev in Thread] Current Thread [Next in Thread>