static void ntfs_getuser_update_vm (void *dest, ntfs_io *src, ntfs_size_t len) { struct ntfs_getuser_update_vm_s *p = src->param; copy_from_user (dest, p->user, len); update_vm_cache (p->ino, p->off, dest, len); p->user += len; p->off += len; }
static int minix_file_write(struct inode * inode, struct file * filp, const char * buf, int count) { off_t pos; int written,c; struct buffer_head * bh; char * p; if (!inode) { printk("minix_file_write: inode = NULL\n"); return -EINVAL; } if (!S_ISREG(inode->i_mode)) { printk("minix_file_write: mode = %07o\n",inode->i_mode); return -EINVAL; } if (filp->f_flags & O_APPEND) pos = inode->i_size; else pos = filp->f_pos; written = 0; while (written < count) { bh = minix_getblk(inode,pos/BLOCK_SIZE,1); if (!bh) { if (!written) written = -ENOSPC; break; } c = BLOCK_SIZE - (pos % BLOCK_SIZE); if (c > count-written) c = count-written; if (c != BLOCK_SIZE && !buffer_uptodate(bh)) { ll_rw_block(READ, 1, &bh); wait_on_buffer(bh); if (!buffer_uptodate(bh)) { brelse(bh); if (!written) written = -EIO; break; } } p = (pos % BLOCK_SIZE) + bh->b_data; memcpy_fromfs(p,buf,c); update_vm_cache(inode, pos, p, c); mark_buffer_uptodate(bh, 1); mark_buffer_dirty(bh, 0); brelse(bh); pos += c; written += c; buf += c; } if (pos > inode->i_size) inode->i_size = pos; inode->i_mtime = inode->i_ctime = CURRENT_TIME; filp->f_pos = pos; inode->i_dirt = 1; return written; }
static int bext2_file_write (struct inode * inode, struct file * filp, const char * buf, int count) { const loff_t two_gb = 2147483647; loff_t pos; off_t pos2; long block; int offset; int written, c; struct buffer_head * bh, *bufferlist[NBUF]; struct super_block * sb; int err; int i,buffercount,write_error; write_error = buffercount = 0; if (!inode) { printk("bext2_file_write: inode = NULL\n"); return -EINVAL; } sb = inode->i_sb; if (sb->s_flags & MS_RDONLY) /* * This fs has been automatically remounted ro because of errors */ return -ENOSPC; if (!S_ISREG(inode->i_mode)) { bext2_warning (sb, "bext2_file_write", "mode = %07o", inode->i_mode); return -EINVAL; } if (filp->f_flags & O_APPEND) pos = inode->i_size; else pos = filp->f_pos; pos2 = (off_t) pos; /* * If a file has been opened in synchronous mode, we have to ensure * that meta-data will also be written synchronously. Thus, we * set the i_osync field. This field is tested by the allocation * routines. */ if (filp->f_flags & O_SYNC) inode->u.ext2_i.i_osync++; block = pos2 >> EXT2_BLOCK_SIZE_BITS(sb); offset = pos2 & (sb->s_blocksize - 1); c = sb->s_blocksize - offset; written = 0; while (count > 0) { if (pos > two_gb) { if (!written) written = -EFBIG; break; } bh = bext2_getblk (inode, block, 1, &err); if (!bh) { if (!written) written = err; break; } count -= c; if (count < 0) c += count; if (c != sb->s_blocksize && !buffer_uptodate(bh)) { ll_rw_block (READ, 1, &bh); wait_on_buffer (bh); if (!buffer_uptodate(bh)) { brelse (bh); if (!written) written = -EIO; break; } } memcpy_fromfs (bh->b_data + offset, buf, c); update_vm_cache(inode, pos, bh->b_data + offset, c); pos2 += c; pos += c; written += c; buf += c; mark_buffer_uptodate(bh, 1); mark_buffer_dirty(bh, 0); if (filp->f_flags & O_SYNC) bufferlist[buffercount++] = bh; else brelse(bh); if (buffercount == NBUF){ ll_rw_block(WRITE, buffercount, bufferlist); for(i=0; i<buffercount; i++){ wait_on_buffer(bufferlist[i]); if (!buffer_uptodate(bufferlist[i])) write_error=1; brelse(bufferlist[i]); } buffercount=0; } if(write_error) break; block++; offset = 0; c = sb->s_blocksize; } if ( buffercount ){ ll_rw_block(WRITE, buffercount, bufferlist); for(i=0; i<buffercount; i++){ wait_on_buffer(bufferlist[i]); if (!buffer_uptodate(bufferlist[i])) write_error=1; brelse(bufferlist[i]); } } if (pos > inode->i_size) inode->i_size = pos; if (filp->f_flags & O_SYNC) inode->u.ext2_i.i_osync--; inode->i_ctime = inode->i_mtime = CURRENT_TIME; filp->f_pos = pos; inode->i_dirt = 1; return written; }
static ssize_t affs_file_write_ofs(struct file *filp, const char *buf, size_t count, loff_t *ppos) { struct inode *inode = filp->f_dentry->d_inode; off_t pos; ssize_t written; ssize_t c; ssize_t blocksize; struct buffer_head *bh; char *p; pr_debug("AFFS: file_write_ofs(ino=%lu,pos=%lu,count=%d)\n",inode->i_ino, (unsigned long)*ppos,count); if (!count) return 0; if (!inode) { affs_error(inode->i_sb,"file_write_ofs","Inode = NULL"); return -EINVAL; } if (!S_ISREG(inode->i_mode)) { affs_error(inode->i_sb,"file_write_ofs", "Trying to write to non-regular file (mode=%07o)", inode->i_mode); return -EINVAL; } if (!inode->u.affs_i.i_ec && alloc_ext_cache(inode)) return -ENOMEM; if (filp->f_flags & O_APPEND) pos = inode->i_size; else pos = *ppos; bh = NULL; blocksize = AFFS_I2BSIZE(inode) - 24; written = 0; while (written < count) { bh = affs_getblock(inode,pos / blocksize); if (!bh) { if (!written) written = -ENOSPC; break; } c = blocksize - (pos % blocksize); if (c > count - written) c = count - written; if (c != blocksize && !buffer_uptodate(bh)) { ll_rw_block(READ,1,&bh); wait_on_buffer(bh); if (!buffer_uptodate(bh)) { affs_brelse(bh); if (!written) written = -EIO; break; } } p = (pos % blocksize) + bh->b_data + 24; c -= copy_from_user(p,buf,c); if (!c) { affs_brelse(bh); if (!written) written = -EFAULT; break; } update_vm_cache(inode,pos,p,c); pos += c; buf += c; written += c; DATA_FRONT(bh)->data_size = cpu_to_be32(be32_to_cpu(DATA_FRONT(bh)->data_size) + c); affs_fix_checksum(AFFS_I2BSIZE(inode),bh->b_data,5); mark_buffer_uptodate(bh,1); mark_buffer_dirty(bh,0); affs_brelse(bh); } if (pos > inode->i_size) inode->i_size = pos; *ppos = pos; inode->i_mtime = inode->i_ctime = CURRENT_TIME; mark_inode_dirty(inode); return written; }