User`s manual

Dynamic C Users Manual digi.com 137
10.1.4.3 Logical Sector Size
fs_setup() can also be used to specify non-default logical sector (LS) sizes and other parameters. FS2
allows any logical sector size between 64 and 8192 bytes, providing the LS size is an exact power of 2.
Each logical extent, including sub-partitions, can have a different LS size. This allows some performance
optimization. Small LSs are better for a RAM LX, since it minimizes wasted space without incurring a
performance penalty. Larger LSs are better for bulk data such as logs. If the flash physical sector size (i.e.
the actual hardware sector size) is large, it is better to use a correspondingly large LS size. This is espe-
cially the case for byte-writable devices. Large LSs should also be used for large LXs. This minimizes the
amount of time needed to initialize the file system and access large files. As a rule of thumb, there should
be no more than 1024 LSs in any LX. The ideal LS size for RAM (which is the default) is 128 bytes. 256
or 512 can also be reasonable values for some applications that have a lot of spare RAM.
Sector-writable flash devices require: LS size PS size. Byte-writable devices, however, may use any
allowable logical sector size, regardless of the physical sector size.
Sample program Samples\FileSystem\FS2DEMO2 illustrates use of fs_setup(). This sample
also allows you to experiment with various file system settings to obtain the best performance.
FS2 has been designed to be extensible so it will work with future flash and other non-volatile storage
devices. Writing and installing custom low-level device drivers is beyond the scope of this document,
however see FS2.LIB and FS_DEV.LIB for hints.
10.1.5 File Identifiers
There are two ways to identify a particular file in the file system: file numbers and file names.
10.1.5.1 File Numbers
The file number uniquely identifies a file within a logical extent. File numbers must be unique within the
entire file system. FS2 accepts file numbers in word format:
typedef word FileNumber
The low-order byte specifies the file number and the high-order byte specifies the LX number of the meta-
data (1 through number of LXs). If the high-order byte is zero, then a suitable “default” LX will be located
by the file system. The default LX will default to 1, but will be settable via a #define, for file creation.
For existing files, a high-order byte of zero will cause the file system to search for the LX that contains the
file. This will require no or minimal changes to existing customer code.
Only the metadata LX may be specified in the file number. This is called a “fully-qualified” file number
(FQFN). The LX number always applies to the file metadata. The data can reside on a different LX, how-
ever this is always determined by FS2 once the file has been created.
10.1.5.2 File Names
There are several functions in ZSERVER.LIB that can be used to associate a descriptive name with a file.
The file must exist in the flash file system before using the auxiliary functions listed in the following table.
These functions were originally intended for use with an HTTP or FTP server, so some of them take a
parameter called servermask. To use these functions for file naming purposes only, this parameter
should be SERVER_USER.
For a detailed description of these functions please refer to the Dynamic C TCP/IP Users Manual, Vol 2,
or use keyboard shortcut Ctrl+H in Dynamic C to use the Library Lookup feature.