Comments (5)
From the following lines:
char *outstr = NULL;
ssize_t bytes_read = 0;
plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read); // This should be plfs_read()
I think that you forget to allocate storage space for the 'outstr', so it's a NULL pointer and which is not correct for plfs_read(). And you use plfs_write instead of plfs_read mistakenly. You can try code like this to allocate the output buffer at stack:
char outstr[16];
ssize_t bytes_read = 0;
printf("Executing 'plfs_read(0x%0x, \"%s\", %d, %d, %d, %d)'\n", fd, outstr, size, offset, pid, bytes_read);
plfs_error = plfs_read(fd, outstr, size, offset, pid, &bytes_read);
from plfs-core.
Thanks, Zhang. That was pretty dense of me. Unfortunately, it still
doesn't seem to be quite correct for some reason. After making the
change you suggested, even though plfs_error is 0 and bytes read is 5,
outstr still has whatever garbage was in it after the declaration. If I
initialize it, the initialized value is returned. What's very
interesting, is that in a different context (from ldplfs) if I preload
the return buffer with "dummy" and pass it to plfs_read to read 3
characters, it returns "xxxmy" which indicates to me that plfs is
returning only the z's that it uses to initialize it's buffer. Anyway,
here is the altered code and output:
#include <stdio.h>
#include <plfs.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#define SUCCESS 0
int main(int argc, char **argv) {
const char *cpath = "/tmp/local_plfs/test.plfs.fil";
//mode_t fmode = "w+";
mode_t fmode = 0666;
Plfs_fd *fd = NULL;
//printf("fd = 0x%0x\n", fd);
//printf("cpath = %s\n", cpath);
//printf("O_RDWR = %d\n", O_RDWR);
//printf("getpid() = %d\n", getpid());
//printf("fmode = %d\n", fmode);
printf("Executing 'plfs_open(0x%0x, \"%s\", %d, %d, %d, NULL)'\n",
fd, cpath, O_RDWR, getpid(), fmode);
plfs_error_t plfs_error = plfs_open(&fd, cpath, O_RDWR, getpid(),
fmode, NULL);
printf("plfs_error = %d\n", plfs_error);
printf("fd = 0x%0x\n\n", fd);
const char *str = "Hello";
const int size = strlen(str);
const int offset = 0;
const pid_t pid = getpid();
ssize_t written = 0;
printf("Executing 'plfs_write(0x%0x, %0x0x, %d, %d, %d, %d)'\n", fd,
str, size, offset, pid, written);
plfs_error = plfs_write(fd, str, size, offset, pid, &written);
printf("plfs_error = %d\n", plfs_error);
printf("written = %d\n\n", written);
char outstr[16];
//outstr[0] = '\0';
//strcpy(outstr, "abcdefghijklm");
ssize_t bytes_read = 0;
printf("outstr = %s\n", outstr);
printf("Executing 'plfs_read(0x%0x, 0x%0x, %d, %d, %d, %d)'\n", fd,
outstr, size, offset, pid, bytes_read);
plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);
printf("plfs_error = %d\n", plfs_error);
printf("bytes_read = %d\n", bytes_read);
printf("outstr = %s\n\n ", outstr);
Plfs_close_opt opts;
int x;
printf("Executing 'plfs_close(0x%0x, %d, %d, %d, %d, NULL)'\n", fd,
pid, getuid(), O_RDWR, NULL, x);
plfs_error = plfs_close(fd, pid, getuid(), O_RDWR, NULL, &x);
printf("plfs_error = %d\n", plfs_error);
return SUCCESS;
}
Executing 'plfs_open(0x0, "/tmp/local_plfs/test.plfs.fil", 2, 54673,
438, NULL)'
plfs_error = 0
fd = 0x24c88e0
Executing 'plfs_write(0x24c88e0, 400c5c0x, 5, 0, 54673, 0)'
plfs_error = 0
written = 5
outstr = N�8YD+
Executing 'plfs_read(0x24c88e0, 0x4a2de670, 5, 0, 54673, 0)'
plfs_error = 0
bytes_read = 5
outstr = N�8YD+
Executing 'plfs_close(0x24c88e0, 54673, 55096, 2, 0, NULL)'
plfs_error = 0
On Mon, 2015-03-16 at 18:41 -0700, Zhang Jingwang wrote:
From the following lines:
char *outstr = NULL;
ssize_t bytes_read = 0;plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);
I think that you forget to allocate storage space for the 'outstr', so
it's a NULL pointer and which is not correct for plfs_read(). You can
try code like this to allocate the output buffer at stack:char outstr[16];
ssize_t bytes_read = 0;printf("Executing 'plfs_read(0x%0x, "%s", %d, %d, %d, %d)'\n", fd, outstr, size, offset, pid, bytes_read);
plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);—
Reply to this email directly or view it on GitHub.
from plfs-core.
I will consult with someone today that may be able to talk to the developer of small file mode.
Alfred
From: krigbaum <[email protected]mailto:[email protected]>
Reply-To: plfs/plfs-core <[email protected]mailto:[email protected]>
Date: Tue, 17 Mar 2015 05:40:56 -0700
To: plfs/plfs-core <[email protected]mailto:[email protected]>
Subject: Re: [plfs-core] plfs_read not working with small files (#360)
Thanks, Zhang. That was pretty dense of me. Unfortunately, it still
doesn't seem to be quite correct for some reason. After making the
change you suggested, even though plfs_error is 0 and bytes read is 5,
outstr still has whatever garbage was in it after the declaration. If I
initialize it, the initialized value is returned. What's very
interesting, is that in a different context (from ldplfs) if I preload
the return buffer with "dummy" and pass it to plfs_read to read 3
characters, it returns "xxxmy" which indicates to me that plfs is
returning only the z's that it uses to initialize it's buffer. Anyway,
here is the altered code and output:
#include <stdio.h>
#include <plfs.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#define SUCCESS 0
int main(int argc, char **argv) {
const char *cpath = "/tmp/local_plfs/test.plfs.fil";
//mode_t fmode = "w+";
mode_t fmode = 0666;
Plfs_fd *fd = NULL;
//printf("fd = 0x%0x\n", fd);
//printf("cpath = %s\n", cpath);
//printf("O_RDWR = %d\n", O_RDWR);
//printf("getpid() = %d\n", getpid());
//printf("fmode = %d\n", fmode);
printf("Executing 'plfs_open(0x%0x, "%s", %d, %d, %d, NULL)'\n",
fd, cpath, O_RDWR, getpid(), fmode);
plfs_error_t plfs_error = plfs_open(&fd, cpath, O_RDWR, getpid(),
fmode, NULL);
printf("plfs_error = %d\n", plfs_error);
printf("fd = 0x%0x\n\n", fd);
const char *str = "Hello";
const int size = strlen(str);
const int offset = 0;
const pid_t pid = getpid();
ssize_t written = 0;
printf("Executing 'plfs_write(0x%0x, %0x0x, %d, %d, %d, %d)'\n", fd,
str, size, offset, pid, written);
plfs_error = plfs_write(fd, str, size, offset, pid, &written);
printf("plfs_error = %d\n", plfs_error);
printf("written = %d\n\n", written);
char outstr[16];
//outstr[0] = '\0';
//strcpy(outstr, "abcdefghijklm");
ssize_t bytes_read = 0;
printf("outstr = %s\n", outstr);
printf("Executing 'plfs_read(0x%0x, 0x%0x, %d, %d, %d, %d)'\n", fd,
outstr, size, offset, pid, bytes_read);
plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);
printf("plfs_error = %d\n", plfs_error);
printf("bytes_read = %d\n", bytes_read);
printf("outstr = %s\n\n ", outstr);
Plfs_close_opt opts;
int x;
printf("Executing 'plfs_close(0x%0x, %d, %d, %d, %d, NULL)'\n", fd,
pid, getuid(), O_RDWR, NULL, x);
plfs_error = plfs_close(fd, pid, getuid(), O_RDWR, NULL, &x);
printf("plfs_error = %d\n", plfs_error);
return SUCCESS;
}
Executing 'plfs_open(0x0, "/tmp/local_plfs/test.plfs.fil", 2, 54673,
438, NULL)'
plfs_error = 0
fd = 0x24c88e0
Executing 'plfs_write(0x24c88e0, 400c5c0x, 5, 0, 54673, 0)'
plfs_error = 0
written = 5
outstr = N�8YD+
Executing 'plfs_read(0x24c88e0, 0x4a2de670, 5, 0, 54673, 0)'
plfs_error = 0
bytes_read = 5
outstr = N�8YD+
Executing 'plfs_close(0x24c88e0, 54673, 55096, 2, 0, NULL)'
plfs_error = 0
On Mon, 2015-03-16 at 18:41 -0700, Zhang Jingwang wrote:
From the following lines:
char *outstr = NULL;
ssize_t bytes_read = 0;plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);
I think that you forget to allocate storage space for the 'outstr', so
it's a NULL pointer and which is not correct for plfs_read(). You can
try code like this to allocate the output buffer at stack:char outstr[16];
ssize_t bytes_read = 0;printf("Executing 'plfs_read(0x%0x, "%s", %d, %d, %d, %d)'\n", fd, outstr, size, offset, pid, bytes_read);
plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);—
Reply to this email directly or view it on GitHub.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/360#issuecomment-82323758.
from plfs-core.
hi-
you are printing "Executing plfs_read" but you appear to
actually be calling plfs_write()?
chuck
On Tue, Mar 17, 2015 at 05:40:57AM -0700, krigbaum wrote:
printf("outstr = %s\n", outstr); printf("Executing 'plfs_read(0x%0x, 0x%0x, %d, %d, %d, %d)'\n", fd,
outstr, size, offset, pid, bytes_read);
plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);
^^^^^^^^^^^
printf("plfs_error = %d\n", plfs_error);
printf("bytes_read = %d\n", bytes_read);
printf("outstr = %s\n\n ", outstr);
from plfs-core.
Thanks. Excuse me while I go find a rock to hide under.
On Tue, 2015-03-17 at 06:37 -0700, chuckcranor wrote:
hi-
you are printing "Executing plfs_read" but you appear to
actually be calling plfs_write()?chuck
On Tue, Mar 17, 2015 at 05:40:57AM -0700, krigbaum wrote:
printf("outstr = %s\n", outstr);
printf("Executing 'plfs_read(0x%0x, 0x%0x, %d, %d, %d, %d)'\n", fd,
outstr, size, offset, pid, bytes_read);
plfs_error = plfs_write(fd, outstr, size, offset, pid, &bytes_read);
^^^^^^^^^^^
printf("plfs_error = %d\n", plfs_error);
printf("bytes_read = %d\n", bytes_read);
printf("outstr = %s\n\n ", outstr);—
Reply to this email directly or view it on GitHub.
from plfs-core.
Related Issues (20)
- PLFSRC indication of index type for mount point HOT 1
- Move reference counting out of libplfs and into FUSE
- MPI Abort during Read Phase of fs_test HOT 6
- Production-harden code
- Patching issue with openmpi-1.7.4
- Error in PLFS N-N files' metadata HOT 1
- Race conditions in Writefile
- Index files aren't sync'd when user calls plfs_sync HOT 2
- plfs_query not working for physical to logical? HOT 3
- plfsrc parsing error HOT 1
- renaming an open file: data structure updates incomplete
- renaming an open file: locking data structures and concurrency
- multithreaded mkdir can fail with multiple backends
- plfs_writex
- VERSION and VERSION.layout files deprecated
- flatfile rename issue HOT 3
- plfs shouldn't have to patch romio HOT 1
- is this project dead? HOT 2
- traces for reference not on lanl.gov anymore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plfs-core.