/[hurd]/hurd/libstore/file.c
ViewVC logotype

Diff of /hurd/libstore/file.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by roland, Thu Mar 14 21:09:54 2002 UTC revision 1.18 by marcus, Tue Dec 3 17:47:06 2002 UTC
# Line 27  Line 27 
27    
28  #include "store.h"  #include "store.h"
29    
30    /* Return 0 if STORE's range is enforced by the filesystem, otherwise an
31       error.  */
32    static error_t
33    enforced (struct store *store)
34    {
35      if (store->num_runs != 1 || store->runs[0].start != 0)
36        /* Can't enforce non-contiguous ranges, or one not starting at 0.  */
37        return EINVAL;
38      else
39        {
40          /* See if the the current (one) range is that the kernel is enforcing. */
41          struct stat st;
42          error_t err = io_stat (store->port, &st);
43    
44          if (!err
45              && store->runs[0].length != (st.st_size >> store->log2_block_size))
46            /* The single run is not the whole file.  */
47            err = EINVAL;
48    
49          return err;
50        }
51    }
52    
53  static error_t  static error_t
54  file_read (struct store *store,  file_read (struct store *store,
55             store_offset_t addr, size_t index, size_t amount, void **buf,             store_offset_t addr, size_t index, size_t amount, void **buf,
# Line 46  file_write (struct store *store, Line 69  file_write (struct store *store,
69  }  }
70    
71  static error_t  static error_t
72    file_store_set_size (struct store *store, size_t newsize)
73    {
74      error_t err;
75    
76      if (enforced (store) != 0)
77        /* Bail out if there is more than a single run.  */
78        return EOPNOTSUPP;
79    
80      err = file_set_size (store->port, newsize);
81    
82      if (!err)
83      {
84        /* Update STORE's size and run.  */
85        store->size = newsize;
86        store->runs[0].length = newsize >> store->log2_block_size;
87      }
88    
89      return err;
90    }
91    
92    static error_t
93  file_decode (struct store_enc *enc, const struct store_class *const *classes,  file_decode (struct store_enc *enc, const struct store_class *const *classes,
94               struct store **store)               struct store **store)
95  {  {
# Line 88  ficlose (struct store *store) Line 132  ficlose (struct store *store)
132    store->port = MACH_PORT_NULL;    store->port = MACH_PORT_NULL;
133  }  }
134    
 /* Return 0 if STORE's range is enforced by the filesystem, otherwise an  
    error.  */  
 static error_t  
 enforced (struct store *store)  
 {  
   if (store->num_runs != 1 || store->runs[0].start != 0)  
     /* Can't enforce non-contiguous ranges, or one not starting at 0.  */  
     return EINVAL;  
   else  
     /* See if the the current (one) range is that the kernel is enforcing. */  
     {  
       struct stat st;  
       error_t err = io_stat (store->port, &st);  
   
       if (!err  
           && store->runs[0].length != (st.st_size >> store->log2_block_size))  
         /* The single run is not the whole file.  */  
         err = EINVAL;  
135    
       return err;  
     }  
 }  
136    
137  static error_t  static error_t
138  file_set_flags (struct store *store, int flags)  file_set_flags (struct store *store, int flags)
# Line 192  file_map (const struct store *store, vm_ Line 215  file_map (const struct store *store, vm_
215  const struct store_class  const struct store_class
216  store_file_class =  store_file_class =
217  {  {
218    STORAGE_HURD_FILE, "file", file_read, file_write,    STORAGE_HURD_FILE, "file", file_read, file_write, file_store_set_size,
219    store_std_leaf_allocate_encoding, store_std_leaf_encode, file_decode,    store_std_leaf_allocate_encoding, store_std_leaf_encode, file_decode,
220    file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map    file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map
221  };  };
# Line 219  struct store_class Line 242  struct store_class
242  store_file_byte_class =  store_file_byte_class =
243  {  {
244    STORAGE_HURD_FILE, "file", file_byte_read, file_byte_write,    STORAGE_HURD_FILE, "file", file_byte_read, file_byte_write,
245      file_store_set_size,
246    store_std_leaf_allocate_encoding, store_std_leaf_encode, file_decode,    store_std_leaf_allocate_encoding, store_std_leaf_encode, file_decode,
247    file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map    file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map
248  };  };

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26