realpath.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. *
  8. * Version: 2.2.0 2009/04/01
  9. *
  10. */
  11. #ifndef _SECURITY_TOMOYO_REALPATH_H
  12. #define _SECURITY_TOMOYO_REALPATH_H
  13. struct path;
  14. struct tomoyo_path_info;
  15. struct tomoyo_io_buffer;
  16. /* Convert binary string to ascii string. */
  17. int tomoyo_encode(char *buffer, int buflen, const char *str);
  18. /* Returns realpath(3) of the given pathname but ignores chroot'ed root. */
  19. int tomoyo_realpath_from_path2(struct path *path, char *newname,
  20. int newname_len);
  21. /*
  22. * Returns realpath(3) of the given pathname but ignores chroot'ed root.
  23. * These functions use tomoyo_alloc(), so the caller must call tomoyo_free()
  24. * if these functions didn't return NULL.
  25. */
  26. char *tomoyo_realpath(const char *pathname);
  27. /*
  28. * Same with tomoyo_realpath() except that it doesn't follow the final symlink.
  29. */
  30. char *tomoyo_realpath_nofollow(const char *pathname);
  31. /* Same with tomoyo_realpath() except that the pathname is already solved. */
  32. char *tomoyo_realpath_from_path(struct path *path);
  33. /*
  34. * Allocate memory for ACL entry.
  35. * The RAM is chunked, so NEVER try to kfree() the returned pointer.
  36. */
  37. void *tomoyo_alloc_element(const unsigned int size);
  38. /*
  39. * Keep the given name on the RAM.
  40. * The RAM is shared, so NEVER try to modify or kfree() the returned name.
  41. */
  42. const struct tomoyo_path_info *tomoyo_save_name(const char *name);
  43. /* Allocate memory for temporary use (e.g. permission checks). */
  44. void *tomoyo_alloc(const size_t size);
  45. /* Free memory allocated by tomoyo_alloc(). */
  46. void tomoyo_free(const void *p);
  47. /* Check for memory usage. */
  48. int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
  49. /* Set memory quota. */
  50. int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
  51. /* Initialize realpath related code. */
  52. void __init tomoyo_realpath_init(void);
  53. #endif /* !defined(_SECURITY_TOMOYO_REALPATH_H) */