Re: Errors from basic open_by_handle operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)
    exit(4);

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

  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>

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




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux