realpath.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /* Check memory quota. */
  34. bool tomoyo_memory_ok(void *ptr);
  35. /*
  36. * Keep the given name on the RAM.
  37. * The RAM is shared, so NEVER try to modify or kfree() the returned name.
  38. */
  39. const struct tomoyo_path_info *tomoyo_save_name(const char *name);
  40. /* Allocate memory for temporary use (e.g. permission checks). */
  41. void *tomoyo_alloc(const size_t size);
  42. /* Free memory allocated by tomoyo_alloc(). */
  43. void tomoyo_free(const void *p);
  44. /* Check for memory usage. */
  45. int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head);
  46. /* Set memory quota. */
  47. int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head);
  48. /* Initialize realpath related code. */
  49. void __init tomoyo_realpath_init(void);
  50. #endif /* !defined(_SECURITY_TOMOYO_REALPATH_H) */