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 14:36:58 +0100 (BST)
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1428584963.5198.478.camel@xxxxxxxxxxxxxxxxxxxxxxxx>
References: <1504091316590.18609@xxxxxxxxxxxxxxxxxxxxxxxxx> <1428584963.5198.478.camel@xxxxxxxxxxxxxxxxxxxxxxxx>
On Thu, 9 Apr 2015, Roger Willcocks wrote:

> There's a small gotcha - the filesystem itself has to have been opened:
> 
>         void *xfs_handle = 0;
>         size_t hlen  = 0;
> 
>         /* xfs library needs the filesystem to have been opened */
> 
>         if (path_to_fshandle(mountpoint, &xfs_handle, &hlen) < 0) {
>                 /* error */
>                 exit(4);
>         }
> 
>         free(xfs_handle);

Thank you Roger, that moves me one step but not to success

Now I know "Operation not permitted" is the correct message I assume that 
use of XFS file handles requires root.

But even as root, I cannot open a file with O_RDONLY:

  $ sudo ./test-xfs ~/scratch/tmp/xfs/file.c ; echo $?
  Handle 8 bytes: bd2c94ba959858
  Handle 24 bytes: bd2c94ba959858e0000000870000000
  readlink_by_handle: Not a directory
  open_by_handle: Not a directory
  0

I am able to do open_by_handle(O_RDONLY) on a directory though:

  $ sudo ./test-xfs ~/scratch/tmp/xfs/directory ; echo $?
  Handle 8 bytes: bd2c94ba959858
  Handle 24 bytes: bd2c94ba959858e0000000880000000
  readlink_by_handle: Invalid argument
  0

and a readlink_by_handle on a symlink works:

  $ sudo ./test-xfs ~/scratch/tmp/xfs/link.c ; echo $?
  Handle 8 bytes: bd2c94ba959858
  Handle 24 bytes: bd2c94ba959858e0000000860000000
  Link: fortress.c
  open_by_handle: Operation not permitted
  0

Switching to O_RDWR does not succeed in opening a file either, and also 
stops the directory case.

It seems possible flags are getting mangled and are not what I think they 
mean. The docs state the call as analogous to open(); is the 'oflags' 
argument actually ready to accept O_RDONLY etc. or some other set of 
flags? Because it seems like I can't actually open a file here.

Many thanks

-- 
Mark

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