public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Format a volume in UEFI (or delete all files)
@ 2016-10-12 10:48 GN Keshava
  2016-10-12 14:31 ` Laszlo Ersek
  0 siblings, 1 reply; 13+ messages in thread
From: GN Keshava @ 2016-10-12 10:48 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

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 ?

Thanks.
With regards,
Keshava


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  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
  0 siblings, 2 replies; 13+ messages in thread
From: Laszlo Ersek @ 2016-10-12 14:31 UTC (permalink / raw)
  To: GN Keshava; +Cc: edk2-devel-01

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



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-12 14:31 ` Laszlo Ersek
@ 2016-10-12 17:23   ` Blibbet
  2016-10-12 17:34   ` GN Keshava
  1 sibling, 0 replies; 13+ messages in thread
From: Blibbet @ 2016-10-12 17:23 UTC (permalink / raw)
  To: edk2-devel

On 10/12/2016 07:31 AM, Laszlo Ersek 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?
If Microsoft relicensed the FAT FS driver, what about some licensing
help to make the Intel EFI Disk Utility source code BSD, so that could
be be used by others, or even exec'ed?



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-12 14:31 ` Laszlo Ersek
  2016-10-12 17:23   ` Blibbet
@ 2016-10-12 17:34   ` GN Keshava
  2016-10-12 17:40     ` Laszlo Ersek
  2016-10-12 17:41     ` Blibbet
  1 sibling, 2 replies; 13+ messages in thread
From: GN Keshava @ 2016-10-12 17:34 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-01

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
>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-12 17:34   ` GN Keshava
@ 2016-10-12 17:40     ` Laszlo Ersek
  2016-10-13  1:29       ` GN Keshava
  2016-10-12 17:41     ` Blibbet
  1 sibling, 1 reply; 13+ messages in thread
From: Laszlo Ersek @ 2016-10-12 17:40 UTC (permalink / raw)
  To: GN Keshava; +Cc: edk2-devel-01

On 10/12/16 19:34, GN Keshava wrote:
> 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?

I'm unaware of any "format" command. And, I think it's enough if you
look at RM (LS should be unnecessary); RM already contains the recursion.

Laszlo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-12 17:34   ` GN Keshava
  2016-10-12 17:40     ` Laszlo Ersek
@ 2016-10-12 17:41     ` Blibbet
  2016-10-12 17:46       ` Richardson, Brian
  1 sibling, 1 reply; 13+ messages in thread
From: Blibbet @ 2016-10-12 17:41 UTC (permalink / raw)
  To: edk2-devel



On 10/12/2016 10:34 AM, GN Keshava wrote:
> 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?

The commands do exist. But they're not in Tianocore, and have non-BSD
license, owned by Intel not UEFI Forum.

http://www.intel.com/technology/efi/agree_diskutil.htm
https://firmwaresecurity.com/2015/09/26/intel-efi-disk-utilities/

But the license is not BSD. It even has a password-protected ZIP, making
you read the outer zip's readme for the password.

I presume whoever wrote this code at Intel may've read the sources to
the Microsoft FAT Windows file system code, thus the harsh license.

But now that Microsoft has relicensed the UEFI FAT FS driver, has anyone
considered relicense the code to these tools too?

Lee
(former Microsoft file system PM)




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-12 17:41     ` Blibbet
@ 2016-10-12 17:46       ` Richardson, Brian
  2016-10-12 17:55         ` Michael Zimmermann
  0 siblings, 1 reply; 13+ messages in thread
From: Richardson, Brian @ 2016-10-12 17:46 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

There is an effort to move these tools to EDK II. More news as it happens.

Thanks ... br
---
Brian Richardson, Senior Technical Marketing Engineer, Intel Software
brian.richardson@intel.com -- http://evangelists.intel.com/bio/Brian_Richardson_

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Blibbet
Sent: Wednesday, October 12, 2016 1:42 PM
To: edk2-devel@lists.01.org
Subject: Re: [edk2] Format a volume in UEFI (or delete all files)



On 10/12/2016 10:34 AM, GN Keshava wrote:
> 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?

The commands do exist. But they're not in Tianocore, and have non-BSD license, owned by Intel not UEFI Forum.

http://www.intel.com/technology/efi/agree_diskutil.htm
https://firmwaresecurity.com/2015/09/26/intel-efi-disk-utilities/

But the license is not BSD. It even has a password-protected ZIP, making you read the outer zip's readme for the password.

I presume whoever wrote this code at Intel may've read the sources to the Microsoft FAT Windows file system code, thus the harsh license.

But now that Microsoft has relicensed the UEFI FAT FS driver, has anyone considered relicense the code to these tools too?

Lee
(former Microsoft file system PM)


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-12 17:46       ` Richardson, Brian
@ 2016-10-12 17:55         ` Michael Zimmermann
  0 siblings, 0 replies; 13+ messages in thread
From: Michael Zimmermann @ 2016-10-12 17:55 UTC (permalink / raw)
  To: Richardson, Brian; +Cc: edk2-devel@lists.01.org

depending on his use case it can be unnecessary to do a low level FS format
though(he said that he just wants to delete all files).

It can also become problematic if you consider that the original filesystem
doesn't have to be FAT.

Thanks
Michael

On Wed, Oct 12, 2016 at 7:46 PM, Richardson, Brian <
brian.richardson@intel.com> wrote:

> There is an effort to move these tools to EDK II. More news as it happens.
>
> Thanks ... br
> ---
> Brian Richardson, Senior Technical Marketing Engineer, Intel Software
> brian.richardson@intel.com -- http://evangelists.intel.com/
> bio/Brian_Richardson_
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Blibbet
> Sent: Wednesday, October 12, 2016 1:42 PM
> To: edk2-devel@lists.01.org
> Subject: Re: [edk2] Format a volume in UEFI (or delete all files)
>
>
>
> On 10/12/2016 10:34 AM, GN Keshava wrote:
> > 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?
>
> The commands do exist. But they're not in Tianocore, and have non-BSD
> license, owned by Intel not UEFI Forum.
>
> http://www.intel.com/technology/efi/agree_diskutil.htm
> https://firmwaresecurity.com/2015/09/26/intel-efi-disk-utilities/
>
> But the license is not BSD. It even has a password-protected ZIP, making
> you read the outer zip's readme for the password.
>
> I presume whoever wrote this code at Intel may've read the sources to the
> Microsoft FAT Windows file system code, thus the harsh license.
>
> But now that Microsoft has relicensed the UEFI FAT FS driver, has anyone
> considered relicense the code to these tools too?
>
> Lee
> (former Microsoft file system PM)
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-12 17:40     ` Laszlo Ersek
@ 2016-10-13  1:29       ` GN Keshava
  2016-10-13  6:20         ` Michael Zimmermann
  2016-10-13  8:33         ` Laszlo Ersek
  0 siblings, 2 replies; 13+ messages in thread
From: GN Keshava @ 2016-10-13  1:29 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-01

Thanks Laszlo.

Is it possible to run RM (or any shell command) from my C application code?
Something like "System()" in Linux? Whether we can use LoadImage for this
purpose?

Thanks again.
Regards,
Keshava

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

> On 10/12/16 19:34, GN Keshava wrote:
> > 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?
>
> I'm unaware of any "format" command. And, I think it's enough if you
> look at RM (LS should be unnecessary); RM already contains the recursion.
>
> Laszlo
>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Michael Zimmermann @ 2016-10-13  6:20 UTC (permalink / raw)
  To: GN Keshava; +Cc: Laszlo Ersek, edk2-devel-01

> Is it possible to run RM (or any shell command) from my C application
code?
> Something like "System()" in Linux? Whether we can use LoadImage for this
> purpose?
If you application was started from the Shell you can do that
using ShellExecute from 'Library/ShellLib.h'. Example:

EFI_STATUS Status;
EFI_STATUS CommandStatus;
Status = ShellExecute (&gImageHandle, L"memmap", FALSE, NULL,
&CommandStatus);

If you were not started by the Shell you can run a new Shell and tell it to
run your command and exit afterwards using these LoadImage arguments:

-nomap -nostartup -noversion -_exit [CMD OR FILE]

Thanks
Michael

On Thu, Oct 13, 2016 at 3:29 AM, GN Keshava <keshava.gn@gmail.com> wrote:

> Thanks Laszlo.
>
> Is it possible to run RM (or any shell command) from my C application code?
> Something like "System()" in Linux? Whether we can use LoadImage for this
> purpose?
>
> Thanks again.
> Regards,
> Keshava
>
> On Wed 12 Oct, 2016 11:10 pm Laszlo Ersek, <lersek@redhat.com> wrote:
>
> > On 10/12/16 19:34, GN Keshava wrote:
> > > 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?
> >
> > I'm unaware of any "format" command. And, I think it's enough if you
> > look at RM (LS should be unnecessary); RM already contains the recursion.
> >
> > Laszlo
> >
> >
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-13  6:20         ` Michael Zimmermann
@ 2016-10-13  6:26           ` GN Keshava
  0 siblings, 0 replies; 13+ messages in thread
From: GN Keshava @ 2016-10-13  6:26 UTC (permalink / raw)
  To: Michael Zimmermann; +Cc: Laszlo Ersek, edk2-devel-01

Thanks for the help, Michael.. Yes, I'm running the app from shell (at
least for now).. I will try your suggestion.

Thanks again.
Regards,
Keshava

On Thu, 13 Oct 2016 at 11:50 Michael Zimmermann <sigmaepsilon92@gmail.com>
wrote:

> > Is it possible to run RM (or any shell command) from my C application
> code?
> > Something like "System()" in Linux? Whether we can use LoadImage for
> this
> > purpose?
> If you application was started from the Shell you can do that
> using ShellExecute from 'Library/ShellLib.h'. Example:
>
> EFI_STATUS Status;
> EFI_STATUS CommandStatus;
> Status = ShellExecute (&gImageHandle, L"memmap", FALSE, NULL,
> &CommandStatus);
>
> If you were not started by the Shell you can run a new Shell and tell it
> to run your command and exit afterwards using these LoadImage arguments:
>
> -nomap -nostartup -noversion -_exit [CMD OR FILE]
>
> Thanks
> Michael
>
> On Thu, Oct 13, 2016 at 3:29 AM, GN Keshava <keshava.gn@gmail.com> wrote:
>
> Thanks Laszlo.
>
> Is it possible to run RM (or any shell command) from my C application code?
> Something like "System()" in Linux? Whether we can use LoadImage for this
> purpose?
>
> Thanks again.
> Regards,
> Keshava
>
>
> On Wed 12 Oct, 2016 11:10 pm Laszlo Ersek, <lersek@redhat.com> wrote:
>
> > On 10/12/16 19:34, GN Keshava wrote:
> > > 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?
> >
> > I'm unaware of any "format" command. And, I think it's enough if you
> > look at RM (LS should be unnecessary); RM already contains the recursion.
> >
> > Laszlo
> >
> >
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-13  1:29       ` GN Keshava
  2016-10-13  6:20         ` Michael Zimmermann
@ 2016-10-13  8:33         ` Laszlo Ersek
  2016-10-13  8:48           ` GN Keshava
  1 sibling, 1 reply; 13+ messages in thread
From: Laszlo Ersek @ 2016-10-13  8:33 UTC (permalink / raw)
  To: GN Keshava; +Cc: edk2-devel-01

On 10/13/16 03:29, GN Keshava wrote:
> Thanks Laszlo.
> 
> Is it possible to run RM (or any shell command) from my C application
> code? Something like "System()" in Linux? Whether we can use LoadImage
> for this purpose?

Can't say for sure; I'd opt for a separate implementation.

Thanks
Laszlo

> On Wed 12 Oct, 2016 11:10 pm Laszlo Ersek, <lersek@redhat.com
> <mailto:lersek@redhat.com>> wrote:
> 
>     On 10/12/16 19:34, GN Keshava wrote:
>     > 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?
> 
>     I'm unaware of any "format" command. And, I think it's enough if you
>     look at RM (LS should be unnecessary); RM already contains the
>     recursion.
> 
>     Laszlo
> 



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Format a volume in UEFI (or delete all files)
  2016-10-13  8:33         ` Laszlo Ersek
@ 2016-10-13  8:48           ` GN Keshava
  0 siblings, 0 replies; 13+ messages in thread
From: GN Keshava @ 2016-10-13  8:48 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-01

Got it. Thanks for the help, Laszlo.

Regards,
Keshava

On Thu, 13 Oct 2016 at 14:03 Laszlo Ersek <lersek@redhat.com> wrote:

> On 10/13/16 03:29, GN Keshava wrote:
> > Thanks Laszlo.
> >
> > Is it possible to run RM (or any shell command) from my C application
> > code? Something like "System()" in Linux? Whether we can use LoadImage
> > for this purpose?
>
> Can't say for sure; I'd opt for a separate implementation.
>
> Thanks
> Laszlo
>
> > On Wed 12 Oct, 2016 11:10 pm Laszlo Ersek, <lersek@redhat.com
> > <mailto:lersek@redhat.com>> wrote:
> >
> >     On 10/12/16 19:34, GN Keshava wrote:
> >     > 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?
> >
> >     I'm unaware of any "format" command. And, I think it's enough if you
> >     look at RM (LS should be unnecessary); RM already contains the
> >     recursion.
> >
> >     Laszlo
> >
>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-10-13  8:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox