int __fxstat64(int ver, int fd, struct stat64 *buf) { if (nfs_fd_list[fd].is_nfs == 1) { int ret; struct stat64 st64; LD_NFS_DPRINTF(9, "__fxstat64(%d)", fd); if ((ret = nfs_fstat(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh, (void *)&st64)) < 0) { errno = -ret; return -1; } buf->st_dev = st64.st_dev; buf->st_ino = st64.st_ino; buf->st_mode = st64.st_mode; buf->st_nlink = st64.st_nlink; buf->st_uid = st64.st_uid; buf->st_gid = st64.st_gid; buf->st_rdev = st64.st_rdev; buf->st_size = st64.st_size; buf->st_blksize = st64.st_blksize; buf->st_blocks = st64.st_blocks; buf->st_atime = st64.st_atime; buf->st_mtime = st64.st_mtime; buf->st_ctime = st64.st_ctime; LD_NFS_DPRINTF(9, "__fxstat64(%d) success", fd); return ret; } return real_fxstat64(ver, fd, buf); }
static void workspace_nfs_fgetattr(fuse_req_t req, struct workspace_fh_struct *fh) { struct resource_struct *resource=fh->object->resource; struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data; struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data; struct nfsfh *nfsfh=(struct nfsfh *) fh->handle.data; int result=0; struct stat st; logoutput("workspace_nfs_fgetattr"); memset(&st, 0, sizeof(struct stat)); pthread_mutex_lock(&nfs_export->mutex); result=nfs_fstat(nfs_ctx, nfsfh, &st); pthread_mutex_unlock(&nfs_export->mutex); if (result==0) { fuse_reply_attr(req, &st, fs_options.attr_timeout); } else { fuse_reply_err(req, -result); } }
static int fstat_file(struct file_context *fc, struct stat *st) { if (fc->is_nfs == 0) { return fstat(fc->fd, st); } else { return nfs_fstat(fc->nfs, fc->nfsfh, st); } }
static void workspace_nfs_create(fuse_req_t req, struct inode_struct *pinode, struct name_struct *xname, struct workspace_fh_struct *fh, mode_t mode) { struct resource_struct *resource=fh->object->resource; struct net_nfs_export_struct *nfs_export=(struct net_nfs_export_struct *) resource->data; struct nfs_context *nfs_ctx=(struct nfs_context *) nfs_export->data; char *path=fh->pathinfo.path + fh->relpath; struct entry_struct *entry=NULL, *parent=pinode->alias; struct inode_struct *inode; struct nfsfh *nfsfh=NULL; logoutput("workspace_nfs_create, path %s", path); entry=create_entry(parent, xname); inode=create_inode(); if (entry && inode) { int result=0; inode->alias=entry; entry->inode=inode; pthread_mutex_lock(&nfs_export->mutex); result=nfs_creat(nfs_ctx, path, mode, &nfsfh); pthread_mutex_unlock(&nfs_export->mutex); if (result==0) { struct fuse_entry_param e; unsigned int error=0; struct stat st; memset(&st, 0, sizeof(struct stat)); add_inode_hashtable(inode, increase_inodes_workspace, (void *) fh->object->workspace_mount); insert_entry(entry, &error, 0); adjust_pathmax(fh->pathinfo.len); nfs_fstat(nfs_ctx, nfsfh, &st); inode->nlookup=1; inode->mode=st.st_mode; inode->nlink=st.st_nlink; inode->uid=st.st_uid; inode->gid=st.st_gid; inode->rdev=st.st_rdev; inode->size=st.st_size; inode->mtim.tv_sec=st.st_mtim.tv_sec; inode->mtim.tv_nsec=st.st_mtim.tv_nsec; inode->ctim.tv_sec=st.st_ctim.tv_sec; inode->ctim.tv_nsec=st.st_ctim.tv_nsec; e.ino = inode->ino; e.generation = 1; e.attr_timeout = fs_options.attr_timeout; e.entry_timeout = fs_options.entry_timeout; e.attr.st_ino = e.ino; e.attr.st_mode = st.st_mode; e.attr.st_nlink = st.st_nlink; e.attr.st_uid = st.st_uid; e.attr.st_gid = st.st_gid; e.attr.st_rdev = st.st_rdev; e.attr.st_atim.tv_sec = st.st_atim.tv_sec; e.attr.st_atim.tv_nsec = st.st_atim.tv_nsec; e.attr.st_mtim.tv_sec = st.st_mtim.tv_sec; e.attr.st_mtim.tv_nsec = st.st_mtim.tv_nsec; e.attr.st_ctim.tv_sec = st.st_ctim.tv_sec; e.attr.st_ctim.tv_nsec = st.st_ctim.tv_nsec; e.attr.st_blksize=_DEFAULT_BLOCKSIZE; if (inode->size % e.attr.st_blksize == 0) { e.attr.st_blocks=inode->size / e.attr.st_blksize; } else { e.attr.st_blocks=1 + inode->size / e.attr.st_blksize; } fh->handle.data=(void *) nfsfh; fuse_reply_create(req, &e, fh->fi); } else { /* error nfs create */ destroy_entry(entry); free(inode); fuse_reply_err(req, abs(result)); } } else { /* not enough memory to allocate entry and/or inode */ if (entry) { destroy_entry(entry); entry=NULL; } if (inode) { free(inode); inode=NULL; } fuse_reply_err(req, ENOMEM); } free_path_pathinfo(&fh->pathinfo); }