LCOV - code coverage report
Current view: top level - spdk/app/iscsi_tgt - iscsi_tgt.c (source / functions) Hit Total Coverage
Test: Combined Lines: 14 32 43.8 %
Date: 2024-07-16 01:00:24 Functions: 2 4 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 16 31.2 %

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2016 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "spdk/stdinc.h"
       7                 :            : 
       8                 :            : #include "spdk/env.h"
       9                 :            : #include "spdk/event.h"
      10                 :            : #include "iscsi/iscsi.h"
      11                 :            : #include "spdk/log.h"
      12                 :            : 
      13                 :            : static int g_daemon_mode = 0;
      14                 :            : 
      15                 :            : static void
      16                 :          0 : iscsi_usage(void)
      17                 :            : {
      18         [ #  # ]:          0 :         printf(" -b                        run iscsi target background, the default is foreground\n");
      19                 :          0 : }
      20                 :            : 
      21                 :            : static void
      22                 :         46 : spdk_startup(void *arg1)
      23                 :            : {
      24   [ -  +  -  + ]:         46 :         if (getenv("MEMZONE_DUMP") != NULL) {
      25                 :          0 :                 spdk_memzone_dump(stdout);
      26                 :          0 :                 fflush(stdout);
      27                 :            :         }
      28                 :         46 : }
      29                 :            : 
      30                 :            : static int
      31                 :          0 : iscsi_parse_arg(int ch, char *arg)
      32                 :            : {
      33         [ #  # ]:          0 :         switch (ch) {
      34                 :          0 :         case 'b':
      35                 :          0 :                 g_daemon_mode = 1;
      36                 :          0 :                 break;
      37                 :          0 :         default:
      38                 :          0 :                 return -EINVAL;
      39                 :            :         }
      40                 :          0 :         return 0;
      41                 :            : }
      42                 :            : 
      43                 :            : int
      44                 :         46 : main(int argc, char **argv)
      45                 :            : {
      46                 :            :         int rc;
      47                 :         46 :         struct spdk_app_opts opts = {};
      48                 :            : 
      49                 :         46 :         spdk_app_opts_init(&opts, sizeof(opts));
      50                 :         46 :         opts.name = "iscsi";
      51         [ -  + ]:         46 :         if ((rc = spdk_app_parse_args(argc, argv, &opts, "b", NULL,
      52                 :            :                                       iscsi_parse_arg, iscsi_usage)) !=
      53                 :            :             SPDK_APP_PARSE_ARGS_SUCCESS) {
      54                 :          0 :                 exit(rc);
      55                 :            :         }
      56                 :            : 
      57         [ -  + ]:         46 :         if (g_daemon_mode) {
      58         [ #  # ]:          0 :                 if (daemon(1, 0) < 0) {
      59                 :          0 :                         SPDK_ERRLOG("Start iscsi target daemon failed.\n");
      60                 :          0 :                         exit(EXIT_FAILURE);
      61                 :            :                 }
      62                 :            :         }
      63                 :            : 
      64                 :         46 :         opts.shutdown_cb = NULL;
      65                 :            : 
      66                 :            :         /* Blocks until the application is exiting */
      67                 :         46 :         rc = spdk_app_start(&opts, spdk_startup, NULL);
      68         [ -  + ]:         46 :         if (rc) {
      69                 :          0 :                 SPDK_ERRLOG("Start iscsi target daemon:  spdk_app_start() retn non-zero\n");
      70                 :            :         }
      71                 :            : 
      72                 :         46 :         spdk_app_fini();
      73                 :            : 
      74                 :         46 :         return rc;
      75                 :            : }

Generated by: LCOV version 1.14