Re: [PATCH 6/11] eCryptfs: Update metadata read/write functions
On Wed, Sep 19, 2007 at 10:48:17PM -0700, Andrew Morton wrote: > On Mon, 17 Sep 2007 16:48:44 -0500 Michael Halcrow <[EMAIL PROTECTED]> wrote: > > + if ((rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, > > checkpatch missed the assignment-in-an-if here. Fix an assignment-in-an-if. Signed-off-by: Michael Halcrow <[EMAIL PROTECTED]> --- diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 4bf1a95..b3795f6 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -1306,8 +1306,9 @@ ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, int header_pages; int rc; - if ((rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, page_virt, - 0, PAGE_CACHE_SIZE))) { + rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, page_virt, + 0, PAGE_CACHE_SIZE); + if (rc) { printk(KERN_ERR "%s: Error attempting to write header " "information to lower file; rc = [%d]\n", __FUNCTION__, rc); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 6/11] eCryptfs: Update metadata read/write functions
On Wed, Sep 19, 2007 at 10:48:17PM -0700, Andrew Morton wrote: On Mon, 17 Sep 2007 16:48:44 -0500 Michael Halcrow [EMAIL PROTECTED] wrote: + if ((rc = ecryptfs_write_lower(ecryptfs_dentry-d_inode, checkpatch missed the assignment-in-an-if here. Fix an assignment-in-an-if. Signed-off-by: Michael Halcrow [EMAIL PROTECTED] --- diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 4bf1a95..b3795f6 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -1306,8 +1306,9 @@ ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, int header_pages; int rc; - if ((rc = ecryptfs_write_lower(ecryptfs_dentry-d_inode, page_virt, - 0, PAGE_CACHE_SIZE))) { + rc = ecryptfs_write_lower(ecryptfs_dentry-d_inode, page_virt, + 0, PAGE_CACHE_SIZE); + if (rc) { printk(KERN_ERR %s: Error attempting to write header information to lower file; rc = [%d]\n, __FUNCTION__, rc); - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 6/11] eCryptfs: Update metadata read/write functions
On Mon, 17 Sep 2007 16:48:44 -0500 Michael Halcrow <[EMAIL PROTECTED]> wrote: > + if ((rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, checkpatch missed the assignment-in-an-if here. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 6/11] eCryptfs: Update metadata read/write functions
On Mon, 17 Sep 2007 16:48:44 -0500 Michael Halcrow [EMAIL PROTECTED] wrote: + if ((rc = ecryptfs_write_lower(ecryptfs_dentry-d_inode, checkpatch missed the assignment-in-an-if here. - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 6/11] eCryptfs: Update metadata read/write functions
Update the metadata read/write functions and grow_file() to use the read_write.c routines. Do not open another lower file; use the persistent lower file instead. Provide a separate function for crypto.c::ecryptfs_read_xattr_region() to get to the lower xattr without having to go through the eCryptfs getxattr. Signed-off-by: Michael Halcrow <[EMAIL PROTECTED]> --- fs/ecryptfs/crypto.c | 126 +++-- fs/ecryptfs/ecryptfs_kernel.h | 15 +++-- fs/ecryptfs/file.c|2 +- fs/ecryptfs/inode.c | 101 +++-- fs/ecryptfs/mmap.c|2 +- 5 files changed, 113 insertions(+), 133 deletions(-) diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index d6a0680..6b4d310 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -1344,21 +1344,28 @@ out: return rc; } -int ecryptfs_read_and_validate_header_region(char *data, struct dentry *dentry, -struct vfsmount *mnt) +int ecryptfs_read_and_validate_header_region(char *data, +struct inode *ecryptfs_inode) { + struct ecryptfs_crypt_stat *crypt_stat = + &(ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat); int rc; - rc = ecryptfs_read_header_region(data, dentry, mnt); - if (rc) + rc = ecryptfs_read_lower(data, 0, crypt_stat->extent_size, +ecryptfs_inode); + if (rc) { + printk(KERN_ERR "%s: Error reading header region; rc = [%d]\n", + __FUNCTION__, rc); goto out; - if (!contains_ecryptfs_marker(data + ECRYPTFS_FILE_SIZE_BYTES)) + } + if (!contains_ecryptfs_marker(data + ECRYPTFS_FILE_SIZE_BYTES)) { rc = -EINVAL; + ecryptfs_printk(KERN_DEBUG, "Valid marker not found\n"); + } out: return rc; } - void ecryptfs_write_header_metadata(char *virt, struct ecryptfs_crypt_stat *crypt_stat, @@ -1443,24 +1450,18 @@ static int ecryptfs_write_headers_virt(char *page_virt, size_t *size, static int ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, - struct file *lower_file, char *page_virt) + struct dentry *ecryptfs_dentry, + char *page_virt) { - mm_segment_t oldfs; int current_header_page; int header_pages; - ssize_t size; - int rc = 0; + int rc; - lower_file->f_pos = 0; - oldfs = get_fs(); - set_fs(get_ds()); - size = vfs_write(lower_file, (char __user *)page_virt, PAGE_CACHE_SIZE, -_file->f_pos); - if (size < 0) { - rc = (int)size; - printk(KERN_ERR "Error attempting to write lower page; " - "rc = [%d]\n", rc); - set_fs(oldfs); + if ((rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, page_virt, + 0, PAGE_CACHE_SIZE))) { + printk(KERN_ERR "%s: Error attempting to write header " + "information to lower file; rc = [%d]\n", __FUNCTION__, + rc); goto out; } header_pages = ((crypt_stat->extent_size @@ -1469,18 +1470,19 @@ ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, memset(page_virt, 0, PAGE_CACHE_SIZE); current_header_page = 1; while (current_header_page < header_pages) { - size = vfs_write(lower_file, (char __user *)page_virt, -PAGE_CACHE_SIZE, _file->f_pos); - if (size < 0) { - rc = (int)size; - printk(KERN_ERR "Error attempting to write lower page; " - "rc = [%d]\n", rc); - set_fs(oldfs); + loff_t offset; + + offset = (current_header_page << PAGE_CACHE_SHIFT); + if ((rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, + page_virt, offset, + PAGE_CACHE_SIZE))) { + printk(KERN_ERR "%s: Error attempting to write header " + "information to lower file; rc = [%d]\n", + __FUNCTION__, rc); goto out; } current_header_page++; } - set_fs(oldfs); out: return rc; } @@ -1500,7 +1502,6 @@ ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, /** * ecryptfs_write_metadata * @ecryptfs_dentry: The eCryptfs dentry - * @lower_file: The lower file struct, which was returned from dentry_open * * Write the file headers out.
[PATCH 6/11] eCryptfs: Update metadata read/write functions
Update the metadata read/write functions and grow_file() to use the read_write.c routines. Do not open another lower file; use the persistent lower file instead. Provide a separate function for crypto.c::ecryptfs_read_xattr_region() to get to the lower xattr without having to go through the eCryptfs getxattr. Signed-off-by: Michael Halcrow [EMAIL PROTECTED] --- fs/ecryptfs/crypto.c | 126 +++-- fs/ecryptfs/ecryptfs_kernel.h | 15 +++-- fs/ecryptfs/file.c|2 +- fs/ecryptfs/inode.c | 101 +++-- fs/ecryptfs/mmap.c|2 +- 5 files changed, 113 insertions(+), 133 deletions(-) diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index d6a0680..6b4d310 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -1344,21 +1344,28 @@ out: return rc; } -int ecryptfs_read_and_validate_header_region(char *data, struct dentry *dentry, -struct vfsmount *mnt) +int ecryptfs_read_and_validate_header_region(char *data, +struct inode *ecryptfs_inode) { + struct ecryptfs_crypt_stat *crypt_stat = + (ecryptfs_inode_to_private(ecryptfs_inode)-crypt_stat); int rc; - rc = ecryptfs_read_header_region(data, dentry, mnt); - if (rc) + rc = ecryptfs_read_lower(data, 0, crypt_stat-extent_size, +ecryptfs_inode); + if (rc) { + printk(KERN_ERR %s: Error reading header region; rc = [%d]\n, + __FUNCTION__, rc); goto out; - if (!contains_ecryptfs_marker(data + ECRYPTFS_FILE_SIZE_BYTES)) + } + if (!contains_ecryptfs_marker(data + ECRYPTFS_FILE_SIZE_BYTES)) { rc = -EINVAL; + ecryptfs_printk(KERN_DEBUG, Valid marker not found\n); + } out: return rc; } - void ecryptfs_write_header_metadata(char *virt, struct ecryptfs_crypt_stat *crypt_stat, @@ -1443,24 +1450,18 @@ static int ecryptfs_write_headers_virt(char *page_virt, size_t *size, static int ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, - struct file *lower_file, char *page_virt) + struct dentry *ecryptfs_dentry, + char *page_virt) { - mm_segment_t oldfs; int current_header_page; int header_pages; - ssize_t size; - int rc = 0; + int rc; - lower_file-f_pos = 0; - oldfs = get_fs(); - set_fs(get_ds()); - size = vfs_write(lower_file, (char __user *)page_virt, PAGE_CACHE_SIZE, -lower_file-f_pos); - if (size 0) { - rc = (int)size; - printk(KERN_ERR Error attempting to write lower page; - rc = [%d]\n, rc); - set_fs(oldfs); + if ((rc = ecryptfs_write_lower(ecryptfs_dentry-d_inode, page_virt, + 0, PAGE_CACHE_SIZE))) { + printk(KERN_ERR %s: Error attempting to write header + information to lower file; rc = [%d]\n, __FUNCTION__, + rc); goto out; } header_pages = ((crypt_stat-extent_size @@ -1469,18 +1470,19 @@ ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, memset(page_virt, 0, PAGE_CACHE_SIZE); current_header_page = 1; while (current_header_page header_pages) { - size = vfs_write(lower_file, (char __user *)page_virt, -PAGE_CACHE_SIZE, lower_file-f_pos); - if (size 0) { - rc = (int)size; - printk(KERN_ERR Error attempting to write lower page; - rc = [%d]\n, rc); - set_fs(oldfs); + loff_t offset; + + offset = (current_header_page PAGE_CACHE_SHIFT); + if ((rc = ecryptfs_write_lower(ecryptfs_dentry-d_inode, + page_virt, offset, + PAGE_CACHE_SIZE))) { + printk(KERN_ERR %s: Error attempting to write header + information to lower file; rc = [%d]\n, + __FUNCTION__, rc); goto out; } current_header_page++; } - set_fs(oldfs); out: return rc; } @@ -1500,7 +1502,6 @@ ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, /** * ecryptfs_write_metadata * @ecryptfs_dentry: The eCryptfs dentry - * @lower_file: The lower file struct, which was returned from dentry_open * * Write the file headers out. This will likely involve a