1 /* 2 * A resource offering support for accessing directories. 3 * 4 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include <ipc/cap_alloc.h> 23 24 #include "directory_resource.h" 25 #include "directory_object_server.h" 26 27 28 29 int DirectoryResource::expected_items() 30 { 31 return DirectoryObject_expected_items; 32 } 33 34 ipc_server_handler_type DirectoryResource::handler() 35 { 36 return (ipc_server_handler_type) handle_DirectoryObject; 37 } 38 39 40 41 /* Open a directory to read the directory entries via a file-like object. */ 42 43 long DirectoryResource::opendir(flags_t flags, offset_t *size, 44 l4_cap_idx_t *file, object_flags_t *object_flags) 45 { 46 /* Invoke the specialised directory opening method. */ 47 48 long err = _opendir(flags, size, file, object_flags); 49 50 /* Handle propagated capabilities. By indicating the special status, the 51 operation is first completed and then the capability is discarded. */ 52 53 if (err == IPC_MESSAGE_SENT) 54 { 55 complete_DirectoryObject_open(*size, *file, *object_flags); 56 ipc_cap_free_um(*file); 57 return IPC_MESSAGE_SENT; 58 } 59 60 return err; 61 } 62 63 // vim: tabstop=4 expandtab shiftwidth=4