From: Stef B. <st...@gm...> - 2010-05-30 18:50:02
|
Well, Ive added code like: static int do_open(fuse_ino_t ino, struct fuse_file_info *fi) { struct xmpfs_entry_struct *entry = find_inode(ino)->alias; int fd; struct stat st; int flags = (fi->flags & O_ACCMODE) | O_NOFOLLOW; int res; if ( DEBUG > 0 ) syslog(LOG_DEBUG, "do_open"); if (xmpfs_options.o_direct) flags |= O_DIRECT; fd = open_ino(entry, flags); if (fd < 0) return fd; fi->fh = fd; fi->keep_cache = 0; fi->nonseekable=1; res=fstat(fd, &st); if ( res != -1 ) { if ( S_ISREG(st.st_mode) ); { // is seekable if ( DEBUG > 0 ) syslog(LOG_DEBUG, "open: a normal file"); fi->nonseekable = 0; fi->keep_cache = 1; } } return 0; } and static void xmpfs_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info *fi) { int res; void *buf; (void) ino; if ( DEBUG > 0 ) syslog(LOG_DEBUG, "read"); res = posix_memalign(&buf, pagesize, size); if (res != 0) { fuse_reply_err(req, res); return; } if ( fi->nonseekable == 1) { // non seekable -> use the default read command if ( DEBUG > 0 ) syslog(LOG_DEBUG, "read: normal read, without offset"); res = read(fi->fh, buf, size); } else { // seekable -> use the pread command using the offset if ( DEBUG > 0 ) syslog(LOG_DEBUG, "read: pread with offset"); res = pread(fi->fh, buf, size, off); } if (res == -1) fuse_reply_err(req, errno); else fuse_reply_buf(req, buf, res); free(buf); } this does not work either. Files in /proc are still seen as normal files (S_ISREG), and thus seekable. I've read some articles on the Internet, and it looks like files in /proc are only readable through fgets in stead of read or pread. Stef 2010/5/30 Stef Bon <st...@gm...>: > I've found that this value (fuse_file_info->nonseekable) is already > available (in 2.8). > > > 2010/5/30 Stef Bon <st...@gm...>: >> Well, >> >> I've found already this in the documentation on: >> >> http://fuse.sourceforge.net/doxygen/structfuse__file__info.html >> >> saying: >> >> unsigned int fuse_file_info::nonseekable >> >> Can be filled in by open, to indicate that the file is not seekable. >> Introduced in version 2.9 >> So this is probably what I need. >> Based on this value I can use pread (when seekable) or "normal" read when not. >> >> >> But 2.9 is still in development? >> >> Stef >> >> >> > |