Details : RHEL mis-interpret setfacl "-X" param, so we won't test setfacl
with param "-X".
+Severity : normal
+Bugzilla : 12192
+Description: llapi_file_create() does not allow some changes
+Details : add llapi_file_open() that allows specifying the mode and
+ open flags, and also returns an open file handle.
+
--------------------------------------------------------------------------------
2007-08-27 Cluster File Systems, Inc. <info@clusterfs.com>
extern int llapi_file_create(const char *name, unsigned long stripe_size,
int stripe_offset, int stripe_count,
int stripe_pattern);
+extern int llapi_file_open(const char *name, int flags, int mode,
+ unsigned long stripe_size, int stripe_offset,
+ int stripe_count, int stripe_pattern);
extern int llapi_file_get_stripe(const char *path, struct lov_user_md *lum);
#define HAVE_LLAPI_FILE_LOOKUP
extern int llapi_file_lookup(int dirfd, const char *name);
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
+#include <lustre/liblustreapi.h>
#define T1 "write data before unlink\n"
#define T2 "write data after unlink\n"
"Usage: %s filename command-sequence\n"
" command-sequence items:\n"
" c close\n"
+" C[num] create with optional stripes\n"
" d mkdir\n"
" D open(O_DIRECTORY)\n"
" L link\n"
}
fd = -1;
break;
+ case 'C':
+ len = atoi(commands+1);
+ fd = llapi_file_open(fname, O_CREAT | O_WRONLY, 0644,
+ 0, 0, len, 0);
+ if (fd == -1) {
+ save_errno = errno;
+ perror("create stripe file");
+ exit(save_errno);
+ }
+ break;
case 'd':
if (mkdir(fname, 0755) == -1) {
save_errno = errno;
#include <lustre_lib.h>
#include <lustre/liblustreapi.h>
#include <obd_lov.h>
-#include <lustre/liblustreapi.h>
static void err_msg(char *fmt, ...)
{
fprintf(stderr, ": %s (%d)\n", strerror(tmp_errno), tmp_errno);
}
-int llapi_file_create(const char *name, unsigned long stripe_size,
- int stripe_offset, int stripe_count, int stripe_pattern)
+int llapi_file_open(const char *name, int flags, int mode,
+ unsigned long stripe_size, int stripe_offset,
+ int stripe_count, int stripe_pattern)
{
struct lov_user_md lum = { 0 };
int fd, rc = 0;
int isdir = 0;
int page_size;
- fd = open(name, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644);
- if (errno == EISDIR) {
+ fd = open(name, flags | O_LOV_DELAY_CREATE, mode);
+ if (fd < 0 && errno == EISDIR) {
fd = open(name, O_DIRECTORY | O_RDONLY);
isdir++;
}
if (fd < 0) {
rc = -errno;
- err_msg("unable to open '%s'",name);
+ err_msg("unable to open '%s'", name);
return rc;
}
(__u64)LL_IOC_LOV_SETSTRIPE, name, fd, errmsg);
}
out:
- if (close(fd) < 0) {
- if (rc == 0)
- rc = -errno;
- err_msg("error on close for '%s' (%d)", name, fd);
+ if (rc) {
+ close(fd);
+ fd = rc;
}
- return rc;
+
+ return fd;
+}
+
+int llapi_file_create(const char *name, unsigned long stripe_size,
+ int stripe_offset, int stripe_count, int stripe_pattern)
+{
+ int fd;
+
+ fd = llapi_file_open(name, O_CREAT | O_WRONLY, 0644, stripe_size,
+ stripe_offset, stripe_count, stripe_pattern);
+ if (fd < 0)
+ return fd;
+
+ close(fd);
+ return 0;
}
typedef int (semantic_func_t)(char *path, DIR *parent, DIR *d, void *data);