public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: GN Keshava <keshava.gn@gmail.com>
To: Laszlo Ersek <lersek@redhat.com>
Cc: edk2-devel-01 <edk2-devel@ml01.01.org>
Subject: Re: Format a volume in UEFI (or delete all files)
Date: Wed, 12 Oct 2016 17:34:26 +0000	[thread overview]
Message-ID: <CABKwMds1LArwTYCz=K+q+LGXMoEBF90mtdhyaqGYTebPdjKeCA@mail.gmail.com> (raw)
In-Reply-To: <a1c36e38-2edd-db9b-a47f-a64ac8bcdc56@redhat.com>

Thanks Laszlo, I'll check it out.

I think I need to combine the LS implementation and RM implementation,
isn't it? So there is no "format this volume" function or command exists,
right?

Thanks again!
Regards,
Keshava

On Wed 12 Oct, 2016 8:01 pm Laszlo Ersek, <lersek@redhat.com> wrote:

> On 10/12/16 12:48, GN Keshava wrote:
> > Hi all,
> >
> > I need to format fs1: (or delete all files and folders in root directory)
> > from my UEFI application.
> >
> > I'm able to use file system APIs such as Open, Write or Delete too. But
> > Delete API needs File (file path) as argument, but what I want is delete
> > all files (irrespective of file name).
> >
> > What could be the best method? Is there any API to directly delete all
> > files? If not, How to go through (Open) all files and delete each?
> >
> > How I can get each file and folder names in a directory programmatically
> ?
>
> Implement recursive directory traversal.
>
> (Minimally) the CP, LS, and TOUCH commands support the "-r" option, for
> recursive operation. I guess you could consult their implementations, if
> you don't want to implement the traversal from scratch.
>
>   ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
>   ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
>   ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
>
> Actually... the RM command supports recursive file & directory removal
> without additional options. The UEFI shell spec 2.2 (Jan 26, 2016) says
> under RM:
>
>     This command deletes one or more files or directories. If the
>     target is a directory, it will delete the directory, including all
>     its subdirectories. [...]
>
> So I guess you could copy & customize the code from
>
>   ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
>
> The CascadeDelete() function looks relevant: "Delete a node and all
> nodes under it (including sub directories)".
>
> Thanks
> Laszlo
>
>


  parent reply	other threads:[~2016-10-12 17:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 10:48 Format a volume in UEFI (or delete all files) GN Keshava
2016-10-12 14:31 ` Laszlo Ersek
2016-10-12 17:23   ` Blibbet
2016-10-12 17:34   ` GN Keshava [this message]
2016-10-12 17:40     ` Laszlo Ersek
2016-10-13  1:29       ` GN Keshava
2016-10-13  6:20         ` Michael Zimmermann
2016-10-13  6:26           ` GN Keshava
2016-10-13  8:33         ` Laszlo Ersek
2016-10-13  8:48           ` GN Keshava
2016-10-12 17:41     ` Blibbet
2016-10-12 17:46       ` Richardson, Brian
2016-10-12 17:55         ` Michael Zimmermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABKwMds1LArwTYCz=K+q+LGXMoEBF90mtdhyaqGYTebPdjKeCA@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox