diff options
author | Michael Halcrow <mhalcrow@us.ibm.com> | 2007-02-12 03:53:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-12 12:48:36 -0500 |
commit | dd2a3b7ad98f8482cae481cad89dfed5eee48365 (patch) | |
tree | 986c09754176ea4c6e8308c6e2cdbf3fc0658a0b /fs/ecryptfs/ecryptfs_kernel.h | |
parent | 17398957aa0a05ef62535060b41d103590dcc533 (diff) |
[PATCH] eCryptfs: Generalize metadata read/write
Generalize the metadata reading and writing mechanisms, with two targets for
now: metadata in file header and metadata in the user.ecryptfs xattr of the
lower file.
[akpm@osdl.org: printk warning fix]
[bunk@stusta.de: make some needlessly global code static]
Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ecryptfs/ecryptfs_kernel.h')
-rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index 7bbd6e6e2743..020abcd16f0e 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 1997-2003 Erez Zadok | 5 | * Copyright (C) 1997-2003 Erez Zadok |
6 | * Copyright (C) 2001-2003 Stony Brook University | 6 | * Copyright (C) 2001-2003 Stony Brook University |
7 | * Copyright (C) 2004-2006 International Business Machines Corp. | 7 | * Copyright (C) 2004-2007 International Business Machines Corp. |
8 | * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> | 8 | * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> |
9 | * Trevor S. Highland <trevor.highland@gmail.com> | 9 | * Trevor S. Highland <trevor.highland@gmail.com> |
10 | * Tyler Hicks <tyhicks@ou.edu> | 10 | * Tyler Hicks <tyhicks@ou.edu> |
@@ -50,8 +50,8 @@ | |||
50 | #define ECRYPTFS_VERSIONING_XATTR 0x00000010 | 50 | #define ECRYPTFS_VERSIONING_XATTR 0x00000010 |
51 | #define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE \ | 51 | #define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE \ |
52 | | ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH \ | 52 | | ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH \ |
53 | | ECRYPTFS_VERSIONING_PUBKEY) | 53 | | ECRYPTFS_VERSIONING_PUBKEY \ |
54 | 54 | | ECRYPTFS_VERSIONING_XATTR) | |
55 | #define ECRYPTFS_MAX_PASSWORD_LENGTH 64 | 55 | #define ECRYPTFS_MAX_PASSWORD_LENGTH 64 |
56 | #define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH | 56 | #define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH |
57 | #define ECRYPTFS_SALT_SIZE 8 | 57 | #define ECRYPTFS_SALT_SIZE 8 |
@@ -83,6 +83,7 @@ | |||
83 | #define ECRYPTFS_TRANSPORT_CONNECTOR 1 | 83 | #define ECRYPTFS_TRANSPORT_CONNECTOR 1 |
84 | #define ECRYPTFS_TRANSPORT_RELAYFS 2 | 84 | #define ECRYPTFS_TRANSPORT_RELAYFS 2 |
85 | #define ECRYPTFS_DEFAULT_TRANSPORT ECRYPTFS_TRANSPORT_NETLINK | 85 | #define ECRYPTFS_DEFAULT_TRANSPORT ECRYPTFS_TRANSPORT_NETLINK |
86 | #define ECRYPTFS_XATTR_NAME "user.ecryptfs" | ||
86 | 87 | ||
87 | #define RFC2440_CIPHER_DES3_EDE 0x02 | 88 | #define RFC2440_CIPHER_DES3_EDE 0x02 |
88 | #define RFC2440_CIPHER_CAST_5 0x03 | 89 | #define RFC2440_CIPHER_CAST_5 0x03 |
@@ -327,18 +328,6 @@ struct ecryptfs_msg_ctx { | |||
327 | struct mutex mux; | 328 | struct mutex mux; |
328 | }; | 329 | }; |
329 | 330 | ||
330 | extern struct list_head ecryptfs_msg_ctx_free_list; | ||
331 | extern struct list_head ecryptfs_msg_ctx_alloc_list; | ||
332 | extern struct mutex ecryptfs_msg_ctx_lists_mux; | ||
333 | |||
334 | #define ecryptfs_uid_hash(uid) \ | ||
335 | hash_long((unsigned long)uid, ecryptfs_hash_buckets) | ||
336 | extern struct hlist_head *ecryptfs_daemon_id_hash; | ||
337 | extern struct mutex ecryptfs_daemon_id_hash_mux; | ||
338 | extern int ecryptfs_hash_buckets; | ||
339 | |||
340 | extern unsigned int ecryptfs_msg_counter; | ||
341 | extern struct ecryptfs_msg_ctx *ecryptfs_msg_ctx_arr; | ||
342 | extern unsigned int ecryptfs_transport; | 331 | extern unsigned int ecryptfs_transport; |
343 | 332 | ||
344 | struct ecryptfs_daemon_id { | 333 | struct ecryptfs_daemon_id { |
@@ -479,6 +468,7 @@ extern struct kmem_cache *ecryptfs_sb_info_cache; | |||
479 | extern struct kmem_cache *ecryptfs_header_cache_0; | 468 | extern struct kmem_cache *ecryptfs_header_cache_0; |
480 | extern struct kmem_cache *ecryptfs_header_cache_1; | 469 | extern struct kmem_cache *ecryptfs_header_cache_1; |
481 | extern struct kmem_cache *ecryptfs_header_cache_2; | 470 | extern struct kmem_cache *ecryptfs_header_cache_2; |
471 | extern struct kmem_cache *ecryptfs_xattr_cache; | ||
482 | extern struct kmem_cache *ecryptfs_lower_page_cache; | 472 | extern struct kmem_cache *ecryptfs_lower_page_cache; |
483 | 473 | ||
484 | int ecryptfs_interpose(struct dentry *hidden_dentry, | 474 | int ecryptfs_interpose(struct dentry *hidden_dentry, |
@@ -505,9 +495,13 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat); | |||
505 | int ecryptfs_crypto_api_algify_cipher_name(char **algified_name, | 495 | int ecryptfs_crypto_api_algify_cipher_name(char **algified_name, |
506 | char *cipher_name, | 496 | char *cipher_name, |
507 | char *chaining_modifier); | 497 | char *chaining_modifier); |
508 | int ecryptfs_write_inode_size_to_header(struct file *lower_file, | 498 | #define ECRYPTFS_LOWER_I_MUTEX_NOT_HELD 0 |
509 | struct inode *lower_inode, | 499 | #define ECRYPTFS_LOWER_I_MUTEX_HELD 1 |
510 | struct inode *inode); | 500 | int ecryptfs_write_inode_size_to_metadata(struct file *lower_file, |
501 | struct inode *lower_inode, | ||
502 | struct inode *inode, | ||
503 | struct dentry *ecryptfs_dentry, | ||
504 | int lower_i_mutex_held); | ||
511 | int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode, | 505 | int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode, |
512 | struct file *lower_file, | 506 | struct file *lower_file, |
513 | unsigned long lower_page_index, int byte_offset, | 507 | unsigned long lower_page_index, int byte_offset, |
@@ -529,17 +523,15 @@ int ecryptfs_writepage_and_release_lower_page(struct page *lower_page, | |||
529 | struct writeback_control *wbc); | 523 | struct writeback_control *wbc); |
530 | int ecryptfs_encrypt_page(struct ecryptfs_page_crypt_context *ctx); | 524 | int ecryptfs_encrypt_page(struct ecryptfs_page_crypt_context *ctx); |
531 | int ecryptfs_decrypt_page(struct file *file, struct page *page); | 525 | int ecryptfs_decrypt_page(struct file *file, struct page *page); |
532 | int ecryptfs_write_headers(struct dentry *ecryptfs_dentry, | 526 | int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry, |
527 | struct file *lower_file); | ||
528 | int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry, | ||
533 | struct file *lower_file); | 529 | struct file *lower_file); |
534 | int ecryptfs_write_headers_virt(char *page_virt, | ||
535 | struct ecryptfs_crypt_stat *crypt_stat, | ||
536 | struct dentry *ecryptfs_dentry); | ||
537 | int ecryptfs_read_headers(struct dentry *ecryptfs_dentry, | ||
538 | struct file *lower_file); | ||
539 | int ecryptfs_new_file_context(struct dentry *ecryptfs_dentry); | 530 | int ecryptfs_new_file_context(struct dentry *ecryptfs_dentry); |
540 | int contains_ecryptfs_marker(char *data); | 531 | int ecryptfs_read_and_validate_header_region(char *data, struct dentry *dentry, |
541 | int ecryptfs_read_header_region(char *data, struct dentry *dentry, | 532 | struct vfsmount *mnt); |
542 | struct vfsmount *mnt); | 533 | int ecryptfs_read_and_validate_xattr_region(char *page_virt, |
534 | struct dentry *ecryptfs_dentry); | ||
543 | u16 ecryptfs_code_for_cipher_string(struct ecryptfs_crypt_stat *crypt_stat); | 535 | u16 ecryptfs_code_for_cipher_string(struct ecryptfs_crypt_stat *crypt_stat); |
544 | int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code); | 536 | int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code); |
545 | void ecryptfs_set_default_sizes(struct ecryptfs_crypt_stat *crypt_stat); | 537 | void ecryptfs_set_default_sizes(struct ecryptfs_crypt_stat *crypt_stat); |
@@ -562,6 +554,11 @@ int ecryptfs_open_lower_file(struct file **lower_file, | |||
562 | struct dentry *lower_dentry, | 554 | struct dentry *lower_dentry, |
563 | struct vfsmount *lower_mnt, int flags); | 555 | struct vfsmount *lower_mnt, int flags); |
564 | int ecryptfs_close_lower_file(struct file *lower_file); | 556 | int ecryptfs_close_lower_file(struct file *lower_file); |
557 | ssize_t ecryptfs_getxattr(struct dentry *dentry, const char *name, void *value, | ||
558 | size_t size); | ||
559 | int | ||
560 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | ||
561 | size_t size, int flags); | ||
565 | 562 | ||
566 | int ecryptfs_process_helo(unsigned int transport, uid_t uid, pid_t pid); | 563 | int ecryptfs_process_helo(unsigned int transport, uid_t uid, pid_t pid); |
567 | int ecryptfs_process_quit(uid_t uid, pid_t pid); | 564 | int ecryptfs_process_quit(uid_t uid, pid_t pid); |