execute from AFS support for linux 2.0

Derrick J Brashear shadow at dementia.org
Sun Jun 28 04:30:46 CEST 1998


Attached is a patch which adds support to xfs to allow execution directly out
of AFS. This is code which was written by Chaskiel Grundman for arla 0.5 which
at the time due to other problems I couldn't get to work, and he put it aside. 

I guarantee it breaks 2.1 support, but I don't have any 2.1 machines to make it
work correctly on either. I haven't heavily tested it yet, so take with a grain
of salt.

-D


*** xfs/linux/xfs_inodeops.c.orig	Wed Jun 17 15:05:04 1998
--- xfs/linux/xfs_inodeops.c	Sat Jun 27 22:05:34 1998
***************
*** 45,50 ****
--- 45,51 ----
  #include "xfs_syscalls.h"
  #include <linux/binfmts.h>
  #include <linux/file.h>
+ #include <linux/mm.h>
  
  RCSID("$Id: xfs_inodeops.c,v 1.30 1998/06/08 22:46:00 map Exp $");
  
***************
*** 69,81 ****
  static int
  xfs_permission(struct inode *inode, int mode);
  
- #ifndef LINUX2_1
  static int
! xfs_read_file(struct inode *inode, struct file *file, char *buf, int count);
! #else
! static ssize_t
! xfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos);
! #endif /* LINUX2_1 */
  
  #ifndef LINUX2_1
  static int
--- 70,77 ----
  static int
  xfs_permission(struct inode *inode, int mode);
  
  static int
! xfs_readpage(struct inode *inode, struct page *page);
  
  #ifndef LINUX2_1
  static int
***************
*** 156,169 ****
  #endif /* LINUX2_1 */
  xfs_release_file (struct inode *inode, struct file *file);
  
  static struct file_operations xfs_file_operations = {
          NULL,                   /* lseek */
!         xfs_read_file,          /* read */
          xfs_write_file,         /* write */
          NULL,                   /* readdir */
          NULL,                   /* select */
          NULL,                   /* ioctl */
!         NULL,                   /* mmap */
          xfs_open,               /* open */
          xfs_release_file,       /* release */
          xfs_fsync,              /* fsync */
--- 152,172 ----
  #endif /* LINUX2_1 */
  xfs_release_file (struct inode *inode, struct file *file);
  
+ static int
+ xfs_link (struct inode * inode, struct inode * dir, const char *name, int len);
+ 
+ static int
+ xfs_symlink (struct inode * dir, const char *name, int len,
+              const char * symname); 
+ 
  static struct file_operations xfs_file_operations = {
          NULL,                   /* lseek */
!         generic_file_read,      /* read */
          xfs_write_file,         /* write */
          NULL,                   /* readdir */
          NULL,                   /* select */
          NULL,                   /* ioctl */
! 	generic_file_mmap,      /* mmap */
          xfs_open,               /* open */
          xfs_release_file,       /* release */
          xfs_fsync,              /* fsync */
***************
*** 185,191 ****
          NULL,                   /* rename */
          NULL,                   /* readlink */
          NULL,                   /* follow_link */
!         generic_readpage,       /* readpage */
          NULL,                   /* writepage */
          NULL,                   /* bmap */
          NULL,                   /* truncate (not yet) */
--- 188,194 ----
          NULL,                   /* rename */
          NULL,                   /* readlink */
          NULL,                   /* follow_link */
!         xfs_readpage,           /* readpage */
          NULL,                   /* writepage */
          NULL,                   /* bmap */
          NULL,                   /* truncate (not yet) */
***************
*** 201,207 ****
          NULL,                   /* select */
          NULL,                   /* ioctl */
          NULL,                   /* mmap */
!         NULL,                   /* open */
          NULL,                   /* release */
          NULL,                   /* fsync */
  	NULL,			/* fasync */
--- 204,210 ----
          NULL,                   /* select */
          NULL,                   /* ioctl */
          NULL,                   /* mmap */
!         xfs_open,               /* open */
          NULL,                   /* release */
          NULL,                   /* fsync */
  	NULL,			/* fasync */
***************
*** 250,258 ****
          &xfs_dir_operations,   /* default file operations */
          xfs_create,             /* create */
          xfs_lookup,             /* lookup */
!         NULL,                   /* link (not yet) */
          xfs_unlink,             /* unlink */
!         NULL,                   /* symlink (not yet) */
          xfs_mkdir,              /* mkdir */
          xfs_rmdir,              /* rmdir */
          NULL,                   /* mknod */
--- 253,261 ----
          &xfs_dir_operations,   /* default file operations */
          xfs_create,             /* create */
          xfs_lookup,             /* lookup */
!         xfs_link,               /* link */
          xfs_unlink,             /* unlink */
!         xfs_symlink,            /* symlink (not */
          xfs_mkdir,              /* mkdir */
          xfs_rmdir,              /* rmdir */
          NULL,                   /* mknod */
***************
*** 716,726 ****
  
  #ifndef LINUX2_1
  static int
! xfs_read_file(struct inode *inode, struct file *file, char *buf, int count)
  {
    int error = 0;
  
!   XFSDEB(XDEBVNOPS, ("xfs_read_file file->f_pos: %d count: %d\n",(int) file->f_pos,count));
  
    error = xfs_data_valid(inode, XFS_DATA_R);
  
--- 719,729 ----
  
  #ifndef LINUX2_1
  static int
! xfs_readpage(struct inode *inode, struct page *page)
  {
    int error = 0;
  
!   XFSDEB(XDEBVNOPS, ("xfs_readpage pos: %d\n",(int) page->offset));
  
    error = xfs_data_valid(inode, XFS_DATA_R);
  
***************
*** 728,744 ****
      struct inode *t = DATA_FROM_VNODE(inode);
      t->i_count++;
      if (t->i_op &&
!         t->i_op->default_file_ops &&
!         t->i_op->default_file_ops->read)
!       error = t->i_op->default_file_ops->read(t, file, buf, count);
!     else {      
!         printk("XFS Panic! read not defined in cache file system\n");
!         error = -EINVAL;
      }
      iput(t);
    }
    return error;
  }
  #else
  static int
  xfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos)
--- 731,775 ----
      struct inode *t = DATA_FROM_VNODE(inode);
      t->i_count++;
      if (t->i_op &&
! 	t->i_op->readpage)
!       error = t->i_op->readpage(t, page);
!     else if (t->i_op &&
!              t->i_op->default_file_ops &&
! 	     t->i_op->default_file_ops->read) {
!       struct file f;
!       unsigned long address = page_address (page);
!       char *data = (char *) address;
!       f.f_pos=page->offset;
!       f.f_mode=FMODE_READ;
!       f.f_inode=t;
!       
!       /* Lock the page */
!       page->count++;
!       set_bit(PG_locked, &page->flags);
!       clear_bit(PG_error, &page->flags);
! 
!       error=t->i_op->default_file_ops->read(t, &f, data, PAGE_SIZE);
!       if (error >= 0) {
!         memset(data+error, 0, PAGE_SIZE-error);
!         error=0;
!       }
!       if (!error)
!         set_bit(PG_uptodate, &page->flags);
!       
!       /* Unlock the page and wake up anyone waiting for it */
!       clear_bit(PG_locked, &page->flags);
!       wake_up(&page->wait);
!       free_page(address);
!       
!     } else {
!       printk("XFS Panic! read not defined in cache file system\n");
!       error = -EINVAL;
      }
      iput(t);
    }
    return error;
  }
+   
  #else
  static int
  xfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos)
***************
*** 784,792 ****
  
  
  #ifndef LINUX2_1
! static int xfs_write_file(struct inode *inode, struct file *file, const char *buf, int count)
  {
      int error = 0;
      
      XFSDEB(XDEBVNOPS, ("xfs_write_file file->f_pos: %d count: %d\n",(int) file->f_pos,count));
      
--- 815,824 ----
  
  
  #ifndef LINUX2_1
! int xfs_write_file(struct inode *inode, struct file *file, const char *buf, int count)
  {
      int error = 0;
+     unsigned long page;
      
      XFSDEB(XDEBVNOPS, ("xfs_write_file file->f_pos: %d count: %d\n",(int) file->f_pos,count));
      
***************
*** 797,810 ****
          t->i_count++;
          if (t->i_op &&
              t->i_op->default_file_ops &&
!             t->i_op->default_file_ops->read) {
              XFSDEB(XDEBVNOPS, ("xfs_write_file t:%p",t));
              error = t->i_op->default_file_ops->write(t, file, buf, count);
              XFSDEB(XDEBVNOPS, ("xfs_write_file error: %d\n",error));
              VNODE_TO_XNODE(inode)->flags |= XFS_DATA_DIRTY;
              inode->i_size = t->i_size;
!             inode->i_mtime = t->i_mtime;
!         } else {        
              printk("XFS Panic! write not defined in cache file system\n");
              error = -EINVAL;
          }
--- 829,861 ----
          t->i_count++;
          if (t->i_op &&
              t->i_op->default_file_ops &&
!             t->i_op->default_file_ops->write) {
              XFSDEB(XDEBVNOPS, ("xfs_write_file t:%p",t));
              error = t->i_op->default_file_ops->write(t, file, buf, count);
              XFSDEB(XDEBVNOPS, ("xfs_write_file error: %d\n",error));
              VNODE_TO_XNODE(inode)->flags |= XFS_DATA_DIRTY;
              inode->i_size = t->i_size;
!             page=get_free_page(GFP_KERNEL);
!             if (!page)
!               invalidate_inode_pages(inode);
!             else {
!               int pos=file->f_pos;
!               int cnt=count;
!               int blk;
!               char *data=(char *)page;
! 
!               while (cnt > 0) {
!                 blk=cnt;
!                 if (blk > PAGE_SIZE)
!                   blk=PAGE_SIZE;
!                 memcpy_fromfs(data, buf, blk);
!                 update_vm_cache(inode, pos, data, blk);
!                 pos+=blk;
!                 cnt-=blk;
!               }
!               free_page(page);
!             }            
!         } else {
              printk("XFS Panic! write not defined in cache file system\n");
              error = -EINVAL;
          }
***************
*** 937,943 ****
      
  }
  
! int
  #ifndef LINUX2_1
  xfs_unlink (struct inode * dir, const char * name, int len)
  #else
--- 988,1029 ----
      
  }
  
! static int
! xfs_link (struct inode * inode, struct inode * dir, const char *name, int len)
! {
!   
!     struct xfs_message_link msg;
!     struct xfs *xfsp  = XFS_FROM_VNODE(dir);
!     struct xfs_node *xn = VNODE_TO_XNODE(dir);
!     struct xfs *fxfsp  = XFS_FROM_VNODE(inode);
!     struct xfs_node *fxn = VNODE_TO_XNODE(inode);
!     int error;
!     
!     XFSDEB(XDEBVNOPS, ("xfs_link: (%s, %d)\n", name, len));
!     if (xfsp != fxfsp) { /* Is this required? */
!           XFSDEB(XDEBVNOPS, ("xfs_link: Can't link accross fs's (%p, %p)\n",
!                              xfsp, fxfsp));
!           iput(inode);
!           iput(dir);
!           return -EXDEV;
!     }
!     
!     msg.header.opcode = XFS_MSG_LINK;
!     msg.parent_handle = xn->handle;
!     strncpy(msg.name, name, 256);
!     msg.from_handle = fxn->handle;
!     msg.cred.uid = current->uid;
!     msg.cred.pag = xfs_get_pag();
!     error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
!     if (error == 0)
!         error = ((struct xfs_message_wakeup *) &msg)->error;
! 
!     iput(inode);
!     iput(dir);
!     return -error;
! }
! 
! static int
  #ifndef LINUX2_1
  xfs_unlink (struct inode * dir, const char * name, int len)
  #else
***************
*** 986,991 ****
--- 1072,1104 ----
      return error;
  }
  
+ static int
+ xfs_symlink (struct inode * dir, const char *name, int len,
+              const char * symname)
+ {
+     struct xfs_message_symlink msg;
+     struct xfs *xfsp  = XFS_FROM_VNODE(dir);
+     struct xfs_node *xn = VNODE_TO_XNODE(dir);
+     int error;
+     
+     XFSDEB(XDEBVNOPS,
+            ("xfs_symlink: (%s, %d) to %s\n", name, len, symname));
+     
+     msg.header.opcode = XFS_MSG_SYMLINK;
+     msg.parent_handle = xn->handle;
+     strncpy(msg.name, name, 256);
+     strncpy(msg.contents, symname, 2048);
+     XA_CLEAR(&msg.attr);
+     msg.cred.uid = current->uid;
+     msg.cred.pag = xfs_get_pag();
+     error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
+     if (error == 0)
+         error = ((struct xfs_message_wakeup *) &msg)->error;
+ 
+     iput(dir);
+     return -error;
+ }
+ 
  int
  #ifndef LINUX2_1
  xfs_rename (struct inode * old_dir, const char * old_name, int old_len,
***************
*** 1188,1197 ****
  }
  
  #ifndef LINUX2_1
! static int xfs_readdir(struct inode * inode, struct file * file,
  		       void * dirent, filldir_t filldir)
  #else
! static int
  xfs_readdir(struct file * file, void * dirent, filldir_t filldir)
  #endif /* LINUX2_1 */
  {
--- 1301,1310 ----
  }
  
  #ifndef LINUX2_1
! int xfs_readdir(struct inode * inode, struct file * file,
  		       void * dirent, filldir_t filldir)
  #else
! int
  xfs_readdir(struct file * file, void * dirent, filldir_t filldir)
  #endif /* LINUX2_1 */
  {
***************
*** 1205,1213 ****
  #endif /* LINUX2_1 */
      int fileno;
      char *buf;
- #ifndef LINUX2_1
-     long oldfs;
- #endif /* LINUX2_1 */
  
      XFSDEB(XDEBREADDIR, ("xfs_readdir\n"));
      
--- 1318,1323 ----
***************
*** 1227,1238 ****
  		offset = file->f_pos & (XFS_DIRENT_BLOCKSIZE - 1);
  		
  		XFSDEB(XDEBREADDIR, ("xfs_readdir begin_offset: %d offset: %d\n",(int)begin_offset,(int)offset));
- 		oldfs = get_fs();
- 		set_fs(KERNEL_DS);
  		file->f_pos = begin_offset;
  		file->f_reada = 0;
  		error = t->i_op->default_file_ops->read(t, file, buf, XFS_DIRENT_BLOCKSIZE);
- 		set_fs(oldfs);
  		if (error == XFS_DIRENT_BLOCKSIZE) {
  		  XFSDEB(XDEBREADDIR, ("xfs_readdir error: %d\n",error));
  		    while (offset < XFS_DIRENT_BLOCKSIZE) {
--- 1337,1345 ----
***************
*** 1382,1391 ****
  }
  
  #ifndef LINUX2_1
! static int xfs_follow_link(struct inode * dir, struct inode * inode,
  			   int flag, int mode, struct inode ** res_inode)
  #else
! static struct dentry *
  xfs_follow_link(struct dentry *dentry, struct dentry *base)
  #endif /* LINUX2_1 */
  {
--- 1489,1498 ----
  }
  
  #ifndef LINUX2_1
! int xfs_follow_link(struct inode * dir, struct inode * inode,
  			   int flag, int mode, struct inode ** res_inode)
  #else
! struct dentry *
  xfs_follow_link(struct dentry *dentry, struct dentry *base)
  #endif /* LINUX2_1 */
  {
***************
*** 1398,1403 ****
--- 1505,1511 ----
  #ifdef LINUX2_1
      int error;
  #endif /* LINUX2_1 */
+     unsigned long fs = get_fs();
  
  #ifndef LINUX2_1
      *res_inode = NULL;
***************
*** 1432,1438 ****
--- 1540,1548 ----
  #endif /* LINUX2_1 */
      }
  #ifndef LINUX2_1
+     set_fs(get_ds());
      error = xfs_readlink(inode, buffer, MAXPATHLEN);
+     set_fs(fs);
  #else
      error = xfs_readlink(dentry, buffer, MAXPATHLEN);
  #endif /* LINUX2_1 */
*** xfs/linux/xfs_vfsops.c.orig	Sat Jun 27 21:48:27 1998
--- xfs/linux/xfs_vfsops.c	Sat Jun 27 22:01:10 1998
***************
*** 261,267 ****
  }
  
  void
! vattr2xfs_attr(struct iattr *iattr, struct xfs_attr *attr)
  {
      XA_CLEAR(attr);
      if (iattr->ia_valid & ATTR_MODE)
--- 261,267 ----
  }
  
  void
! vattr2xfs_attr(struct inode *inode, struct iattr *iattr, struct xfs_attr *attr)
  {
      XA_CLEAR(attr);
      if (iattr->ia_valid & ATTR_MODE)
***************
*** 307,313 ****
  	msg.cred.uid = current->uid;
  	msg.cred.pag = xfs_get_pag();
          msg.handle = xn->handle;
!         vattr2xfs_attr(attr, &msg.attr);
  	inode_setattr(inode, attr);
          error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
          if (error == 0) {
--- 307,313 ----
  	msg.cred.uid = current->uid;
  	msg.cred.pag = xfs_get_pag();
          msg.handle = xn->handle;
!         vattr2xfs_attr(inode, attr, &msg.attr);
  	inode_setattr(inode, attr);
          error = xfs_message_rpc(xfsp->fd, &msg.header, sizeof(msg));
          if (error == 0) {
*** xfs/linux/xfs_message.c.orig	Wed Jun 17 15:05:05 1998
--- xfs/linux/xfs_message.c	Sat Jun 27 21:37:25 1998
***************
*** 273,278 ****
--- 273,280 ----
  			XFS_DATA_MASK | XFS_LOCK_MASK);
  #ifndef LINUX2_1
  	xfs_cache_delete(t);
+ 	if (XNODE_TO_VNODE(t))
+           invalidate_inode_pages(XNODE_TO_VNODE(t));
  #else
        	clear_all_childs(XNODE_TO_VNODE(t));
  #endif /* LINUX2_1 */





More information about the Arla-drinkers mailing list