[Libwebsockets] Enabling/disabling LWS_WITH_FILE_OPS consequences

Andy Green andy at warmcat.com
Mon Nov 23 20:32:50 CET 2020



On 11/23/20 6:07 PM, Bram Peeters wrote:
> Hi,
> 
> I noticed there are still some 'naked' posix file operation calls (open, fstat) even after enabling LWS_WITH_FILE_OPS
> 
> Eg:
> - In libwebsockets.c function:
> #if defined(LWS_WITH_FILE_OPS)
> int lws_open(const char *__file, int __oflag, ...)
> 
> -  In cached-file.c function:
> int
> lwsac_cached_file(const char *filepath, lwsac_cached_file_t *cache, size_t *len)
> 
> Are these intentional or should they be redirected to the VFS ?
> (especially the first one is a bit weird since it is only activated when LWS_WITH_FILE_OPS is set)

It's as expected IIUI, the vfs stuff and elaborations of it like 
lws_open() only exist if the VFS stuff is enabled.

The idea is that you can arbitrarily override the actual file operations 
used by, eg, serving files, to do things like _ZIP_FOPS where the VFS is 
actually serving files from inside a literal zip file, without unzipping 
it, and even serving the contents gzip-encoded without decode and recode 
if that was possible at http layer.

It's not the same as, eg, loading certificates or local cache files 
(this is lwsac_cached_file()'s job) from the local filesystem, you don't 
want that coming through such a zip file VFS scheme but handled locally.

-Andy

> Regards
> Bram
> 
> -----Original Message-----
> From: Bram Peeters
> Sent: Monday, November 23, 2020 11:49
> To: 'Andy Green' <andy at warmcat.com>; libwebsockets at ml.libwebsockets.org
> Subject: RE: [Libwebsockets] Enabling/disabling LWS_WITH_FILE_OPS consequences
> 
> Ok, thank you !
> 
> -----Original Message-----
> From: Andy Green <andy at warmcat.com>
> Sent: Monday, November 23, 2020 11:38
> To: Bram Peeters <Bram.Peeters at dekimo.com>; libwebsockets at ml.libwebsockets.org
> Subject: Re: [Libwebsockets] Enabling/disabling LWS_WITH_FILE_OPS consequences
> 
> 
> 
> On 11/23/20 10:27 AM, Bram Peeters wrote:
>> Hi,
>>
>> I (noob user) am porting libwebsockets to a new platform and I am
>> wondering what functionality I loose if I disable support for file
>> operations (LWS_WITH_FILE_OPS)  ?
> 
> Basically the lws VFS support.
> 
>> I tried googling but it did not immediately give me an answer.
>>
>> Also what kind of write operations happen if you enable it (volumes &
>> frequency). This is to know if this can be redirected to internal
>> program flash, or if something big is needed/something with wear leveling.
> 
> It doesn't cause any file operations.
> 
> If enabled, it will provide a generic VFS struct you can override on your platform to make file operations do whatever makes sense for your platform.  Lws will use the vfs to, eg, read files to serve.  By default the vfs maps to the generic POSIX file apis but you can override it.
> 
> If disabled, if your platform supports files at all it will directly use the POSIX file access apis on your platform.
> 
>> My apologies if this has been asked before, I do not immediately see a
>> way to search the mailing archives.
> 
> You would probably want to find it out yourself by git grep the sources and see what it does, it's pretty esoteric.
> 
> -Andy
> 
>> Bram
>>
>>
>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> https://libwebsockets.org/mailman/listinfo/libwebsockets
>>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 


More information about the Libwebsockets mailing list