Kentaro Takeda | c73bd6d | 2009-02-05 17:18:12 +0900 | [diff] [blame] | 1 | /* |
| 2 | * security/tomoyo/realpath.h |
| 3 | * |
| 4 | * Get the canonicalized absolute pathnames. The basis for TOMOYO. |
| 5 | * |
| 6 | * Copyright (C) 2005-2009 NTT DATA CORPORATION |
| 7 | * |
Tetsuo Handa | 39826a1 | 2009-04-08 22:31:28 +0900 | [diff] [blame] | 8 | * Version: 2.2.0 2009/04/01 |
Kentaro Takeda | c73bd6d | 2009-02-05 17:18:12 +0900 | [diff] [blame] | 9 | * |
| 10 | */ |
| 11 | |
| 12 | #ifndef _SECURITY_TOMOYO_REALPATH_H |
| 13 | #define _SECURITY_TOMOYO_REALPATH_H |
| 14 | |
| 15 | struct path; |
| 16 | struct tomoyo_path_info; |
| 17 | struct tomoyo_io_buffer; |
| 18 | |
| 19 | /* Convert binary string to ascii string. */ |
| 20 | int tomoyo_encode(char *buffer, int buflen, const char *str); |
| 21 | |
| 22 | /* Returns realpath(3) of the given pathname but ignores chroot'ed root. */ |
| 23 | int tomoyo_realpath_from_path2(struct path *path, char *newname, |
| 24 | int newname_len); |
| 25 | |
| 26 | /* |
| 27 | * Returns realpath(3) of the given pathname but ignores chroot'ed root. |
| 28 | * These functions use tomoyo_alloc(), so the caller must call tomoyo_free() |
| 29 | * if these functions didn't return NULL. |
| 30 | */ |
| 31 | char *tomoyo_realpath(const char *pathname); |
| 32 | /* |
| 33 | * Same with tomoyo_realpath() except that it doesn't follow the final symlink. |
| 34 | */ |
| 35 | char *tomoyo_realpath_nofollow(const char *pathname); |
| 36 | /* Same with tomoyo_realpath() except that the pathname is already solved. */ |
| 37 | char *tomoyo_realpath_from_path(struct path *path); |
| 38 | |
| 39 | /* |
| 40 | * Allocate memory for ACL entry. |
| 41 | * The RAM is chunked, so NEVER try to kfree() the returned pointer. |
| 42 | */ |
| 43 | void *tomoyo_alloc_element(const unsigned int size); |
| 44 | |
| 45 | /* |
| 46 | * Keep the given name on the RAM. |
| 47 | * The RAM is shared, so NEVER try to modify or kfree() the returned name. |
| 48 | */ |
| 49 | const struct tomoyo_path_info *tomoyo_save_name(const char *name); |
| 50 | |
| 51 | /* Allocate memory for temporary use (e.g. permission checks). */ |
| 52 | void *tomoyo_alloc(const size_t size); |
| 53 | |
| 54 | /* Free memory allocated by tomoyo_alloc(). */ |
| 55 | void tomoyo_free(const void *p); |
| 56 | |
| 57 | /* Check for memory usage. */ |
| 58 | int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head); |
| 59 | |
| 60 | /* Set memory quota. */ |
| 61 | int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head); |
| 62 | |
Tetsuo Handa | 1581e7d | 2009-02-21 20:40:50 +0900 | [diff] [blame] | 63 | /* Initialize realpath related code. */ |
| 64 | void __init tomoyo_realpath_init(void); |
| 65 | |
Kentaro Takeda | c73bd6d | 2009-02-05 17:18:12 +0900 | [diff] [blame] | 66 | #endif /* !defined(_SECURITY_TOMOYO_REALPATH_H) */ |