diff options
author | Michael I. Bushnell <mib@gnu.org> | 1994-02-03 19:29:45 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1994-02-03 19:29:45 +0000 |
commit | 01f5f99c33e9703ecddbc07553e9fb63515ad293 (patch) | |
tree | 24e3346354a23d51ada720b0ed359825d2a740ea /libdiskfs/node-rdwr.c | |
parent | 1043ca2e762f34a40bc8c7eaeaf2332e4cdea71a (diff) |
Formerly node-rdwr.c.~2~
Diffstat (limited to 'libdiskfs/node-rdwr.c')
-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; } |