diff options
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/node-rdwr.c | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/libdiskfs/node-rdwr.c b/libdiskfs/node-rdwr.c index 4ee9a213..3c099e4c 100644 --- a/libdiskfs/node-rdwr.c +++ b/libdiskfs/node-rdwr.c @@ -18,48 +18,48 @@ #include "priv.h" /* Reading and writing of files. this is called by other filesystem - routines and handles extension of files and reads of more than is - left automatically. NP is the node to be read or written. DATA - will be written or filled. OFF identifies where in thi fel the I/O - is to take place (-1 is not allowed). AMT is the size of DATA and - tells how much to copy. DIR is 1 for writing and 0 for reading. - CRED is the user doing the access (only used to validate attempted - file extension). */ + routines and handles extension of files automatically. NP is the + node to be read or written, and must be locked. DATA will be + written or filled. OFF identifies where in thi fel the I/O is to + take place (-1 is not allowed). AMT is the size of DATA and tells + how much to copy. DIR is 1 for writing and 0 for reading. CRED is + the user doing the access (only used to validate attempted file + extension). For reads, *AMTREAD is filled with the amount actually + read. */ error_t -diskfs_noderdwr (struct inode *ip, - char *data, - off_t off, - int amt, - int dir, - struct protid *cred) +diskfs_node_rdwr (struct node *np, + char *data, + off_t off, + int amt, + int dir, + struct protid *cred, + int *amtread) { error_t err; - if (err = ioserver_get_conch (&ip->i_conch)) + err = ioserver_get_conch (&np->i_conch); + if (err) return err; - if (!(err = catch_exception ())) + if (dir) + while (off + amt > np->allocsize) + if (err = diskfs_grow (np, off + amt, cred)) + return err; + + if (off + amt > np->dn_stat.st_size) { if (dir) - while (off + amt > ip->i_allocsize) - if (err = file_extend (ip, off + amt, cred)) - return err; - - if (off + amt > ip->di->di_size) { - assert (dir); /* reads can't go past EOF internally */ - if (dir) - { - ip->di->di_size = off + amt; - ip->di->di_ctime = wallclock->seconds; - } + np->dn_stat.st_size = off + amt; + np->dn_set_ctime = 1; } - end_catch_exception (); + else + amt = np->dn_stat.st_size - off; } - if (err) - return err; - - err = io_rdwr (ip, data, off, amt, dir); + + err = _diskfs_rdwr_internal (np, data, off, amt, dir); + if (!err) + *amtread = amt; return err; } |