Skip to content
Snippets Groups Projects
  1. Feb 19, 2014
    • Stephen Warren's avatar
      cmd_test: evaluate to false without any arguments · 2453de99
      Stephen Warren authored
      
      This emulates bash:
      $ if test; then echo yes; else echo no; fi
      no
      
      Currently, the code sets expr = -1 in this case, which gets mapped to
      0 (true) at the end of do_test() by the logical -> shell exit code
      conversion.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      2453de99
    • Stephen Warren's avatar
      cmd_test: implement ! on sub-expressions · d9b651ce
      Stephen Warren authored
      
      Currently, ! can only be parsed as the first operator in an expression.
      This prevents the following from working:
      
      $ if test ! ! 1 -eq 1; then echo yes; else echo no; fi
      yes
      $ if test ! 1 -eq 2 -a ! 3 -eq 4; then echo yes; else echo no; fi
      yes
      
      Fix this by parsing ! like any other operator, and and handling it
      similarly to -a and -o.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      d9b651ce
    • Stephen Warren's avatar
      cmd_test: check for binary operators before unary · 4c80f29e
      Stephen Warren authored
      
      This better mirrors the behaviour of bash, for example:
      
      $ if test -z = -z; then echo yes; else echo no; fi
      yes
      
      This is parsed as a string comparison of "-z" and "-z", since the check
      for the binary "=" operator occurs first. Without this change, the
      command would be parsed as a -z test of "-", followed by a syntax error;
      a trailing -z without and operand.
      
      This is a behavioural change, but I believe any commands affected were
      previously invalid or bizarely formed.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      4c80f29e
    • Stephen Warren's avatar
      cmd_test: use table lookup for parsing · 490ba833
      Stephen Warren authored
      
      do_test() currently uses strcmp() twice to determine which operator is
      present; once to determine how many arguments the operator needs, then
      a second time to actually decode the operator and implement it.
      
      Rewrite the code so that a table lookup is used to translate the operator
      string to an integer, and use a more efficient switch statement to decode
      and execute the operator.
      
      This approach also acts as enablement for the following patches.
      
      This patch should introduce no behavioural change.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      490ba833
    • Stephen Warren's avatar
      fs: don't pass NULL dev_desc to most filesystems · 377202b5
      Stephen Warren authored
      
      FAT and ext4 expect that the passed in block device descriptor not be
      NULL. This causes problems on sandbox, where get_device_and_partition()
      succeeds for the "host" device, yet passes back a NULL device descriptor.
      Add special handling for this situation, so that the generic filesystem
      commands operate as expected on sandbox.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      377202b5
    • Stephen Warren's avatar
      fs: implement infrastructure for an 'exists' function · 6152916a
      Stephen Warren authored
      
      This could be used in scripts such as:
      
      if test -e mmc 0:1 /boot/boot.scr; then
          load mmc 0:1 ${scriptaddr} /boot/boot.scr
          source ${scriptaddr}
      fi
      
      rather than:
      
      if load mmc 0:1 ${scriptaddr} /boot/boot.scr; then
          source ${scriptaddr}
      fi
      
      This prevents errors being printed by attempts to load non-existent
      files, which can be important when checking for a large set of files,
      such as /boot/boot.scr.uimg, /boot/boot.scr, /boot/extlinux.conf,
      /boot.scr.uimg, /boot.scr, /extlinux.conf.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      Acked-by: default avatarSimon Glass <sjg@chromium.org>
      6152916a
    • Stephen Warren's avatar
      fs: fix generic save command implementation · bd6fb31f
      Stephen Warren authored
      
      Fix a few issues with the generic "save" shell command, and fs_write()
      function.
      
      1) fstypes[].write wasn't filled in for some file-systems, and isn't
         checked when used, which could cause crashes/... if executing save
         on e.g. fat/ext filesystems.
      
      2) fs_write() requires the length argument to be non-zero, since it needs
         to know exactly how many bytes to write. Adjust the comments and code
         according to this.
      
      3) fs_write() wasn't prototyped in <fs.h> like other generic functions;
         other code should be able to call this directly rather than invoking
         the "save" shell command.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      Acked-by: default avatarSimon Glass <sjg@chromium.org>
      bd6fb31f
    • Stephen Warren's avatar
      README: document CONFIG_CMD_FS_GENERIC · 16f4d933
      Stephen Warren authored
      
      This enables generic filesystem commands such as load and ls, which
      automatically work with multiple filesystem types, without having to
      be told which is present, unlike e.g. ext2load, fatls.
      
      Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
      16f4d933
  2. Feb 17, 2014
  3. Feb 14, 2014
  4. Feb 13, 2014
  5. Feb 11, 2014
  6. Feb 10, 2014
  7. Feb 07, 2014
Loading