#if defined(AFS_LINUX26_ENV)
#include "h/namei.h"
#endif
-
+#if !defined(HAVE_IGET)
+#include "h/exportfs.h"
+#endif
afs_lock_t afs_xosi; /* lock is for tvattr */
extern struct osi_dev cacheDev;
#if defined(AFS_LINUX26_ENV)
void *
+#if defined(LINUX_USE_FH)
+osi_UFSOpen_fh(struct fid *fh, int fh_type)
+#else
osi_UFSOpen(afs_int32 ainode)
+#endif
{
register struct osi_file *afile = NULL;
extern int cacheDiskType;
struct inode *tip = NULL;
struct dentry *dp = NULL;
struct file *filp = NULL;
+#if !defined(HAVE_IGET) || defined(LINUX_USE_FH)
+ struct fid fid;
+#endif
AFS_STATCNT(osi_UFSOpen);
if (cacheDiskType != AFS_FCACHE_TYPE_UFS) {
osi_Panic("UFSOpen called for non-UFS cache\n");
AFS_GUNLOCK();
if (!afile) {
osi_Panic("osi_UFSOpen: Failed to allocate %d bytes for osi_file.\n",
- sizeof(struct osi_file));
+ (int)sizeof(struct osi_file));
}
memset(afile, 0, sizeof(struct osi_file));
+#if defined(HAVE_IGET)
tip = iget(afs_cacheSBp, (u_long) ainode);
if (!tip)
osi_Panic("Can't get inode %d\n", ainode);
- tip->i_flags |= MS_NOATIME; /* Disable updating access times. */
dp = d_alloc_anon(tip);
+#else
+#if defined(LINUX_USE_FH)
+ dp = afs_cacheSBp->s_export_op->fh_to_dentry(afs_cacheSBp, fh, sizeof(struct fid), fh_type);
+#else
+ fid.i32.ino = ainode;
+ fid.i32.gen = 0;
+ dp = afs_cacheSBp->s_export_op->fh_to_dentry(afs_cacheSBp, &fid, sizeof(fid), FILEID_INO32_GEN);
+#endif
if (!dp)
- osi_Panic("Can't get dentry for inode %d\n", ainode);
+ osi_Panic("Can't get dentry\n");
+ tip = dp->d_inode;
+#endif
+ tip->i_flags |= MS_NOATIME; /* Disable updating access times. */
+#if defined(STRUCT_TASK_HAS_CRED)
+ filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred());
+#else
filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR);
+#endif
if (IS_ERR(filp))
+#if defined(LINUX_USE_FH)
+ osi_Panic("Can't open file\n");
+#else
osi_Panic("Can't open inode %d\n", ainode);
+#endif
afile->filp = filp;
- afile->size = FILE_INODE(filp)->i_size;
+ afile->size = i_size_read(FILE_INODE(filp));
AFS_GLOCK();
afile->offset = 0;
afile->proc = (int (*)())0;
+#if defined(LINUX_USE_FH)
+ afile->inum = tip->i_ino; /* for hint validity checking */
+#else
afile->inum = ainode; /* for hint validity checking */
+#endif
return (void *)afile;
}
#else
code = filp->f_op->open(tip, filp);
if (code)
osi_Panic("Can't open inode %d\n", ainode);
- afile->size = tip->i_size;
+ afile->size = i_size_read(tip);
AFS_GLOCK();
afile->offset = 0;
afile->proc = (int (*)())0;
}
#endif
+#if defined(LINUX_USE_FH)
+int
+osi_get_fh(struct dentry *dp, struct fid *fh, int *max_len) {
+ int fh_type;
+
+ if (dp->d_sb->s_export_op->encode_fh) {
+ fh_type = dp->d_sb->s_export_op->encode_fh(dp, (__u32 *)fh, max_len, 0);
+ } else {
+ fh_type = FILEID_INO32_GEN;
+ fh->i32.ino = dp->d_inode->i_ino;
+ fh->i32.gen = dp->d_inode->i_generation;
+ }
+ dput(dp);
+ return(fh_type);
+}
+#endif
+
int
afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
{
register afs_int32 code;
AFS_STATCNT(osi_Stat);
MObtainWriteLock(&afs_xosi, 320);
- astat->size = OSIFILE_INODE(afile)->i_size;
- astat->blksize = OSIFILE_INODE(afile)->i_blksize;
+ astat->size = i_size_read(OSIFILE_INODE(afile));
#if defined(AFS_LINUX26_ENV)
astat->mtime = OSIFILE_INODE(afile)->i_mtime.tv_sec;
astat->atime = OSIFILE_INODE(afile)->i_atime.tv_sec;
if (!code)
truncate_inode_pages(&inode->i_data, asize);
#else
- inode->i_size = asize;
+ i_size_write(inode, asize);
if (inode->i_sb->s_op && inode->i_sb->s_op->notify_change) {
code = inode->i_sb->s_op->notify_change(&afile->dentry, &newattrs);
}
void
shutdown_osifile(void)
{
- extern int afs_cold_shutdown;
-
AFS_STATCNT(shutdown_osifile);
if (afs_cold_shutdown) {
afs_osicred_initialized = 0;
osi_InitCacheInfo(char *aname)
{
int code;
+#if defined(LINUX_USE_FH)
+ int max_len = sizeof(struct fid);
+#else
+ extern ino_t cacheInode;
+#endif
struct dentry *dp;
extern ino_t cacheInode;
extern struct osi_dev cacheDev;
if (code)
return ENOENT;
+#if defined(LINUX_USE_FH)
+ if (dp->d_sb->s_export_op->encode_fh) {
+ cacheitems_fh_type = dp->d_sb->s_export_op->encode_fh(dp, (__u32 *)&cacheitems_fh, &max_len, 0);
+ } else {
+ cacheitems_fh_type = FILEID_INO32_GEN;
+ cacheitems_fh.i32.ino = dp->d_inode->i_ino;
+ cacheitems_fh.i32.gen = dp->d_inode->i_generation;
+ }
+#else
cacheInode = dp->d_inode->i_ino;
+#endif
cacheDev.dev = dp->d_inode->i_sb->s_dev;
afs_fsfragsize = dp->d_inode->i_sb->s_blocksize - 1;
afs_cacheSBp = dp->d_inode->i_sb;