"Fossies" - the Fresh Open Source Software Archive

Member "coda-6.9.5/coda-src/partition/inoder.c" (29 Aug 2005, 3851 Bytes) of package /linux/misc/old/coda-6.9.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "inoder.c" see the Fossies "Dox" file reference documentation.

    1 
    2 /* BLURB gpl
    3 
    4                            Coda File System
    5                               Release 6
    6 
    7           Copyright (c) 1987-2003 Carnegie Mellon University
    8                   Additional copyrights listed below
    9 
   10 This  code  is  distributed "AS IS" without warranty of any kind under
   11 the terms of the GNU General Public Licence Version 2, as shown in the
   12 file  LICENSE.  The  technical and financial  contributors to Coda are
   13 listed in the file CREDITS.
   14 
   15                         Additional copyrights
   16                            none currently
   17 
   18 #*/
   19 
   20 #ifdef HAVE_CONFIG_H
   21 #include <config.h>
   22 #endif
   23 
   24 #include "coda_string.h"
   25 #include <stdlib.h>
   26 #include <unistd.h>
   27 #include <stdio.h>
   28 #include <sys/param.h>
   29 
   30 #include <voltypes.h>
   31 #include "inodeops.h"
   32 #include "viceinode.h"
   33 #include "partition.h"
   34 #include "util.h"
   35 
   36 #define MODE 00700
   37 
   38 void dosubs(int *, int, int);
   39 int mdirs(int);
   40 
   41 int
   42 main(int argc, char **argv)
   43 {
   44     char myname[256];
   45     int rc, dev;
   46     int depth, width;
   47     struct DiskPartition *dp;
   48 
   49     if ( argc < 4 ) {
   50     printf("Usage %s <vicetab> <dir> {icreate,iinc,idec,header,setheader} opts\n", argv[0]);
   51     exit(1);
   52     }
   53     
   54     DP_Init(argv[1], hostname(myname));
   55 
   56     dp = DP_Get(argv[2]);
   57     
   58     if ( !dp ) {
   59     printf("Error getting partition named %s. Check vicetab.\n", argv[2]);
   60     exit(1);
   61     }
   62 
   63     depth = dp->d->ftree.depth;
   64     width = dp->d->ftree.width;
   65     dev = dp->device;
   66     
   67     if ( strcmp(argv[3], "icreate") == 0 ){
   68     if ( argc == 8 ) {
   69         u_long vol, vnode, uniq, vers;
   70         Inode ino;
   71 
   72         vol = atoi(argv[4]);
   73         vnode = atoi(argv[5]);
   74         uniq = atoi(argv[6]);
   75         vers = atoi(argv[7]);
   76         ino = icreate(dev, vol, vnode, uniq, vers);
   77         printf("Created inode %u (error if <=0)\n", ino);
   78         if ( ino > 0 ) 
   79         exit(0);
   80         else 
   81         exit(1);
   82     } else {
   83         printf("Usage %s <vicetab> <dir> icreate <vol> <vnode> <uniq> <vers>\n", argv[0]);
   84         exit(1);
   85     }
   86 
   87     } else if ( strcmp(argv[3], "header") == 0 ) { 
   88     if ( argc == 5 ) {
   89         Inode ino= atoi(argv[4]);
   90         struct i_header header;
   91         int rc;
   92 
   93         rc = dp->ops->get_header(dp, &header, ino);
   94         
   95         if ( rc == 0 ) {
   96         printf("Header for inode %u\n", ino);
   97         printf(" lnk   %d\n", header.lnk);
   98         printf(" vol   %x\n", header.volume);
   99         printf(" vnode %x\n", header.vnode);
  100         printf(" uniq  %x\n", header.unique);
  101         printf(" vers  %u\n", header.dataversion);
  102         printf(" magic %d\n", header.magic);
  103         exit(0);
  104         } else {
  105         printf("Error getting inode header %u\n", ino);
  106         exit(1);
  107         }
  108     } else {
  109         printf("Usage %s <vicetab> <dir> header <ino>\n", argv[0]);
  110         exit(1);
  111     }
  112 
  113     } else if ( strcmp(argv[3], "iinc") == 0 ) { 
  114     if ( argc == 5 ) {
  115         int ino = atoi(argv[4]);
  116         iinc(dev, ino, 0);
  117     } else {
  118         printf("Usage %s <vicetab> <dir> iinc <ino>\n", argv[0]);
  119         exit(1);
  120     }
  121 
  122     } else if ( strcmp(argv[3], "idec") == 0 ) { 
  123     if ( argc == 5  ) {
  124         int ino = atoi(argv[4]);
  125         idec(dev, ino, 0);
  126         exit(0);
  127     } else {
  128         printf("Usage %s <vicetab> <dir> idec <ino>\n", argv[0]);
  129         exit(1);
  130     }
  131         
  132     } else if ( strcmp(argv[3], "setheader") == 0 ) { 
  133     if ( argc == 10 ) {
  134         int magic = dp->ops->magic();
  135         Inode ino = atoi(argv[4]);
  136         int lnk = atoi(argv[5]);
  137         int vol = atoi(argv[6]);
  138         int vnode = atoi(argv[7]);
  139         int unique = atoi(argv[8]);
  140         int version = atoi(argv[9]);
  141         struct i_header header={lnk, vol, vnode, unique, version, magic};
  142         
  143         rc = dp->ops->put_header(dp, &header, ino);
  144         if ( rc != 0 ) {
  145         printf("Could not put header for ino %u\n", ino);
  146         exit(1);
  147         }
  148         exit(0);
  149 
  150     } else {
  151         printf("Usage %s <vicetab> <dir> setheader <ino> <lnk> <vol> <vnode> <uniq> <vers>\n", argv[0]);
  152         exit(1);
  153     }
  154     } else {
  155     printf("Usage %s <vicetab> <dir> {icreate,iinc,idec,header,setheader} opts\n", argv[0]);
  156     exit(1);
  157     }
  158 
  159     return 0;
  160 }
  161