LCOV - code coverage report
Current view: top level - zephyr/drivers - loopback_disk.h Hit Total Coverage
Test: new.info Lines: 3 8 37.5 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           0 : /*
       2             :  * Copyright (c) 2023 Embedded Solutions GmbH
       3             :  *
       4             :  * SPDX-License-Identifier: Apache-2.0
       5             :  */
       6             : 
       7             : #ifndef ZEPHYR_INCLUDE_DRIVERS_LOOPBACK_DISK_ACCESS_H_
       8             : #define ZEPHYR_INCLUDE_DRIVERS_LOOPBACK_DISK_ACCESS_H_
       9             : 
      10             : #include <zephyr/drivers/disk.h>
      11             : #include <zephyr/fs/fs_interface.h>
      12             : 
      13             : /**
      14             :  * @brief Context object for an active loopback disk device
      15             :  */
      16           1 : struct loopback_disk_access {
      17           0 :         struct disk_info info;
      18           0 :         const char *file_path;
      19           0 :         struct fs_file_t file;
      20           0 :         size_t num_sectors;
      21             : };
      22             : 
      23             : /**
      24             :  * @brief Register a loopback disk device
      25             :  *
      26             :  * Registers a new loopback disk deviced backed by a file at the specified path.
      27             :  *
      28             :  * @details
      29             :  * @p All parameters (ctx, file_path and disk_access_name) must point to data that will remain valid
      30             :  * until the disk access is unregistered. This is trivially true for file_path and disk_access_name
      31             :  * if they are string literals, but care must be taken for ctx, as well as for file_path and
      32             :  * disk_access_name if they are constructed dynamically.
      33             :  *
      34             :  * @param ctx Preallocated context structure
      35             :  * @param file_path Path to backing file
      36             :  * @param disk_access_name Name of the created disk access (for disk_access_*() functions)
      37             :  *
      38             :  * @retval 0 on success;
      39             :  * @retval <0 negative errno code, depending on file system of the backing file.
      40             :  */
      41           1 : int loopback_disk_access_register(struct loopback_disk_access *ctx, const char *file_path,
      42             :                                   const char *disk_access_name);
      43             : 
      44             : /**
      45             :  * @brief Unregister a previously registered loopback disk device
      46             :  *
      47             :  * Cleans up resources used by the disk access.
      48             :  *
      49             :  * @param ctx Context structure previously passed to a successful invocation of
      50             :  * loopback_disk_access_register()
      51             :  *
      52             :  * @retval 0 on success;
      53             :  * @retval <0 negative errno code, depending on file system of the backing file.
      54             :  */
      55           1 : int loopback_disk_access_unregister(struct loopback_disk_access *ctx);
      56             : 
      57             : #endif /* ZEPHYR_INCLUDE_DRIVERS_LOOPBACK_DISK_ACCESS_H_ */

Generated by: LCOV version 1.14