1. 19 2月, 2014 8 次提交
    • S
      cmd_test: evaluate to false without any arguments · 2453de99
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      2453de99
    • S
      cmd_test: implement ! on sub-expressions · d9b651ce
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      d9b651ce
    • S
      cmd_test: check for binary operators before unary · 4c80f29e
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      4c80f29e
    • S
      cmd_test: use table lookup for parsing · 490ba833
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      490ba833
    • S
      fs: don't pass NULL dev_desc to most filesystems · 377202b5
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      377202b5
    • S
      fs: implement infrastructure for an 'exists' function · 6152916a
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      Acked-by: NSimon Glass <sjg@chromium.org>
      6152916a
    • S
      fs: fix generic save command implementation · bd6fb31f
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      Acked-by: NSimon Glass <sjg@chromium.org>
      bd6fb31f
    • S
      README: document CONFIG_CMD_FS_GENERIC · 16f4d933
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      16f4d933
  2. 18 2月, 2014 3 次提交
  3. 14 2月, 2014 2 次提交
  4. 13 2月, 2014 13 次提交
  5. 11 2月, 2014 2 次提交
  6. 10 2月, 2014 2 次提交
  7. 08 2月, 2014 9 次提交
  8. 07 2月, 2014 1 次提交