file.c (c376222960ae91d5ffb9197ee36771aaed1d9f90) file.c (dd2a3b7ad98f8482cae481cad89dfed5eee48365)
1/**
2 * eCryptfs: Linux filesystem encryption layer
3 *
4 * Copyright (C) 1997-2004 Erez Zadok
5 * Copyright (C) 2001-2004 Stony Brook University
1/**
2 * eCryptfs: Linux filesystem encryption layer
3 *
4 * Copyright (C) 1997-2004 Erez Zadok
5 * Copyright (C) 2001-2004 Stony Brook University
6 * Copyright (C) 2004-2006 International Business Machines Corp.
6 * Copyright (C) 2004-2007 International Business Machines Corp.
7 * Author(s): Michael A. Halcrow <mhalcrow@us.ibm.com>
8 * Michael C. Thompson <mcthomps@us.ibm.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
14 *

--- 273 unchanged lines hidden (view full) ---

288 lower_inode = lower_dentry->d_inode;
289 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) {
290 ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
291 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED);
292 rc = 0;
293 goto out;
294 }
295 mutex_lock(&crypt_stat->cs_mutex);
7 * Author(s): Michael A. Halcrow <mhalcrow@us.ibm.com>
8 * Michael C. Thompson <mcthomps@us.ibm.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of the
13 * License, or (at your option) any later version.
14 *

--- 273 unchanged lines hidden (view full) ---

288 lower_inode = lower_dentry->d_inode;
289 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) {
290 ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
291 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED);
292 rc = 0;
293 goto out;
294 }
295 mutex_lock(&crypt_stat->cs_mutex);
296 if (i_size_read(lower_inode) < ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE) {
297 if (!(mount_crypt_stat->flags
298 & ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)) {
299 rc = -EIO;
300 printk(KERN_WARNING "Attempt to read file that is "
301 "not in a valid eCryptfs format, and plaintext "
302 "passthrough mode is not enabled; returning "
303 "-EIO\n");
304 mutex_unlock(&crypt_stat->cs_mutex);
305 goto out_puts;
306 }
307 crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
308 rc = 0;
309 mutex_unlock(&crypt_stat->cs_mutex);
310 goto out;
311 } else if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags,
312 ECRYPTFS_POLICY_APPLIED)
313 || !ECRYPTFS_CHECK_FLAG(crypt_stat->flags,
314 ECRYPTFS_KEY_VALID)) {
315 rc = ecryptfs_read_headers(ecryptfs_dentry, lower_file);
296 if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags,
297 ECRYPTFS_POLICY_APPLIED)
298 || !ECRYPTFS_CHECK_FLAG(crypt_stat->flags,
299 ECRYPTFS_KEY_VALID)) {
300 rc = ecryptfs_read_metadata(ecryptfs_dentry, lower_file);
316 if (rc) {
317 ecryptfs_printk(KERN_DEBUG,
318 "Valid headers not found\n");
319 if (!(mount_crypt_stat->flags
320 & ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)) {
321 rc = -EIO;
322 printk(KERN_WARNING "Attempt to read file that "
323 "is not in a valid eCryptfs format, "

--- 145 unchanged lines hidden ---
301 if (rc) {
302 ecryptfs_printk(KERN_DEBUG,
303 "Valid headers not found\n");
304 if (!(mount_crypt_stat->flags
305 & ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)) {
306 rc = -EIO;
307 printk(KERN_WARNING "Attempt to read file that "
308 "is not in a valid eCryptfs format, "

--- 145 unchanged lines hidden ---