[36ab7c7] | 1 | /*
|
---|
| 2 | * Copyright (c) 2008 Tim Post
|
---|
[216d6fc] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
[36ab7c7] | 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
[216d6fc] | 8 | *
|
---|
[36ab7c7] | 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
[216d6fc] | 16 | *
|
---|
[36ab7c7] | 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
[216d6fc] | 27 | */
|
---|
| 28 |
|
---|
| 29 | /* NOTE:
|
---|
| 30 | * This is a bit of an ugly hack, working around the absence of fstat / etc.
|
---|
| 31 | * As more stuff is completed and exposed in libc, this will improve */
|
---|
| 32 |
|
---|
| 33 | #include <stdio.h>
|
---|
| 34 | #include <stdlib.h>
|
---|
| 35 | #include <unistd.h>
|
---|
| 36 | #include <dirent.h>
|
---|
| 37 | #include <fcntl.h>
|
---|
[e3a3e3ad] | 38 | #include <getopt.h>
|
---|
[216d6fc] | 39 | #include <sys/types.h>
|
---|
| 40 | #include <sys/stat.h>
|
---|
[19f857a] | 41 | #include <str.h>
|
---|
[e3a3e3ad] | 42 | #include <sort.h>
|
---|
[216d6fc] | 43 |
|
---|
[4567b31c] | 44 | #include "ls.h"
|
---|
[216d6fc] | 45 | #include "errors.h"
|
---|
| 46 | #include "config.h"
|
---|
| 47 | #include "util.h"
|
---|
| 48 | #include "entry.h"
|
---|
| 49 | #include "cmds.h"
|
---|
| 50 |
|
---|
[a000878c] | 51 | static const char *cmdname = "ls";
|
---|
[216d6fc] | 52 |
|
---|
[4567b31c] | 53 | static ls_job_t ls;
|
---|
| 54 |
|
---|
[e3a3e3ad] | 55 | static struct option const long_options[] = {
|
---|
| 56 | { "help", no_argument, 0, 'h' },
|
---|
[cfc3027] | 57 | { "unsort", no_argument, 0, 'u' },
|
---|
[9bdf1f2a] | 58 | { "recursive", no_argument, 0, 'r' },
|
---|
[e3a3e3ad] | 59 | { 0, 0, 0, 0 }
|
---|
| 60 | };
|
---|
| 61 |
|
---|
[4567b31c] | 62 | /* Prototypes for the ls command, excluding entry points. */
|
---|
| 63 | static unsigned int ls_start(ls_job_t *);
|
---|
| 64 | static void ls_print(struct dir_elem_t *);
|
---|
| 65 | static int ls_cmp(void *, void *, void *);
|
---|
| 66 | static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **);
|
---|
| 67 | static unsigned int ls_recursive(const char *, DIR *);
|
---|
| 68 | static unsigned int ls_scope(const char *, struct dir_elem_t *);
|
---|
| 69 |
|
---|
| 70 | static unsigned int ls_start(ls_job_t *ls)
|
---|
| 71 | {
|
---|
| 72 | ls->recursive = 0;
|
---|
| 73 | ls->sort = 1;
|
---|
| 74 |
|
---|
| 75 | return 1;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
[ba63912] | 78 | /** Print an entry.
|
---|
| 79 | *
|
---|
| 80 | * ls_print currently does nothing more than print the entry.
|
---|
| 81 | * In the future, we will likely pass the absolute path, and
|
---|
| 82 | * some sort of ls_options structure that controls how each
|
---|
| 83 | * entry is printed and what is printed about it.
|
---|
| 84 | *
|
---|
| 85 | * Now we just print basic DOS style lists.
|
---|
| 86 | *
|
---|
| 87 | * @param de Directory element.
|
---|
| 88 | */
|
---|
| 89 | static void ls_print(struct dir_elem_t *de)
|
---|
| 90 | {
|
---|
| 91 | if (de->s.is_file)
|
---|
| 92 | printf("%-40s\t%llu\n", de->name, (long long) de->s.size);
|
---|
| 93 | else if (de->s.is_directory)
|
---|
| 94 | printf("%-40s\t<dir>\n", de->name);
|
---|
| 95 | else
|
---|
| 96 | printf("%-40s\n", de->name);
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[e3a3e3ad] | 99 | /** Compare 2 directory elements.
|
---|
[a716a75] | 100 | *
|
---|
[e3a3e3ad] | 101 | * It compares 2 elements of a directory : a file is considered
|
---|
[ba63912] | 102 | * as bigger than a directory, and if they have the same type,
|
---|
[e3a3e3ad] | 103 | * they are compared alphabetically.
|
---|
[a716a75] | 104 | *
|
---|
[e3a3e3ad] | 105 | * @param a Pointer to the structure of the first element.
|
---|
| 106 | * @param b Pointer to the structure of the second element.
|
---|
[ba63912] | 107 | * @param arg Pointer for an other and optionnal argument.
|
---|
[a716a75] | 108 | *
|
---|
[ba63912] | 109 | * @return -1 if a < b, 1 otherwise.
|
---|
[a716a75] | 110 | */
|
---|
[e3a3e3ad] | 111 | static int ls_cmp(void *a, void *b, void *arg)
|
---|
[a716a75] | 112 | {
|
---|
[ba63912] | 113 | struct dir_elem_t *da = a;
|
---|
| 114 | struct dir_elem_t *db = b;
|
---|
[a716a75] | 115 |
|
---|
[ba63912] | 116 | if ((da->s.is_directory && db->s.is_file) ||
|
---|
| 117 | ((da->s.is_directory == db->s.is_directory) &&
|
---|
| 118 | str_cmp(da->name, db->name) < 0))
|
---|
[e3a3e3ad] | 119 | return -1;
|
---|
| 120 | else
|
---|
| 121 | return 1;
|
---|
[a716a75] | 122 | }
|
---|
| 123 |
|
---|
| 124 | /** Scan a directory.
|
---|
| 125 | *
|
---|
| 126 | * Scan the content of a directory and print it.
|
---|
| 127 | *
|
---|
| 128 | * @param d Name of the directory.
|
---|
| 129 | * @param dirp Directory stream.
|
---|
[1e2629f] | 130 | * @param sort 1 if the output must be sorted,
|
---|
| 131 | * 0 otherwise.
|
---|
[a716a75] | 132 | */
|
---|
[4567b31c] | 133 | static signed int ls_scan_dir(const char *d, DIR *dirp,
|
---|
| 134 | struct dir_elem_t **dir_list_ptr)
|
---|
[216d6fc] | 135 | {
|
---|
[a716a75] | 136 | int alloc_blocks = 20;
|
---|
[ba63912] | 137 | int i;
|
---|
[a716a75] | 138 | int nbdirs = 0;
|
---|
[ba63912] | 139 | int rc;
|
---|
| 140 | int len;
|
---|
| 141 | char *buff;
|
---|
| 142 | struct dir_elem_t *tmp;
|
---|
| 143 | struct dir_elem_t *tosort;
|
---|
| 144 | struct dirent *dp;
|
---|
[e3a3e3ad] | 145 |
|
---|
[ba63912] | 146 | if (!dirp)
|
---|
[4567b31c] | 147 | return -1;
|
---|
[216d6fc] | 148 |
|
---|
[ba63912] | 149 | buff = (char *) malloc(PATH_MAX);
|
---|
| 150 | if (!buff) {
|
---|
[216d6fc] | 151 | cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
|
---|
[4567b31c] | 152 | return -1;
|
---|
[216d6fc] | 153 | }
|
---|
[e3a3e3ad] | 154 |
|
---|
[ba63912] | 155 | tosort = (struct dir_elem_t *) malloc(alloc_blocks * sizeof(*tosort));
|
---|
| 156 | if (!tosort) {
|
---|
[a716a75] | 157 | cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
|
---|
[e3a3e3ad] | 158 | free(buff);
|
---|
[4567b31c] | 159 | return -1;
|
---|
[a716a75] | 160 | }
|
---|
| 161 |
|
---|
[216d6fc] | 162 | while ((dp = readdir(dirp))) {
|
---|
[ba63912] | 163 | if (nbdirs + 1 > alloc_blocks) {
|
---|
[a716a75] | 164 | alloc_blocks += alloc_blocks;
|
---|
| 165 |
|
---|
[ba63912] | 166 | tmp = (struct dir_elem_t *) realloc(tosort,
|
---|
| 167 | alloc_blocks * sizeof(struct dir_elem_t));
|
---|
| 168 | if (!tmp) {
|
---|
[a716a75] | 169 | cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
|
---|
[ba63912] | 170 | goto out;
|
---|
[a716a75] | 171 | }
|
---|
| 172 | tosort = tmp;
|
---|
| 173 | }
|
---|
| 174 |
|
---|
[ba63912] | 175 | /* fill the name field */
|
---|
[a701812] | 176 | tosort[nbdirs].name = (char *) malloc(str_size(dp->d_name) + 1);
|
---|
[ba63912] | 177 | if (!tosort[nbdirs].name) {
|
---|
[e3a3e3ad] | 178 | cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
|
---|
[ba63912] | 179 | goto out;
|
---|
[e3a3e3ad] | 180 | }
|
---|
[a701812] | 181 |
|
---|
| 182 | str_cpy(tosort[nbdirs].name, str_size(dp->d_name) + 1, dp->d_name);
|
---|
[ba63912] | 183 | len = snprintf(buff, PATH_MAX - 1, "%s/%s", d, tosort[nbdirs].name);
|
---|
| 184 | buff[len] = '\0';
|
---|
| 185 |
|
---|
| 186 | rc = stat(buff, &tosort[nbdirs++].s);
|
---|
[e3a3e3ad] | 187 | if (rc != 0) {
|
---|
| 188 | printf("ls: skipping bogus node %s\n", buff);
|
---|
| 189 | printf("rc=%d\n", rc);
|
---|
[ba63912] | 190 | goto out;
|
---|
[a716a75] | 191 | }
|
---|
| 192 | }
|
---|
| 193 |
|
---|
[4567b31c] | 194 | if (ls.sort) {
|
---|
[ba63912] | 195 | if (!qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t),
|
---|
| 196 | ls_cmp, NULL)) {
|
---|
| 197 | printf("Sorting error.\n");
|
---|
| 198 | }
|
---|
[e3a3e3ad] | 199 | }
|
---|
[a716a75] | 200 |
|
---|
[ba63912] | 201 | for (i = 0; i < nbdirs; i++)
|
---|
| 202 | ls_print(&tosort[i]);
|
---|
[4567b31c] | 203 |
|
---|
| 204 | /* Populate the directory list. */
|
---|
| 205 | if (ls.recursive) {
|
---|
| 206 | tmp = (struct dir_elem_t *) realloc(*dir_list_ptr,
|
---|
| 207 | nbdirs * sizeof(struct dir_elem_t));
|
---|
| 208 | if (!tmp) {
|
---|
| 209 | cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
|
---|
| 210 | goto out;
|
---|
| 211 | }
|
---|
| 212 | *dir_list_ptr = tmp;
|
---|
| 213 |
|
---|
| 214 | for (i = 0; i < nbdirs; i++) {
|
---|
| 215 | (*dir_list_ptr)[i].name = str_dup(tosort[i].name);
|
---|
| 216 | if (!(*dir_list_ptr)[i].name) {
|
---|
| 217 | cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
|
---|
| 218 | goto out;
|
---|
| 219 | }
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
[a716a75] | 222 |
|
---|
[ba63912] | 223 | out:
|
---|
| 224 | for(i = 0; i < nbdirs; i++)
|
---|
| 225 | free(tosort[i].name);
|
---|
[a716a75] | 226 | free(tosort);
|
---|
[216d6fc] | 227 | free(buff);
|
---|
[4567b31c] | 228 |
|
---|
| 229 | return nbdirs;
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | /** Visit a directory recursively.
|
---|
| 233 | *
|
---|
| 234 | * ls_recursive visits all the subdirectories recursively and
|
---|
| 235 | * prints the files and directories in them.
|
---|
| 236 | *
|
---|
| 237 | * @param path Path the current directory being visited.
|
---|
| 238 | * @param dirp Directory stream.
|
---|
| 239 | */
|
---|
| 240 | static unsigned int ls_recursive(const char *path, DIR *dirp)
|
---|
| 241 | {
|
---|
| 242 | int i, nbdirs, ret;
|
---|
| 243 | unsigned int scope;
|
---|
| 244 | char *subdir_path;
|
---|
| 245 | DIR *subdirp;
|
---|
| 246 | struct dir_elem_t *dir_list;
|
---|
| 247 |
|
---|
| 248 | const char * const trailing_slash = "/";
|
---|
| 249 |
|
---|
| 250 | nbdirs = 0;
|
---|
| 251 | dir_list = (struct dir_elem_t *) malloc(sizeof(struct dir_elem_t));
|
---|
| 252 |
|
---|
| 253 | printf("\n%s:\n", path);
|
---|
| 254 |
|
---|
| 255 | subdir_path = (char *) malloc(PATH_MAX);
|
---|
| 256 | if (!subdir_path) {
|
---|
| 257 | ret = CMD_FAILURE;
|
---|
| 258 | goto out;
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | nbdirs = ls_scan_dir(path, dirp, &dir_list);
|
---|
| 262 | if (nbdirs == -1) {
|
---|
| 263 | ret = CMD_FAILURE;
|
---|
| 264 | goto out;
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | for (i = 0; i < nbdirs; ++i) {
|
---|
| 268 | memset(subdir_path, 0, PATH_MAX);
|
---|
| 269 |
|
---|
| 270 | if (str_size(subdir_path) + str_size(path) + 1 <= PATH_MAX)
|
---|
| 271 | str_append(subdir_path, PATH_MAX, path);
|
---|
| 272 | if (path[str_size(path)-1] != '/' &&
|
---|
| 273 | str_size(subdir_path) + str_size(trailing_slash) + 1 <= PATH_MAX)
|
---|
| 274 | str_append(subdir_path, PATH_MAX, trailing_slash);
|
---|
| 275 | if (str_size(subdir_path) +
|
---|
| 276 | str_size(dir_list[i].name) + 1 <= PATH_MAX)
|
---|
| 277 | str_append(subdir_path, PATH_MAX, dir_list[i].name);
|
---|
| 278 |
|
---|
| 279 | scope = ls_scope(subdir_path, &dir_list[i]);
|
---|
| 280 | switch (scope) {
|
---|
| 281 | case LS_FILE:
|
---|
| 282 | break;
|
---|
| 283 | case LS_DIR:
|
---|
| 284 | subdirp = opendir(subdir_path);
|
---|
| 285 | if (!subdirp) {
|
---|
| 286 | /* May have been deleted between scoping it and opening it */
|
---|
| 287 | cli_error(CL_EFAIL, "Could not stat %s", dir_list[i].name);
|
---|
| 288 | ret = CMD_FAILURE;
|
---|
| 289 | goto out;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | ret = ls_recursive(subdir_path, subdirp);
|
---|
| 293 | closedir(subdirp);
|
---|
| 294 | if (ret == CMD_FAILURE)
|
---|
| 295 | goto out;
|
---|
| 296 | break;
|
---|
| 297 | case LS_BOGUS:
|
---|
| 298 | ret = CMD_FAILURE;
|
---|
| 299 | goto out;
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | ret = CMD_SUCCESS;
|
---|
| 304 |
|
---|
| 305 | out:
|
---|
| 306 | for (i = 0; i < nbdirs; i++)
|
---|
| 307 | free(dir_list[i].name);
|
---|
| 308 | free(dir_list);
|
---|
| 309 | free(subdir_path);
|
---|
| 310 |
|
---|
| 311 | return ret;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | static unsigned int ls_scope(const char *path, struct dir_elem_t *de)
|
---|
| 315 | {
|
---|
| 316 | if (stat(path, &de->s)) {
|
---|
[26c02b22] | 317 | cli_error(CL_ENOENT, "%s", path);
|
---|
[4567b31c] | 318 | return LS_BOGUS;
|
---|
| 319 | }
|
---|
| 320 |
|
---|
| 321 | if (de->s.is_file)
|
---|
| 322 | return LS_FILE;
|
---|
| 323 | else if (de->s.is_directory)
|
---|
| 324 | return LS_DIR;
|
---|
| 325 |
|
---|
| 326 | return LS_BOGUS;
|
---|
[216d6fc] | 327 | }
|
---|
| 328 |
|
---|
[809813d] | 329 | void help_cmd_ls(unsigned int level)
|
---|
[216d6fc] | 330 | {
|
---|
| 331 | if (level == HELP_SHORT) {
|
---|
| 332 | printf("`%s' lists files and directories.\n", cmdname);
|
---|
| 333 | } else {
|
---|
| 334 | help_cmd_ls(HELP_SHORT);
|
---|
[e3a3e3ad] | 335 | printf(
|
---|
| 336 | "Usage: %s [options] [path]\n"
|
---|
| 337 | "If not path is given, the current working directory is used.\n"
|
---|
| 338 | "Options:\n"
|
---|
| 339 | " -h, --help A short option summary\n"
|
---|
[4567b31c] | 340 | " -u, --unsort Do not sort directory entries\n"
|
---|
[9bdf1f2a] | 341 | " -r, --recursive List subdirectories recursively\n",
|
---|
[e3a3e3ad] | 342 | cmdname);
|
---|
[216d6fc] | 343 | }
|
---|
| 344 |
|
---|
[809813d] | 345 | return;
|
---|
[216d6fc] | 346 | }
|
---|
| 347 |
|
---|
[809813d] | 348 | int cmd_ls(char **argv)
|
---|
[216d6fc] | 349 | {
|
---|
| 350 | unsigned int argc;
|
---|
[ba63912] | 351 | struct dir_elem_t de;
|
---|
[216d6fc] | 352 | DIR *dirp;
|
---|
[e3a3e3ad] | 353 | int c, opt_ind;
|
---|
[4567b31c] | 354 | int ret = 0;
|
---|
| 355 | unsigned int scope;
|
---|
| 356 |
|
---|
| 357 | if (!ls_start(&ls)) {
|
---|
| 358 | cli_error(CL_EFAIL, "%s: Could not initialize", cmdname);
|
---|
| 359 | return CMD_FAILURE;
|
---|
| 360 | }
|
---|
[216d6fc] | 361 |
|
---|
[43e02a6] | 362 | argc = cli_count_args(argv);
|
---|
[e3a3e3ad] | 363 |
|
---|
| 364 | for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
|
---|
[9bdf1f2a] | 365 | c = getopt_long(argc, argv, "hur", long_options, &opt_ind);
|
---|
[e3a3e3ad] | 366 | switch (c) {
|
---|
| 367 | case 'h':
|
---|
| 368 | help_cmd_ls(HELP_LONG);
|
---|
| 369 | return CMD_SUCCESS;
|
---|
| 370 | case 'u':
|
---|
[4567b31c] | 371 | ls.sort = 0;
|
---|
| 372 | break;
|
---|
[9bdf1f2a] | 373 | case 'r':
|
---|
[4567b31c] | 374 | ls.recursive = 1;
|
---|
[e3a3e3ad] | 375 | break;
|
---|
| 376 | }
|
---|
| 377 | }
|
---|
| 378 |
|
---|
[cfc3027] | 379 | argc -= optind;
|
---|
[e3a3e3ad] | 380 |
|
---|
[ba63912] | 381 | de.name = (char *) malloc(PATH_MAX);
|
---|
| 382 | if (!de.name) {
|
---|
[216d6fc] | 383 | cli_error(CL_ENOMEM, "%s: ", cmdname);
|
---|
| 384 | return CMD_FAILURE;
|
---|
| 385 | }
|
---|
[4567b31c] | 386 | memset(de.name, 0, PATH_MAX);
|
---|
[e3a3e3ad] | 387 |
|
---|
[cfc3027] | 388 | if (argc == 0)
|
---|
[ba63912] | 389 | getcwd(de.name, PATH_MAX);
|
---|
[216d6fc] | 390 | else
|
---|
[cfc3027] | 391 | str_cpy(de.name, PATH_MAX, argv[optind]);
|
---|
[415c7e0d] | 392 |
|
---|
[4567b31c] | 393 | scope = ls_scope(de.name, &de);
|
---|
| 394 | switch (scope) {
|
---|
| 395 | case LS_FILE:
|
---|
[ba63912] | 396 | ls_print(&de);
|
---|
[4567b31c] | 397 | break;
|
---|
| 398 | case LS_DIR:
|
---|
[ba63912] | 399 | dirp = opendir(de.name);
|
---|
[415c7e0d] | 400 | if (!dirp) {
|
---|
[216d6fc] | 401 | /* May have been deleted between scoping it and opening it */
|
---|
[ba63912] | 402 | cli_error(CL_EFAIL, "Could not stat %s", de.name);
|
---|
| 403 | free(de.name);
|
---|
[216d6fc] | 404 | return CMD_FAILURE;
|
---|
| 405 | }
|
---|
[4567b31c] | 406 | if (ls.recursive)
|
---|
| 407 | ret = ls_recursive(de.name, dirp);
|
---|
| 408 | else
|
---|
| 409 | ret = ls_scan_dir(de.name, dirp, NULL);
|
---|
| 410 |
|
---|
[216d6fc] | 411 | closedir(dirp);
|
---|
[4567b31c] | 412 | break;
|
---|
| 413 | case LS_BOGUS:
|
---|
| 414 | return CMD_FAILURE;
|
---|
[216d6fc] | 415 | }
|
---|
| 416 |
|
---|
[ba63912] | 417 | free(de.name);
|
---|
[216d6fc] | 418 |
|
---|
[4567b31c] | 419 | if (ret == -1 || ret == CMD_FAILURE)
|
---|
| 420 | return CMD_FAILURE;
|
---|
| 421 | else
|
---|
| 422 | return CMD_SUCCESS;
|
---|
[216d6fc] | 423 | }
|
---|
| 424 |
|
---|