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

Diff of /hurd/libstore/rdwr.c

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

revision 1.26 by marcus, Tue Dec 3 17:47:06 2002 UTC revision 1.27 by marcus, Mon Aug 4 22:00:24 2003 UTC
# Line 1  Line 1 
1  /* Store I/O  /* Store I/O
2    
3     Copyright (C) 1995,96,97,98,99,2001,02 Free Software Foundation, Inc.     Copyright (C) 1995-1999,2001,2002,2003 Free Software Foundation, Inc.
4     Written by Miles Bader <miles@gnu.org>     Written by Miles Bader <miles@gnu.org>
5     This file is part of the GNU Hurd.     This file is part of the GNU Hurd.
6    
# Line 89  store_next_run (struct store *store, str Line 89  store_next_run (struct store *store, str
89      return 1;      return 1;
90  }  }
91    
 #include <assert.h>  
   
92  /* Write LEN bytes from BUF to STORE at ADDR.  Returns the amount written  /* Write LEN bytes from BUF to STORE at ADDR.  Returns the amount written
93     in AMOUNT.  ADDR is in BLOCKS (as defined by STORE->block_size).  */     in AMOUNT.  ADDR is in BLOCKS (as defined by STORE->block_size).  */
94  error_t  error_t
# Line 110  store_write (struct store *store, Line 108  store_write (struct store *store,
108    if ((addr << block_shift) + len > store->size)    if ((addr << block_shift) + len > store->size)
109      return EIO;      return EIO;
110    
111    if (store->block_size != 0)    if (store->block_size != 0 && (len & (store->block_size - 1)) != 0)
112      assert ((len & (store->block_size - 1)) == 0);      return EINVAL;
113    
114    addr = store_find_first_run (store, addr, &run, &runs_end, &base, &index);    addr = store_find_first_run (store, addr, &run, &runs_end, &base, &index);
115    if (addr < 0)    if (addr < 0)
# Line 190  store_read (struct store *store, Line 188  store_read (struct store *store,
188    if ((addr << block_shift) + amount > store->size)    if ((addr << block_shift) + amount > store->size)
189      amount = store->size - (addr << block_shift);      amount = store->size - (addr << block_shift);
190    
191    if (store->block_size != 0)    if (store->block_size != 0 && (amount & (store->block_size - 1)) != 0)
192      assert ((amount & (store->block_size - 1)) == 0);      return EINVAL;
193    
194    if ((amount >> block_shift) <= run->length - addr)    if ((amount >> block_shift) <= run->length - addr)
195      /* The first run has it all... */      /* The first run has it all... */

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

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