File.cpp 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/StringView.h>
  7. #include <Kernel/FileSystem/File.h>
  8. #include <Kernel/FileSystem/FileDescription.h>
  9. namespace Kernel {
  10. File::File()
  11. {
  12. }
  13. File::~File()
  14. {
  15. }
  16. KResultOr<NonnullRefPtr<FileDescription>> File::open(int options)
  17. {
  18. auto description = FileDescription::create(*this);
  19. if (!description.is_error()) {
  20. description.value()->set_rw_mode(options);
  21. description.value()->set_file_flags(options);
  22. }
  23. return description;
  24. }
  25. KResult File::close()
  26. {
  27. return KSuccess;
  28. }
  29. int File::ioctl(FileDescription&, unsigned, FlatPtr)
  30. {
  31. return -ENOTTY;
  32. }
  33. KResultOr<Region*> File::mmap(Process&, FileDescription&, const Range&, u64, int, bool)
  34. {
  35. return ENODEV;
  36. }
  37. KResult File::attach(FileDescription&)
  38. {
  39. m_attach_count++;
  40. return KSuccess;
  41. }
  42. void File::detach(FileDescription&)
  43. {
  44. m_attach_count--;
  45. }
  46. }