From: tinguely@sgi.com
To: xfs@oss.sgi.com
Subject: [PATCH] libhandle: document the need for path_to_handle
Date: Thu, 09 Apr 2015 08:31:04 -0500 [thread overview]
Message-ID: <20150409133213.214186014@sgi.com> (raw)
In-Reply-To: 1504091316590.18609@sys953.ldn.framestore.com
[-- Attachment #1: libhandle-doc-need-for-path_to_handle.patch --]
[-- Type: text/plain, Size: 2687 bytes --]
The handle ioctls require an open file descriptor to
the XFS mount directory. This file descriptor is found
and supplied in the libhandle code by matching the
entry added with a path_to_handle() call. Document
the requirement and supply a simple example.
Signed-off-by: Mark Tinguely <tinguely@sgi.com>
---
man/man3/handle.3 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)
Index: b/man/man3/handle.3
===================================================================
--- a/man/man3/handle.3
+++ b/man/man3/handle.3
@@ -74,6 +74,12 @@ The
function returns the handle for the filesystem in which the object given by the
.I path
argument resides.
+.I path
+must be the path to the mount point or
+.BR open_by_handle ()
+will return the
+.B ENOTDIR
+error.
.PP
The
.BR fd_to_handle ()
@@ -95,7 +101,16 @@ The
function opens a file descriptor for the object referenced by a handle.
It is analogous and identical to
.BR open (2)
-with the exception of accepting handles instead of path names.
+with the exception of accepting handles instead of path names. The returned
+file descriptor is opened to do invisible IO. Internally,
+.BR open_by_handle ()
+uses the mount point file descriptor that was saved by
+.BR path_to_fshandle ().
+Therefore,
+.BR path_to_fshandle ().
+must be called before calling
+.BR open_by_handle ().
+See below for an example.
.PP
The
.BR readlink_by_handle ()
@@ -192,6 +207,59 @@ does not exist.
.TP
.B EPERM
The caller does not have sufficient privileges.
+.SH EXAMPLE
+Example of
+.BR open_by_handle ().
+.PP
+.Vb 1
+\& main()
+.br
+\& {
+.br
+\& int fd;
+.br
+\& size_t hlen;
+.br
+\& void *han;
+.br
+\& size_t sz_int_used;
+.br
+\& void *hdl_int_used;
+.br
+\& char *mount_path = "/mnt/";
+.br
+\& char *file = "file_to_open";
+.br
+\& if (path_to_handle(file, &han, &hlen) < 0) {
+.br
+\& perror("path-to-handle");
+.br
+\& exit(1);
+.br
+\& }
+.br
+\& /*
+.br
+\& * path_to_fshandle saves an internal copy of the mount point's
+.br
+\& * (/mnt in this example) file descriptor. The open_by_handle call
+.br
+\& * looks up this internal file descriptor and uses it in the
+.br
+\& * xfsctl call to the kernel. Once path_to_fshandle is called,
+.br
+\& * this internal file descriptor remains open for the remaining
+.br
+\& * life of the application.
+.br
+\& */
+.br
+\& path_to_fshandle(mount_path, &hdl_int_used, &sz_int_used);
+.br
+\& fd = open_by_handle(han, hlen, O_RDWR);
+.br
+\&}
+.Ve
.SH SEE ALSO
.BR open (2),
.BR readlink (2),
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-04-09 13:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-09 12:53 Errors from basic open_by_handle operations Mark Hills
2015-04-09 13:09 ` Roger Willcocks
2015-04-09 13:36 ` Mark Hills
2015-04-09 13:27 ` Dave Chinner
2015-04-09 13:31 ` tinguely [this message]
2015-04-13 0:25 ` [PATCH] libhandle: document the need for path_to_handle Dave Chinner
2015-04-09 14:09 ` Errors from basic open_by_handle operations Roger Willcocks
2015-04-09 14:34 ` Mark Hills
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150409133213.214186014@sgi.com \
--to=tinguely@sgi.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.