[Top] [All Lists]

Re: Errors from basic open_by_handle operations

To: Mark Hills <mark.hills@xxxxxxxxxxxxxx>
Subject: Re: Errors from basic open_by_handle operations
From: Roger Willcocks <roger@xxxxxxxxxxxxxxxx>
Date: Thu, 09 Apr 2015 15:09:18 +0100
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1504091316590.18609@xxxxxxxxxxxxxxxxxxxxxxxxx>
References: <1504091316590.18609@xxxxxxxxxxxxxxxxxxxxxxxxx>
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

/* g++ handle_test.cpp -lhandle */

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <xfs/handle.h>

int main(int argc, char *argv[])
  void *xfs_handle = 0;
  size_t hlen = 0;

  if (path_to_fshandle("/mnt/disk1", &xfs_handle, &hlen) < 0)

  if (path_to_handle("/mnt/disk1/test", &xfs_handle, &hlen) < 0)

  printf("hlen = %d\n", (int)hlen);

  int fd = open_by_handle(xfs_handle, hlen, O_RDWR);

  printf("fd = %d\n", fd);
  return 0;

On Thu, 2015-04-09 at 13:53 +0100, Mark Hills wrote:
> I am having troubles with elementary file handle functions in libhandle.
> A basic open_by_handle is giving "Bad file descriptor".
> But I am suspicious of a side effect; using path_to_fshandle earlier in 
> the program changes these errors to "Operation not permitted".
> Is there a basic mistake in my use of these calls, or a bug/unmaintained 
> code?
> I am on an XFS filesystem (otherwise the first call fails with 
> 'inappropriate ioctl'). The only documentation I can find is the man page; 
> no mention about initialising the library, and I wasn't able to find any 
> examples.
> I'm on Scientific Linux 6.6 (like RedHat 6, kernel 2.6.32-504.1.3), and 
> also tried updating to the latest xfsprogs from Git, with the same 
> results.
> Many thanks
Roger Willcocks <roger@xxxxxxxxxxxxxxxx>

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