llapi_layout_comp_flags_get.3 \
llapi_layout_comp_flags_set.3 \
llapi_layout_comp_id_get.3 \
- llapi_layout_comp_move.3 \
- llapi_layout_comp_move_at.3 \
+ llapi_layout_comp_use.3 \
+ llapi_layout_comp_use_id.3 \
llapi_layout_file_comp_add.3 \
llapi_layout_file_comp_del.3 \
llapi_layout_file_create.3 \
layout = llapi_layout_get_by_path(path, 0);
/* Move cursor to the first component */
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_FIRST);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST);
/* Traverse all components */
while (rc == 0) {
llapi_layout_comp_extent_get(layout, &start, &end);
/* Advance cursor */
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_NEXT);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_NEXT);
};
/* Free layout */
.BR llapi_layout_comp_id_get (3),
.BR llapi_layout_comp_add (3),
.BR llapi_layout_comp_del (3),
-.BR llapi_layout_comp_move (3),
-.BR llapi_layout_comp_move_at (3),
+.BR llapi_layout_comp_use (3),
+.BR llapi_layout_comp_use_id (3),
.BR llapi_layout_file_comp_add (3),
.BR llapi_layout_file_comp_del (3),
.BR lfs (1),
+++ /dev/null
-.TH llapi_layout_comp_move 3 "2015 Nov 4" "Lustre User API"
-.SH NAME
-llapi_layout_comp_move \- Move the current component of layout to a specified
-position: first, next or last.
-llapi_layout_comp_move_at \- Move the current component of layout to a component
-with specified component id.
-.SH SYNOPSIS
-.nf
-.B #include <lustre/lustreapi.h>
-.PP
-.BI "int llapi_layout_comp_move(struct llapi_layout *" layout ",
-.BI " uint32_t *" pos );
-.PP
-.BI "int llapi_layout_comp_move_at(struct llapi_layout *" layout ",
-.BI " uint32_t *" comp_id );
-.fi
-.SH DESCRIPTION
-.PP
-Moves the current component of the
-.IR layout .
-to a specified position.
-.PP
-.BR llapi_layout_comp_move (3)
-Moves current component to
-.IR pos .
-Available
-.IR pos
-are:
-.PP
-.BR LLAPI_LAYOUT_COMP_POS_FIRST:
-The first component of the layout.
-.PP
-.BR LLAPI_LAYOUT_COMP_POS_NEXT:
-The next component of current one.
-.PP
-.BR LLAPI_LAYOUT_COMP_POS_LAST:
-The last component of the layout.
-.PP
-.BR llapi_layout_comp_move_at (3)
-Moves current component to the component with specified
-.IR comp_id .
-.SH RETURN VALUES
-Return 0 on success, 1 when reaches last component when try to move next, or -1 if
-an error occurred (in which case, errno is set appropriately).
-.SH ERRORS
-.TP 15
-.SM EINVAL
-An invalid argument was specified.
-.SH "SEE ALSO"
-.BR llapi_layout_alloc (3),
-.BR llapi_layout_file_open (3),
-.BR llapi_layout_comp_id (3),
-.BR llapi_layout (7),
-.BR lustreapi (7)
+++ /dev/null
-.so man3/llapi_layout_comp_move.3
--- /dev/null
+.TH llapi_layout_comp_use 3 "2017 Apr 7" "Lustre User API"
+.SH NAME
+llapi_layout_comp_use \- change current component to relative position
+.SH SYNOPSIS
+.nf
+.B #include <lustre/lustreapi.h>
+.PP
+.BI "int llapi_layout_comp_use(struct llapi_layout *" layout ",
+.BI " enum llapi_layout_comp_use *" pos );
+.fi
+.SH DESCRIPTION
+.PP
+Changes the currently active component of
+.I layout
+to the relative position given by
+.IR pos .
+Possible values for
+.I pos
+are:
+.PP
+.BR LLAPI_LAYOUT_COMP_USE_FIRST :
+The first component of the layout.
+.PP
+.BR LLAPI_LAYOUT_COMP_USE_NEXT :
+The next component after the current one.
+.PP
+.BR LLAPI_LAYOUT_COMP_USE_LAST :
+The last component of the layout.
+.SH RETURN VALUES
+Return 0 on success, and 1 when there is no next component. Otherwise,
+if an error occurred -1 is returned and
+.I errno
+is set appropriately.
+.SH ERRORS
+.TP 15
+.SM EINVAL
+An invalid argument was specified.
+.TP 15
+.SM ENOENT
+No such component ID exists.
+.SH "SEE ALSO"
+.BR llapi_layout_alloc (3),
+.BR llapi_layout_file_open (3),
+.BR llapi_layout_comp_del (3),
+.BR llapi_layout_comp_use_id (3),
+.BR llapi_layout (7),
+.BR lustreapi (7)
--- /dev/null
+.TH llapi_layout_comp_use_id 3 "2017 Apr 7" "Lustre User API"
+.SH NAME
+llapi_layout_comp_use_id \- set currently active component to given ID
+.SH SYNOPSIS
+.nf
+.B #include <lustre/lustreapi.h>
+.PP
+.BI "int llapi_layout_comp_use_id(struct llapi_layout *" layout ",
+.BI " uint32_t *" comp_id );
+.fi
+.SH DESCRIPTION
+.PP
+Sets currently active component of
+.I layout
+to the component with specified
+.IR comp_id .
+.SH RETURN VALUES
+Return 0 on success. Otherwise, if an error occurred -1 is returned and
+.I errno
+is set appropriately.
+.SH ERRORS
+.TP 15
+.SM ENOENT
+No such component ID exists.
+.TP 15
+.SM EINVAL
+An invalid argument was specified.
+.SH "SEE ALSO"
+.BR llapi_layout_alloc (3),
+.BR llapi_layout_file_open (3),
+.BR llapi_layout_comp_del (3),
+.BR llapi_layout_comp_id_get (3),
+.BR llapi_layout_comp_use (3),
+.BR llapi_layout (7),
+.BR lustreapi (7)
.BR llapi_layout_get_by_path (3),
.BR llapi_layout_file_comp_add (3),
.BR llapi_layout_comp_id_get (3),
-.BR llapi_layout_comp_move_at (3),
+.BR llapi_layout_comp_use_id (3),
.BR llapi_layout (7),
.BR lustreapi (7)
.BR llapi_layout_comp_flags_get (3),
.BR llapi_layout_comp_flags_set (3),
.BR llapi_layout_comp_id_get (3),
-.BR llapi_layout_comp_move (3),
-.BR llapi_layout_comp_move_at (3),
+.BR llapi_layout_comp_use (3),
+.BR llapi_layout_comp_use_id (3),
.BR llapi_layout_file_comp_add (3),
.BR llapi_layout_file_comp_del (3),
.BR llapi_layout_file_create (3),
*/
int llapi_layout_comp_del(struct llapi_layout *layout);
-enum {
- LLAPI_LAYOUT_COMP_POS_NEXT = 0,
- LLAPI_LAYOUT_COMP_POS_FIRST = 1,
- LLAPI_LAYOUT_COMP_POS_LAST = 2
+enum llapi_layout_comp_use {
+ LLAPI_LAYOUT_COMP_USE_FIRST = 1,
+ LLAPI_LAYOUT_COMP_USE_LAST = 2,
+ LLAPI_LAYOUT_COMP_USE_NEXT = 3,
};
/**
- * Move the current component pointer by specified component ID.
+ * Set the currently active component to the specified component ID.
*/
-int llapi_layout_comp_move_at(struct llapi_layout *layout, uint32_t id);
+int llapi_layout_comp_use_id(struct llapi_layout *layout, uint32_t id);
/**
- * Move the current component pointer to a specified position.
+ * Select the currently active component at the specified position.
*/
-int llapi_layout_comp_move(struct llapi_layout *layout, uint32_t pos);
+int llapi_layout_comp_use(struct llapi_layout *layout, uint32_t pos);
/**
* Add layout components to an existing file.
*/
ASSERTF(s == start[2] && e == end[2],
"s: %"PRIu64", e: %"PRIu64"", s, e);
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_FIRST);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST);
ASSERTF(rc == 0, "rc %d, errno %d", rc, errno);
/* delete non-tail component will fail */
ASSERTF(s == start[0] && e == end[0],
"s: %"PRIu64", e: %"PRIu64"", s, e);
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_NEXT);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_NEXT);
ASSERTF(rc == 0, "rc %d, errno %d", rc, errno);
rc = llapi_layout_comp_extent_get(layout, &s, &e);
ASSERTF(s == start[1] && e == end[1],
"s: %"PRIu64", e: %"PRIu64"", s, e);
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_NEXT);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_NEXT);
ASSERTF(rc == 0, "rc %d, errno %d", rc, errno);
rc = llapi_layout_comp_del(layout);
layout = llapi_layout_get_by_path(path, 0);
ASSERTF(layout != NULL, "errno = %d", errno);
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_FIRST);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST);
ASSERTF(rc == 0, "rc %d, errno %d", rc, errno);
i = 0;
do {
ASSERTF(rc == 0 && id[i] != 0, "i %d, errno %d, id %d",
i, errno, id[i]);
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_NEXT);
- ASSERTF(rc >= 0, "i %d, rc %d, errno %d", i, rc, errno);
-
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_NEXT);
+ ASSERTF(rc == 0 || i == 1, "i=%d rc=%d errno=%d", i, rc, errno);
i++;
} while (rc == 0);
layout = llapi_layout_get_by_path(path, 0);
ASSERTF(layout != NULL, "errno = %d", errno);
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_FIRST);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST);
ASSERTF(rc == 0, "rc %d, errno %d", rc, errno);
rc = llapi_layout_comp_extent_get(layout, &s, &e);
llapi_layout_free(head);
/* Make sure we use the first component of the layout to be added. */
- rc = llapi_layout_comp_move(layout, LLAPI_LAYOUT_COMP_POS_FIRST);
+ rc = llapi_layout_comp_use(layout, LLAPI_LAYOUT_COMP_USE_FIRST);
if (rc < 0) {
fprintf(stderr, "Move component cursor failed. %s\n",
strerror(errno));
* \retval =0 : moved successfully
* \retval <0 if error occurs
*/
-int llapi_layout_comp_move_at(struct llapi_layout *layout, uint32_t id)
+int llapi_layout_comp_use_id(struct llapi_layout *layout, uint32_t comp_id)
{
struct llapi_layout_comp *comp;
comp = __llapi_layout_cur_comp(layout);
if (comp == NULL)
- return -1;
+ return -1; /* use previously set errno */
if (!layout->llot_is_composite) {
errno = EINVAL;
return -1;
}
- if (id == 0) {
+ if (comp_id == LCME_ID_INVAL) {
errno = EINVAL;
return -1;
}
list_for_each_entry(comp, &layout->llot_comp_list, llc_list) {
- if (comp->llc_id == id) {
+ if (comp->llc_id == comp_id) {
layout->llot_cur_comp = comp;
return 0;
}
*
* \param[in] layout composite layout
* \param[in] pos the position to be moved, it can be:
- * LLAPI_LAYOUT_COMP_POS_FIRST: move to head
- * LLAPI_LAYOUT_COMP_POS_LAST: move to tail
- * LLAPI_LAYOUT_COMP_POS_NEXT: move to next
+ * LLAPI_LAYOUT_COMP_USE_FIRST: use first component
+ * LLAPI_LAYOUT_COMP_USE_LAST: use last component
+ * LLAPI_LAYOUT_COMP_USE_NEXT: use next component
*
* \retval =0 : moved successfully
- * \retval =1 : already at the tail when move to the next
+ * \retval =1 : at last component with NEXT
* \retval <0 if error occurs
*/
-int llapi_layout_comp_move(struct llapi_layout *layout, uint32_t pos)
+int llapi_layout_comp_use(struct llapi_layout *layout, uint32_t pos)
{
struct llapi_layout_comp *comp, *head, *tail;
tail = list_entry(layout->llot_comp_list.prev, typeof(*tail),
llc_list);
- if (pos == LLAPI_LAYOUT_COMP_POS_NEXT) {
+ if (pos == LLAPI_LAYOUT_COMP_USE_NEXT) {
if (comp == tail)
return 1;
layout->llot_cur_comp = list_entry(comp->llc_list.next,
typeof(*comp), llc_list);
- } else if (pos == LLAPI_LAYOUT_COMP_POS_FIRST) {
+ } else if (pos == LLAPI_LAYOUT_COMP_USE_FIRST) {
layout->llot_cur_comp = head;
- } else if (pos == LLAPI_LAYOUT_COMP_POS_LAST) {
+ } else if (pos == LLAPI_LAYOUT_COMP_USE_LAST) {
layout->llot_cur_comp = tail;
} else {
errno = EINVAL;