[Pvfs2-cvs] commit by robl in pvfs2-1/test/posix: getdents.c
openg-socket.c openg.c readwritex.c stat.c xio_test.c
CVS commit program
cvs at parl.clemson.edu
Mon Nov 27 15:21:20 EST 2006
Update of /projects/cvsroot/pvfs2-1/test/posix
In directory parlweb1:/tmp/cvs-serv21183/test/posix
Modified Files:
Tag: WALT3
getdents.c openg-socket.c openg.c readwritex.c stat.c
xio_test.c
Log Message:
from HEAD: use a more portable way of making system calls
Index: getdents.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/getdents.c,v
diff -u -w -p -u -r1.3.2.1 -r1.3.2.2
--- getdents.c 18 Sep 2006 15:07:29 -0000 1.3.2.1
+++ getdents.c 27 Nov 2006 20:21:20 -0000 1.3.2.2
@@ -256,6 +256,9 @@ static inline struct files* clone_filp(s
return new_filp;
}
+/* the _syscallXX apprroach is not portable. instead, we'll use syscall and
+ * sadly forego any type checking. For reference, here are the prototypes for
+ * the system calls
int newstatlite(const char *, struct kernel_stat_lite *);
static int newfstatlite(int, struct kernel_stat_lite *);
static int newlstatlite(const char *, struct kernel_stat_lite *);
@@ -267,17 +270,8 @@ static int getdents_plus_lite(unsigned i
struct dirent_plus_lite *dirent, unsigned int count);
static int getdents64_plus_lite(unsigned int fd, unsigned long lite_mask,
struct dirent64_plus_lite *dirent, unsigned int count);
+*/
-/* glibc does not seem to provide a getdents() routine, so we provide one */
-_syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count);
-_syscall3(int, getdents64, uint, fd, struct dirent64 *, dirp, uint, count);
-_syscall3(int, getdents_plus, uint, fd, struct dirent_plus *, dirp, uint, count);
-_syscall3(int, getdents64_plus, uint, fd, struct dirent64_plus *, dirp, uint, count);
-_syscall4(int, getdents_plus_lite, uint, fd, unsigned long, lite_mask, struct dirent_plus_lite *, dirp, unsigned int, count);
-_syscall4(int, getdents64_plus_lite, uint, fd, unsigned long, lite_mask, struct dirent64_plus_lite *, dirp, unsigned int, count);
-_syscall2(int, newstatlite, const char *, path, struct kernel_stat_lite *, buf);
-_syscall2(int, newfstatlite, int, filedes, struct kernel_stat_lite *, buf);
-_syscall2(int, newlstatlite, const char *, path, struct kernel_stat_lite *, buf);
/* free the struct files queued on the TREE list */
@@ -1036,7 +1030,7 @@ static int path_walk(struct files *root_
S_SLITE_CTIME |
S_SLITE_BLKSIZE |
S_SLITE_BLOCKS;
- ret = newlstatlite(root_filp->name, &statbuflite);
+ ret = syscall(__NR_newlstatlite, root_filp->name, &statbuflite);
is_dir = S_ISDIR(statbuflite.st_mode);
is_link = S_ISLNK(statbuflite.st_mode);
}
@@ -1055,7 +1049,7 @@ static int path_walk(struct files *root_
S_SLITE_CTIME |
S_SLITE_BLKSIZE |
S_SLITE_BLOCKS;
- ret = newlstatlite(root_filp->name, &statbuflite);
+ ret = syscall(__NR_newlstatlite, root_filp->name, &statbuflite);
is_dir = S_ISDIR(statbuflite.st_mode);
is_link = S_ISLNK(statbuflite.st_mode);
}
@@ -1077,7 +1071,7 @@ static int path_walk(struct files *root_
S_SLITE_CTIME |
S_SLITE_BLKSIZE |
S_SLITE_BLOCKS;
- ret = newfstatlite(dir_fd, &statbuflite);
+ ret = syscall(__NR_newfstatlite,dir_fd, &statbuflite);
is_dir = S_ISDIR(statbuflite.st_mode);
is_link = S_ISLNK(statbuflite.st_mode);
}
@@ -1097,7 +1091,7 @@ static int path_walk(struct files *root_
S_SLITE_CTIME |
S_SLITE_BLKSIZE |
S_SLITE_BLOCKS;
- ret = newfstatlite(dir_fd, &statbuflite);
+ ret = syscall(__NR_newfstatlite, dir_fd, &statbuflite);
is_dir = S_ISDIR(statbuflite.st_mode);
is_link = S_ISLNK(statbuflite.st_mode);
}
@@ -1154,7 +1148,8 @@ static int path_walk(struct files *root_
assert(p64);
}
ptr = (char *) p64 + dirent_total_bytes;
- dirent_output_bytes = getdents64(dir_fd, (struct dirent64 *) ptr,
+ dirent_output_bytes = syscall(__NR_getdents64, dir_fd,
+ (struct dirent64 *) ptr,
dirent_input_count * sizeof(struct dirent64));
if (dirent_output_bytes <= 0)
break;
@@ -1174,7 +1169,8 @@ static int path_walk(struct files *root_
assert(p);
}
ptr = (char *) p + dirent_total_bytes;
- dirent_output_bytes = getdents(dir_fd, (struct dirent *) ptr,
+ dirent_output_bytes = syscall(__NR_getdents, dir_fd,
+ (struct dirent *) ptr,
dirent_input_count * sizeof(struct dirent));
if (dirent_output_bytes <= 0)
break;
@@ -1264,8 +1260,10 @@ static int path_walk(struct files *root_
assert(p64_lite);
}
ptr = (char *) p64_lite + dirent_total_bytes;
- dirent_output_bytes = getdents64_plus_lite(dir_fd, lite_mask,
- (struct dirent64_plus_lite *) ptr, dirent_input_count * sizeof(struct dirent64_plus_lite));
+ dirent_output_bytes = syscall(__NR_getdents64_plus_lite,
+ dir_fd, lite_mask,
+ (struct dirent64_plus_lite *) ptr,
+ dirent_input_count * sizeof(struct dirent64_plus_lite));
if (dirent_output_bytes <= 0)
break;
total_rec_len = 0;
@@ -1285,7 +1283,9 @@ static int path_walk(struct files *root_
assert(p64);
}
ptr = (char *) p64 + dirent_total_bytes;
- dirent_output_bytes = getdents64_plus(dir_fd, (struct dirent64_plus *) ptr, dirent_input_count * sizeof(struct dirent64_plus));
+ dirent_output_bytes = syscall(__NR_getdents64_plus, dir_fd,
+ (struct dirent64_plus *) ptr,
+ dirent_input_count * sizeof(struct dirent64_plus));
if (dirent_output_bytes <= 0)
break;
total_rec_len = 0;
@@ -1308,8 +1308,10 @@ static int path_walk(struct files *root_
assert(p_lite);
}
ptr = (char *) p_lite + dirent_total_bytes;
- dirent_output_bytes = getdents_plus_lite(dir_fd, lite_mask,
- (struct dirent_plus_lite *) ptr, dirent_input_count * sizeof(struct dirent_plus_lite));
+ dirent_output_bytes = syscall(__NR_getdents_plus_lite,
+ dir_fd, lite_mask,
+ (struct dirent_plus_lite *) ptr,
+ dirent_input_count * sizeof(struct dirent_plus_lite));
if (dirent_output_bytes <= 0)
break;
total_rec_len = 0;
@@ -1329,8 +1331,9 @@ static int path_walk(struct files *root_
assert(p);
}
ptr = (char *) p + dirent_total_bytes;
- dirent_output_bytes = getdents_plus(dir_fd,
- (struct dirent_plus *) ptr, dirent_input_count * sizeof(struct dirent_plus));
+ dirent_output_bytes = syscall(__NR_getdents_plus, dir_fd,
+ (struct dirent_plus *) ptr,
+ dirent_input_count * sizeof(struct dirent_plus));
if (dirent_output_bytes <= 0)
break;
total_rec_len = 0;
Index: openg-socket.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/openg-socket.c,v
diff -u -w -p -u -r1.2.2.1 -r1.2.2.2
--- openg-socket.c 18 Sep 2006 15:07:29 -0000 1.2.2.1
+++ openg-socket.c 27 Nov 2006 20:21:20 -0000 1.2.2.2
@@ -35,10 +35,12 @@
#define __NR_openfh 274
#endif
+/* the _syscallXX apprroach is not portable. instead, we'll use syscall and
+ * sadly forego any type checking. For reference, here are the prototypes for
+ * the system calls
static long openfh(const void *, size_t);
static long openg(const char *, void *, size_t *, int, int);
-_syscall2(long, openfh, const void *, uhandle, size_t, handle_len);
-_syscall5(long, openg, const char *, pathname, void *, uhandle, size_t *, uhandle_len, int, flags, int, mode);
+*/
static inline double usec_diff(double *end, double *begin)
{
@@ -179,6 +181,15 @@ int main(int argc, char *argv[])
double begin, end;
enum muck_options_t muck_options = DONT_MUCK;
+#ifndef __NR_openg
+ printf("This kernel does not support the openg() extension\n");
+ exit(-1);
+#endif
+#ifndef __NR_openfh
+ printf("This kernel does not support the openfh() extension\n");
+ exit(-1);
+#endif
+
while ((c = getopt(argc, argv, opt)) != EOF) {
switch (c) {
case 's':
@@ -230,7 +241,7 @@ int main(int argc, char *argv[])
/* if I am the client, openg the file and send a packet */
else {
begin = Wtime();
- err = openg(fname, ptr, &len, O_RDONLY, 0775);
+ err = syscall(__NR_openg, fname, ptr, &len, O_RDONLY, 0775);
end = Wtime();
if (err < 0) {
perror("openg error:");
@@ -243,7 +254,7 @@ int main(int argc, char *argv[])
/* muck with buffer if need be */
muck_with_buffer(ptr, len, muck_options);
begin = Wtime();
- fd = openfh(ptr, len);
+ fd = syscall(__NR_openfh, ptr, len);
end = Wtime();
if (fd < 0) {
fprintf(stderr, "openfh failed: %s\n", strerror(errno));
Index: openg.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/openg.c,v
diff -u -w -p -u -r1.2.2.1 -r1.2.2.2
--- openg.c 18 Sep 2006 15:07:29 -0000 1.2.2.1
+++ openg.c 27 Nov 2006 20:21:20 -0000 1.2.2.2
@@ -33,10 +33,12 @@
#endif
#define MAX_LENGTH 128
+/* the _syscallXX apprroach is not portable. instead, we'll use syscall and
+ * sadly forego any type checking. For reference, here are the prototypes for
+ * the system calls
static long openfh(const void *, size_t);
static long openg(const char *, void *, size_t *, int, int);
-_syscall2(long, openfh, const void *, uhandle, size_t, handle_len);
-_syscall5(long, openg, const char *, pathname, void *, uhandle, size_t *, uhandle_len, int, flags, int, mode);
+*/
static inline double msec_diff(double *end, double *begin)
{
@@ -131,7 +133,7 @@ int main(int argc, char *argv[])
exit(1);
}
begin = Wtime();
- err = openg(fname, ptr, &len, O_RDONLY, 0775);
+ err = syscall(__NR_openg, fname, ptr, &len, O_RDONLY, 0775);
if (err < 0) {
perror("openg(2) error:");
exit(1);
@@ -141,7 +143,7 @@ int main(int argc, char *argv[])
fname, (unsigned long) len, msec_diff(&end, &begin));
muck_with_buffer(ptr, len, muck_options);
begin = Wtime();
- fd = openfh(ptr, len);
+ fd = syscall(__NR_openfh, ptr, len);
if (fd < 0) {
fprintf(stderr, "openfh failed: %s\n", strerror(errno));
free(ptr);
Index: readwritex.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/readwritex.c,v
diff -u -w -p -u -r1.2.2.1 -r1.2.2.2
--- readwritex.c 18 Sep 2006 15:07:29 -0000 1.2.2.1
+++ readwritex.c 27 Nov 2006 20:21:20 -0000 1.2.2.2
@@ -31,10 +31,12 @@ struct xtvec {
size_t xtv_len;
};
+/* the _syscallXX apprroach is not portable. instead, we'll use syscall and
+ * sadly forego any type checking. For reference, here are the prototypes for
+ * the system calls
static ssize_t readx(unsigned long, const struct iovec *, unsigned long, const struct xtvec *, unsigned long);
static ssize_t writex(unsigned long, const struct iovec *, unsigned long, const struct xtvec *, unsigned long);
-_syscall5(ssize_t, readx, unsigned long, fd, const struct iovec *, iov, unsigned long, iovlen, const struct xtvec *, xtv, unsigned long, xtvlen);
-_syscall5(ssize_t, writex, unsigned long, fd, const struct iovec *, iov, unsigned long, iovlen, const struct xtvec *, xtv, unsigned long, xtvlen);
+*/
#ifndef Ld
#define Ld(x) (x)
@@ -230,7 +232,8 @@ int main(int argc, char **argv)
}
time1 = Wtime();
/* write out the data */
- ret = writex(fh, wriov, frame.cf_valid_count, xtv, frame.cf_valid_count);
+ ret = syscall(__NR_writex, fh, wriov, frame.cf_valid_count, xtv,
+ frame.cf_valid_count);
time2 = Wtime();
if (ret < 0)
{
@@ -300,7 +303,8 @@ int main(int argc, char **argv)
fh = ret;
/* now read it back from the file and make sure we have the correct data */
time1 = Wtime();
- ret = readx(fh, rdiov, frame.cf_valid_count, xtv, frame.cf_valid_count);
+ ret = syscall(__NR_readx, fh, rdiov, frame.cf_valid_count, xtv,
+ frame.cf_valid_count);
time2 = Wtime();
if(ret < 0)
{
Index: stat.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/stat.c,v
diff -u -w -p -u -r1.2.2.1 -r1.2.2.2
--- stat.c 18 Sep 2006 15:07:29 -0000 1.2.2.1
+++ stat.c 27 Nov 2006 20:21:20 -0000 1.2.2.2
@@ -444,15 +444,14 @@ static void print_entry_kernel_stat_lite
printf("%s\n",buf);
}
+/* the _syscallXX apprroach is not portable. instead, we'll use syscall and
+ * sadly forego any type checking. For reference, here are the prototypes for
+ * the system calls
int newstatlite(const char *, struct kernel_stat_lite *);
static int newfstatlite(int, struct kernel_stat_lite *);
static int newlstatlite(const char *, struct kernel_stat_lite *);
static int getdents(uint, struct dirent *, uint);
-
-_syscall2(int, newstatlite, const char *, path, struct kernel_stat_lite *, buf);
-_syscall2(int, newfstatlite, int, filedes, struct kernel_stat_lite *, buf);
-_syscall2(int, newlstatlite, const char *, path, struct kernel_stat_lite *, buf);
-_syscall3(int, getdents, uint, fd, struct dirent *, dirp, uint, count);
+*/
/*
* Notes: We don't follow symbolic links, and we ignore any special
@@ -490,7 +489,8 @@ static int path_walk(struct files *root_
S_SLITE_CTIME |
S_SLITE_BLKSIZE |
S_SLITE_BLOCKS;
- ret = newlstatlite(root_filp->name, &statbuflite);
+ ret = syscall(__NR_newlstatlite, root_filp->name,
+ &statbuflite);
is_dir = S_ISDIR(statbuflite.st_mode);
is_link = S_ISLNK(statbuflite.st_mode);
}
@@ -510,7 +510,7 @@ static int path_walk(struct files *root_
S_SLITE_CTIME |
S_SLITE_BLKSIZE |
S_SLITE_BLOCKS;
- ret = newfstatlite(dir_fd, &statbuflite);
+ ret = syscall(__NR_newfstatlite, dir_fd, &statbuflite);
is_dir = S_ISDIR(statbuflite.st_mode);
is_link = S_ISLNK(statbuflite.st_mode);
}
@@ -555,7 +555,9 @@ static int path_walk(struct files *root_
assert(p);
}
ptr = (char *) p + dirent_total_bytes;
- dirent_output_bytes = getdents(dir_fd, (struct dirent *) ptr,
+ dirent_output_bytes = syscall(__NR_getdents,
+ dir_fd,
+ (struct dirent *) ptr,
dirent_input_count * sizeof(struct dirent));
if (dirent_output_bytes <= 0)
break;
Index: xio_test.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/test/posix/xio_test.c,v
diff -u -w -p -u -r1.2.2.1 -r1.2.2.2
--- xio_test.c 18 Sep 2006 15:07:29 -0000 1.2.2.1
+++ xio_test.c 27 Nov 2006 20:21:20 -0000 1.2.2.2
@@ -34,15 +34,17 @@ struct xtvec {
size_t xtv_len;
};
+
+/* the _syscallXX apprroach is not portable. instead, we'll use syscall and
+ * sadly forego any type checking. For reference, here are the prototypes for
+ * the system calls
static ssize_t readx(unsigned long fd,
const struct iovec * iov, unsigned long iovlen,
const struct xtvec * xtv, unsigned long xtvlen);
static ssize_t writex(unsigned long fd,
const struct iovec * iov, unsigned long iovlen,
const struct xtvec * xtv, unsigned long xtvlen);
-
-_syscall5(ssize_t, readx, unsigned long, fd, const struct iovec *, iov, unsigned long, iovlen, const struct xtvec *, xtv, unsigned long, xtvlen);
-_syscall5(ssize_t, writex, unsigned long, fd, const struct iovec *, iov, unsigned long, iovlen, const struct xtvec *, xtv, unsigned long, xtvlen);
+*/
#ifndef min
#define min(a, b) (a) < (b) ? (a) : (b)
@@ -101,7 +103,7 @@ static ssize_t do_writex(struct iovec *i
double time1, time2;
fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0700);
time1 = Wtime();
- ret = writex(fd, iov, ivlen, xtv, xtvlen);
+ ret = syscall(__NR_writex, fd, iov, ivlen, xtv, xtvlen);
time2 = Wtime();
if (ret < 0)
{
@@ -120,7 +122,7 @@ static ssize_t do_readx(struct iovec *io
double time1, time2;
fd = open(fname, O_RDONLY);
time1 = Wtime();
- ret = readx(fd, iov, ivlen, xtv, xtvlen);
+ ret = syscall(__NR_readx, fd, iov, ivlen, xtv, xtvlen);
time2 = Wtime();
if (ret < 0)
{
More information about the Pvfs2-cvs
mailing list