extern struct osi_dev cacheDev;
extern struct vfsmount *afs_cacheMnt;
extern struct super_block *afs_cacheSBp;
+#if defined(STRUCT_TASK_HAS_CRED)
+extern struct cred *cache_creds;
+#endif
struct file *
-afs_linux_raw_open(afs_dcache_id_t *ainode, ino_t *hint)
+afs_linux_raw_open(afs_dcache_id_t *ainode)
{
struct inode *tip = NULL;
struct dentry *dp = NULL;
osi_Panic("Can't get dentry\n");
tip = dp->d_inode;
#endif
- tip->i_flags |= MS_NOATIME; /* Disable updating access times. */
+ tip->i_flags |= S_NOATIME; /* Disable updating access times. */
#if defined(STRUCT_TASK_HAS_CRED)
- filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred());
+ /* Use stashed credentials - prevent selinux/apparmor problems */
+ filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, cache_creds);
#else
filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR);
#endif
#else
osi_Panic("Can't open inode %d\n", (int) ainode->ufs);
#endif
- if (hint)
- *hint = tip->i_ino;
return filp;
}
{
struct osi_file *afile = NULL;
extern int cacheDiskType;
- struct file *filp = NULL;
+
AFS_STATCNT(osi_UFSOpen);
if (cacheDiskType != AFS_FCACHE_TYPE_UFS) {
osi_Panic("UFSOpen called for non-UFS cache\n");
}
if (!afs_osicred_initialized) {
/* valid for alpha_osf, SunOS, Ultrix */
- memset((char *)&afs_osi_cred, 0, sizeof(AFS_UCRED));
+ memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
crhold(&afs_osi_cred); /* don't let it evaporate, since it is static */
afs_osicred_initialized = 1;
}
}
memset(afile, 0, sizeof(struct osi_file));
- afile->filp = afs_linux_raw_open(ainode, &afile->inum);
+ afile->filp = afs_linux_raw_open(ainode);
afile->size = i_size_read(FILE_INODE(afile->filp));
AFS_GLOCK();
afile->offset = 0;
afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
{
AFS_STATCNT(osi_Stat);
- MObtainWriteLock(&afs_xosi, 320);
+ ObtainWriteLock(&afs_xosi, 320);
astat->size = i_size_read(OSIFILE_INODE(afile));
astat->mtime = OSIFILE_INODE(afile)->i_mtime.tv_sec;
astat->atime = OSIFILE_INODE(afile)->i_atime.tv_sec;
- MReleaseWriteLock(&afs_xosi);
+ ReleaseWriteLock(&afs_xosi);
return 0;
}
code = afs_osi_Stat(afile, &tstat);
if (code || tstat.size <= asize)
return code;
- MObtainWriteLock(&afs_xosi, 321);
+ ObtainWriteLock(&afs_xosi, 321);
AFS_GUNLOCK();
-#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
- down_write(&inode->i_alloc_sem);
-#endif
#ifdef STRUCT_INODE_HAS_I_MUTEX
mutex_lock(&inode->i_mutex);
#else
down(&inode->i_sem);
#endif
+#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
+ down_write(&inode->i_alloc_sem);
+#endif
newattrs.ia_size = asize;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
newattrs.ia_ctime = CURRENT_TIME;
if (!code)
truncate_inode_pages(&inode->i_data, asize);
code = -code;
+#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
+ up_write(&inode->i_alloc_sem);
+#endif
#ifdef STRUCT_INODE_HAS_I_MUTEX
mutex_unlock(&inode->i_mutex);
#else
up(&inode->i_sem);
#endif
-#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
- up_write(&inode->i_alloc_sem);
-#endif
AFS_GLOCK();
- MReleaseWriteLock(&afs_xosi);
+ ReleaseWriteLock(&afs_xosi);
return code;
}
/* seek to the desired position. Return -1 on error. */
if (filp->f_op->llseek) {
if (filp->f_op->llseek(filp, (loff_t) uiop->uio_offset, 0) != uiop->uio_offset)
- return -1;
+ code = -1;
+ goto out;
} else
filp->f_pos = uiop->uio_offset;
code = 0;
}
+out:
if (uiop->uio_seg == AFS_UIOSYS)
TO_KERNEL_SPACE();