diff options
-rw-r--r-- | api/src/glfs-resolve.c | 4 | ||||
-rw-r--r-- | tests/basic/ctime/ctime-glfs-init.c | 67 | ||||
-rw-r--r-- | tests/basic/ctime/ctime-glfs-init.t | 25 |
3 files changed, 94 insertions, 2 deletions
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 03be7c7eda7..d305c126cb6 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -241,9 +241,9 @@ glfs_resolve_root (struct glfs *fs, xlator_t *subvol, inode_t *inode, loc.inode = inode_ref (inode); - ret = inode_path (loc.inode, NULL, &path); + ret = inode_path (loc.inode, ".", &path); loc.path = path; - loc.name = ""; + loc.name = "."; /* Having a value in loc.name will help to bypass md-cache check for * nameless lookup. * TODO: Re-visit on nameless lookup and md-cache. diff --git a/tests/basic/ctime/ctime-glfs-init.c b/tests/basic/ctime/ctime-glfs-init.c new file mode 100644 index 00000000000..57a3dc7820e --- /dev/null +++ b/tests/basic/ctime/ctime-glfs-init.c @@ -0,0 +1,67 @@ +#include <fcntl.h> +#include <unistd.h> +#include <time.h> +#include <limits.h> +#include <string.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <glusterfs/api/glfs.h> +#include <glusterfs/api/glfs-handles.h> + +#define LOG_ERR(msg) do { \ + fprintf (stderr, "%s : Error (%s)\n", msg, strerror (errno)); \ + } while (0) + +int +main (int argc, char *argv[]) +{ + int ret = 0; + char *hostname = NULL; + char *volname = NULL; + char *logfile = NULL; + glfs_t *fs = NULL; + + if (argc != 4) { + fprintf (stderr, "Invalid argument\n"); + exit(1); + } + + hostname = argv[1]; + volname = argv[2]; + logfile = argv[3]; + + fs = glfs_new (volname); + if (!fs) { + LOG_ERR ("glfs_new failed"); + return -1; + } + + ret = glfs_set_volfile_server (fs, "tcp", hostname, 24007); + if (ret < 0) { + LOG_ERR ("glfs_set_volfile_server failed"); + goto err; + } + + ret = glfs_set_logging (fs, logfile, 7); + if (ret < 0) { + LOG_ERR ("glfs_set_logging failed"); + goto err; + } + + ret = glfs_init (fs); + if (ret < 0) { + LOG_ERR ("glfs_init failed"); + goto err; + } + + glfs_fini (fs); + fs = NULL; + return 0; +err: + glfs_fini (fs); + fs = NULL; + + return -1; +} diff --git a/tests/basic/ctime/ctime-glfs-init.t b/tests/basic/ctime/ctime-glfs-init.t new file mode 100644 index 00000000000..0ecd80c2680 --- /dev/null +++ b/tests/basic/ctime/ctime-glfs-init.t @@ -0,0 +1,25 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd + +TEST $CLI volume create $V0 replica 3 ${H0}:$B0/brick{1,2,3}; +TEST $CLI volume set $V0 performance.stat-prefetch off +TEST $CLI volume set $V0 ctime on +TEST $CLI volume set $V0 utime on +TEST $CLI volume start $V0; + +logdir=`gluster --print-logdir` + +TEST build_tester $(dirname $0)/ctime-glfs-init.c -lgfapi -lpthread + +TEST ./$(dirname $0)/ctime-glfs-init ${H0} $V0 $logdir/ctime-glfs-init.log + +cleanup_tester $(dirname $0)/ctime-glfs-init + +cleanup; + |