static loff_t cifs_llseek(struct file *file, loff_t offset, int whence) { /* * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate * the cached file length */ if (whence != SEEK_SET && whence != SEEK_CUR) { int rc; struct inode *inode = file_inode(file); /* * We need to be sure that all dirty pages are written and the * server has the newest file length. */ if (!CIFS_I(inode)->clientCanCacheRead && inode->i_mapping && inode->i_mapping->nrpages != 0) { rc = filemap_fdatawait(inode->i_mapping); if (rc) { mapping_set_error(inode->i_mapping, rc); return rc; } } /* * Some applications poll for the file length in this strange * way so we must seek to end on non-oplocked files by * setting the revalidate time to zero. */ CIFS_I(inode)->time = 0; rc = cifs_revalidate_file_attr(file); if (rc < 0) return (loff_t)rc; } return generic_file_llseek(file, offset, whence); }
int v9fs_file_open(struct inode *inode, struct file *file) { int err; struct v9fs_inode *v9inode; struct v9fs_session_info *v9ses; struct p9_fid *fid; int omode; p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file); v9inode = V9FS_I(inode); v9ses = v9fs_inode2v9ses(inode); if (v9fs_proto_dotl(v9ses)) omode = v9fs_open_to_dotl_flags(file->f_flags); else omode = v9fs_uflags2omode(file->f_flags, v9fs_proto_dotu(v9ses)); fid = file->private_data; if (!fid) { fid = v9fs_fid_clone(file->f_path.dentry); if (IS_ERR(fid)) return PTR_ERR(fid); err = p9_client_open(fid, omode); if (err < 0) { p9_client_clunk(fid); return err; } if ((file->f_flags & O_APPEND) && (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses))) generic_file_llseek(file, 0, SEEK_END); } file->private_data = fid; mutex_lock(&v9inode->v_mutex); if (v9ses->cache && !v9inode->writeback_fid && ((file->f_flags & O_ACCMODE) != O_RDONLY)) { /* * clone a fid and add it to writeback_fid * we do it during open time instead of * page dirty time via write_begin/page_mkwrite * because we want write after unlink usecase * to work. */ fid = v9fs_writeback_fid(file->f_path.dentry); if (IS_ERR(fid)) { err = PTR_ERR(fid); mutex_unlock(&v9inode->v_mutex); goto out_error; } v9inode->writeback_fid = (void *) fid; } mutex_unlock(&v9inode->v_mutex); if (v9ses->cache) v9fs_cache_inode_set_cookie(inode, file); return 0; out_error: p9_client_clunk(file->private_data); file->private_data = NULL; return err; }
loff_t testfs_llseek(struct file *file, loff_t offset, int whence) { int ret = 0; ret = generic_file_llseek(file, offset, whence); printk(KERN_INFO "testfs: testfs_llseek called...\n"); return ret; }
static loff_t sysfs_dir_llseek(struct file *file, loff_t offset, int whence) { struct inode *inode = file_inode(file); loff_t ret; mutex_lock(&inode->i_mutex); ret = generic_file_llseek(file, offset, whence); mutex_unlock(&inode->i_mutex); return ret; }
static loff_t kernfs_dir_fop_llseek(struct file *file, loff_t offset, int whence) { struct inode *inode = file_inode(file); loff_t ret; inode_lock(inode); ret = generic_file_llseek(file, offset, whence); inode_unlock(inode); return ret; }
static loff_t gfs2_llseek(struct file *file, loff_t offset, int whence) { struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); struct gfs2_holder i_gh; loff_t error; switch (whence) { case SEEK_END: error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); if (!error) { error = generic_file_llseek(file, offset, whence); gfs2_glock_dq_uninit(&i_gh); } break; case SEEK_DATA: error = gfs2_seek_data(file, offset); break; case SEEK_HOLE: error = gfs2_seek_hole(file, offset); break; case SEEK_CUR: case SEEK_SET: /* * These don't reference inode->i_size and don't depend on the * block mapping, so we don't need the glock. */ error = generic_file_llseek(file, offset, whence); break; default: error = -EINVAL; } return error; }
/** * ecryptfs_llseek * @file: File we are seeking in * @offset: The offset to seek to * @origin: 2 - offset from i_size; 1 - offset from f_pos * * Returns the position we have seeked to, or negative on error */ static loff_t ecryptfs_llseek(struct file *file, loff_t offset, int origin) { loff_t rv; loff_t new_end_pos; int rc; int expanding_file = 0; struct inode *inode = file->f_mapping->host; /* If our offset is past the end of our file, we're going to * need to grow it so we have a valid length of 0's */ new_end_pos = offset; switch (origin) { case 2: new_end_pos += i_size_read(inode); expanding_file = 1; break; case 1: new_end_pos += file->f_pos; if (new_end_pos > i_size_read(inode)) { ecryptfs_printk(KERN_DEBUG, "new_end_pos(=[0x%.16x]) " "> i_size_read(inode)(=[0x%.16x])\n", new_end_pos, i_size_read(inode)); expanding_file = 1; } break; default: if (new_end_pos > i_size_read(inode)) { ecryptfs_printk(KERN_DEBUG, "new_end_pos(=[0x%.16x]) " "> i_size_read(inode)(=[0x%.16x])\n", new_end_pos, i_size_read(inode)); expanding_file = 1; } } ecryptfs_printk(KERN_DEBUG, "new_end_pos = [0x%.16x]\n", new_end_pos); if (expanding_file) { rc = ecryptfs_truncate(file->f_path.dentry, new_end_pos); if (rc) { rv = rc; ecryptfs_printk(KERN_ERR, "Error on attempt to " "truncate to (higher) offset [0x%.16x];" " rc = [%d]\n", new_end_pos, rc); goto out; } } rv = generic_file_llseek(file, offset, origin); out: return rv; }
STATIC loff_t xfs_file_llseek( struct file *file, loff_t offset, int whence) { switch (whence) { case SEEK_END: case SEEK_CUR: case SEEK_SET: return generic_file_llseek(file, offset, whence); case SEEK_HOLE: case SEEK_DATA: return xfs_seek_hole_data(file, offset, whence); default: return -EINVAL; } }
int v9fs_file_open(struct inode *inode, struct file *file) { int err; struct v9fs_session_info *v9ses; struct p9_fid *fid; int omode; P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p \n", inode, file); v9ses = v9fs_inode2v9ses(inode); omode = v9fs_uflags2omode(file->f_flags, v9fs_proto_dotu(v9ses)); fid = file->private_data; if (!fid) { fid = v9fs_fid_clone(file->f_path.dentry); if (IS_ERR(fid)) return PTR_ERR(fid); err = p9_client_open(fid, omode); if (err < 0) { p9_client_clunk(fid); return err; } if (omode & P9_OTRUNC) { i_size_write(inode, 0); inode->i_blocks = 0; } if ((file->f_flags & O_APPEND) && (!v9fs_proto_dotu(v9ses))) generic_file_llseek(file, 0, SEEK_END); } file->private_data = fid; if ((fid->qid.version) && (v9ses->cache)) { P9_DPRINTK(P9_DEBUG_VFS, "cached"); /* enable cached file options */ if(file->f_op == &v9fs_file_operations) file->f_op = &v9fs_cached_file_operations; #ifdef CONFIG_9P_FSCACHE v9fs_cache_inode_set_cookie(inode, file); #endif } return 0; }
loff_t nfs_file_llseek(struct file *filp, loff_t offset, int whence) { dprintk("NFS: llseek file(%pD2, %lld, %d)\n", filp, offset, whence); /* * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate * the cached file length */ if (whence != SEEK_SET && whence != SEEK_CUR) { struct inode *inode = filp->f_mapping->host; int retval = nfs_revalidate_file_size(inode, filp); if (retval < 0) return (loff_t)retval; } return generic_file_llseek(filp, offset, whence); }
loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) { dprintk("NFS: llseek file(%s/%s, %lld, %d)\n", filp->f_path.dentry->d_parent->d_name.name, filp->f_path.dentry->d_name.name, offset, origin); /* * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate * the cached file length */ if (origin != SEEK_SET && origin != SEEK_CUR) { struct inode *inode = filp->f_mapping->host; int retval = nfs_revalidate_file_size(inode, filp); if (retval < 0) return (loff_t)retval; } return generic_file_llseek(filp, offset, origin); }
static loff_t zpl_llseek(struct file *filp, loff_t offset, int whence) { #if defined(SEEK_HOLE) && defined(SEEK_DATA) if (whence == SEEK_DATA || whence == SEEK_HOLE) { struct inode *ip = filp->f_mapping->host; loff_t maxbytes = ip->i_sb->s_maxbytes; loff_t error; spl_inode_lock(ip); error = -zfs_holey(ip, whence, &offset); if (error == 0) error = lseek_execute(filp, ip, offset, maxbytes); spl_inode_unlock(ip); return (error); } #endif /* SEEK_HOLE && SEEK_DATA */ return (generic_file_llseek(filp, offset, whence)); }
static loff_t unionfs_llseek(struct file *file, loff_t offset, int origin) { loff_t err; struct file *hidden_file = NULL; print_entry_location(); fist_dprint(6, "unionfs_llseek: file=%p, offset=0x%llx, origin=%d\n", file, offset, origin); if ((err = unionfs_file_revalidate(file, 0))) goto out; PASSERT(ftopd(file)); hidden_file = ftohf(file); PASSERT(hidden_file); /* always set hidden position to this one */ hidden_file->f_pos = file->f_pos; memcpy(&(hidden_file->f_ra), &(file->f_ra), sizeof(struct file_ra_state)); if (hidden_file->f_op && hidden_file->f_op->llseek) err = hidden_file->f_op->llseek(hidden_file, offset, origin); else err = generic_file_llseek(hidden_file, offset, origin); if (err < 0) goto out; if (err != file->f_pos) { file->f_pos = err; // ION maybe this? // file->f_pos = hidden_file->f_pos; file->f_version++; } out: print_exit_status((int)err); return err; }
loff_t pmfs_llseek(struct file *file, loff_t offset, int origin) { struct inode *inode = file->f_path.dentry->d_inode; int retval; if (origin != SEEK_DATA && origin != SEEK_HOLE) return generic_file_llseek(file, offset, origin); mutex_lock(&inode->i_mutex); switch (origin) { case SEEK_DATA: retval = pmfs_find_region(inode, &offset, 0); if (retval) { mutex_unlock(&inode->i_mutex); return retval; } break; case SEEK_HOLE: retval = pmfs_find_region(inode, &offset, 1); if (retval) { mutex_unlock(&inode->i_mutex); return retval; } break; } if ((offset < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET)) || offset > inode->i_sb->s_maxbytes) { mutex_unlock(&inode->i_mutex); return -EINVAL; } if (offset != file->f_pos) { file->f_pos = offset; file->f_version = 0; } mutex_unlock(&inode->i_mutex); return offset; }
/* If a directory is seeked, we have to free saved readdir() state */ static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int origin) { kfree(file->private_data); file->private_data = NULL; return generic_file_llseek(file, offset, origin); }
static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int whence) { return generic_file_llseek(file, offset, whence); }
static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int origin) { return generic_file_llseek(file, offset, origin); }
/** * @brief generic llseek implementation for regular files This is a generic implemenation * of ->llseek useable for all normal local filesystems. It just updates the file * offset to the value specified by * @offset and @origin under i_mutex. * @param pfile file structure to seek on * @param offset file offset to seek to * @param origin type of seek * * @returns file postion after seek * */ loff_t yramfs_file_llseek(struct file *pfile, loff_t offset, int origin) { DBG_PRINT("seek"); return generic_file_llseek(pfile, offset, origin); }
loff_t dfs_file_lseek(struct file *filp, loff_t pos, int origin) { return generic_file_llseek(filp, pos, origin); }
loff_t sjfs_fops_llseek(struct file *f, loff_t l, int i) { printk("sjfs_fops_llseek -> generic_file_llseek\n"); return generic_file_llseek(f, l, i); }