b0VIM 6.1      3A) BO  choo                                    simey                                   ~choo/work/modules/snmpfs/stamfs/stamfs_fops.c                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      3210#"! U                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     tp       h            B   i                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ad  C        h     |  :                    u  t  `  F  .                    b  1                t  G          i  ?  <  ;  :  7  
  
  
  
  
  T
  
  	  	  	  g	  ?	  *	  	  	        F        G  ,  "  !        J  #            R  *        y  Z  P  0      d  '        }  s  r  :                                                                             err = stamfs_dir_get_data_block_num(dir, &data_block_num);         /* read in the data block of this directory. */          }                 filp->f_pos++;                         goto done;                 if (over < 0)                                dentry->d_parent->d_inode->i_ino, DT_DIR);                 over = filldir(dirent, "..", 2, filp->f_pos,                                      dentry->d_parent->d_inode->i_ino);                                      "adding '..', ino=%lu\n",                 STAMFS_DBG(DEB_STAM, "stamfs: readdir, f_pos == 1, "         if (filp->f_pos == 1) {         }                 filp->f_pos++;                         goto done;                 if (over < 0)                                dir->i_ino, DT_DIR);                 over = filldir(dirent, ".", 1, filp->f_pos,                            dir->i_ino);                            "stamfs: readdir, f_pos == 0, adding '.', ino=%lu\n",                 STAMFS_DBG(DEB_STAM,         if (filp->f_pos == 0) {         /* special handling for '.' and '..' */          }                 need_revalidation = 0;                 /* TODO - make sure 'pos' points to the beginning of a dir rec. */         if (need_revalidation) {          * mean at all? */         /* TODO - what does this revalidation, and version information,          }                 goto done;                            "stamfs: file pos larger then dir size.\n");                 STAMFS_DBG(DEB_STAM,         if (filp->f_pos > dir->i_size - sizeof(struct stamfs_dir_rec)) {          * handle reading of the two pseudo-entries for "." and "..". */         /* TODO - well, when reading an empty directory - we still need to                               dentry->d_name.name, filp->f_pos);         STAMFS_DBG(DEB_STAM, "stamfs: readdir, file=%s, pos=%llu\n",          int over;         int err = 0;         struct stamfs_dir_rec *dir_rec;         int data_block_num = 0;         struct buffer_head *bh = NULL;         int need_revalidation = (filp->f_version != dir->i_version);         struct super_block* sb = dir->i_sb;         struct inode *dir = filp->f_dentry->d_inode;         struct dentry *dentry = filp->f_dentry; { int stamfs_readdir(struct file *filp, void *dirent, filldir_t filldir)  */  * passing it back to the user.  * This function is used for reading the contents of a directory, and /*   };         fsync:          stamfs_sync_file,         open:           generic_file_open,         mmap:           generic_file_mmap,         /*ioctl: we don't support any ioctls. */         write:          generic_file_write,         read:           generic_file_read,         llseek:         generic_file_llseek, struct file_operations stamfs_file_fops = {  */  * generic VFS code.  * most of the file-operations for normal files are directly handled by /*  };         fsync:          stamfs_sync_file         /*ioctl: we don't support any ioctls. */         readdir:        stamfs_readdir,         read:           generic_read_dir, struct file_operations stamfs_dir_fops = {   */  * Data structures. /*  #include "stamfs_util.h" #include "stamfs_fops.h" #include "stamfs_dir.h" #include "stamfs_super.h" #include "stamfs.h"  #include <linux/dcache.h> #include <linux/fs.h>    */  *$Id$ /*  /* License: GNU General Public License                         */ /* Copyright (C) 2004 guy keren, choo@actcom.co.il             */ /*                                                             */ /* implements a file-system for accessing STAM devices.        */ /* This file is part of stamfs, a GNU/Linux kernel module that */ ad  "  >     B       E            s  6        M            `          Y  1    
  
  
  j
  &
  	  	  	  u	  t	  8	  	            {  Q  6  5  %  	              ^  M  I          W  @  >  =                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }         return -EPERM;                              filp->f_dentry->d_name.name, datasync);         STAMFS_DBG(DEB_STAM, "stamfs: sync_file, file=%s, datasync=%d.\n",         /* TODO */ { int stamfs_sync_file(struct file *filp, struct dentry *dentry, int datasync)  */  * to the disk).  * (i.e. forcing writing all dirty pages and buffer_head-s of this file  * This function is used for syncing the contents of a file to the disk /*  }         return err;                  brelse(bh);         if (bh)          UPDATE_ATIME(dir);         filp->f_version = dir->i_version;   done:          }                 dir_rec++;                         goto done;                 if (filp->f_pos >= STAMFS_BLOCK_SIZE + 2)                  * phony "." and ".." entries. */                 /* note: again, the '+ 2' is because of the                  filp->f_pos += sizeof(struct stamfs_dir_rec);                 /* skip to the next entry. */                                       le32_to_cpu(dir_rec->dr_ino));                                      filp->f_pos, dir_rec->dr_name,                                      "adding '%s', ino=%u\n",                 STAMFS_DBG(DEB_STAM, "stamfs: readdir, f_pos == %lld, "                          goto done;                 if(over < 0)                                d_type);                                filp->f_pos, le32_to_cpu(dir_rec->dr_ino),                 over = filldir(dirent, dir_rec->dr_name, dir_rec->dr_name_len,                          d_type = DT_REG;                 if (dir_rec->dr_ftype == STAMFS_DIR_REC_FTYPE_FILE)                         d_type = DT_DIR;                 if (dir_rec->dr_ftype == STAMFS_DIR_REC_FTYPE_DIR)                          break;                 if (dir_rec->dr_ino == 0)                 /* dr_ino == 0 implies end-of-list. */                 unsigned char d_type = DT_UNKNOWN;         while (1) {         dir_rec = (struct stamfs_dir_rec *)(((char*)(bh->b_data)) + filp->f_pos - 2);         /* note: the '- 2' is because of the phony "." and ".." entries. */          * we finish filling the dirent's available space */         /* loop over the dir entries, until we finish scanning, or until          }                 goto done;                 err = -EIO;                 printk("stamfs: unable to read block-index block.\n");         if (!(bh = bread(sb->s_dev, data_block_num, STAMFS_BLOCK_SIZE))) {                              data_block_num);         STAMFS_DBG(DEB_STAM, "stamfs: block index in block %d\n", 