Move the TZ/Olson zoneinfo data set from apps/system/zoneinfo to libc/zoneinfo
This commit is contained in:
parent
8a03660c72
commit
7304927448
@ -1,83 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* apps/include/zoneinfo.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef __APPS_INCLUDE_ZONEINFO_H
|
|
||||||
#define __APPS_INCLUDE_ZONEINFO_H
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_SYSTEM_ZONEINFO_ROMFS
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define EXTERN extern "C"
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If the TZ database is built as a ROMFS file system, then these variables
|
|
||||||
* provide (1) the address of the array in FLASH/ROM that contains the
|
|
||||||
* ROMFS file system image, and (2) the size of the ROMFS file system image
|
|
||||||
* in bytes. This is sufficient information to permit external logic to
|
|
||||||
* mount the ROMF file system.
|
|
||||||
*/
|
|
||||||
|
|
||||||
EXTERN unsigned char romfs_zoneinfo_img[];
|
|
||||||
EXTERN unsigned int romfs_zoneinfo_img_len;
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Function Prototypes
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#undef EXTERN
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* CONFIG_SYSTEM_ZONEINFO_ROMFS */
|
|
||||||
#endif /* __APPS_INCLUDE_ZONEINFO_H */
|
|
17
system/zoneinfo/.gitignore
vendored
17
system/zoneinfo/.gitignore
vendored
@ -1,17 +0,0 @@
|
|||||||
/Make.dep
|
|
||||||
/.depend
|
|
||||||
/.built
|
|
||||||
/.tzbuilt
|
|
||||||
/.tzunpack
|
|
||||||
/tzbin
|
|
||||||
/tzcode
|
|
||||||
/tz*-latest.tar.gz
|
|
||||||
/romfs_zoneinfo.*
|
|
||||||
/*.asm
|
|
||||||
/*.rel
|
|
||||||
/*.lst
|
|
||||||
/*.sym
|
|
||||||
/*.adb
|
|
||||||
/*.lib
|
|
||||||
/*.src
|
|
||||||
/*.obj
|
|
@ -1,22 +0,0 @@
|
|||||||
#
|
|
||||||
# For a description of the syntax of this configuration file,
|
|
||||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
|
||||||
#
|
|
||||||
|
|
||||||
config SYSTEM_ZONEINFO
|
|
||||||
bool "TZ database"
|
|
||||||
default n
|
|
||||||
depends on LIBC_LOCALTIME
|
|
||||||
---help---
|
|
||||||
Build the TZ/Olson database.
|
|
||||||
|
|
||||||
if SYSTEM_ZONEINFO
|
|
||||||
|
|
||||||
config SYSTEM_ZONEINFO_ROMFS
|
|
||||||
bool "Build ROMFS filesystem"
|
|
||||||
default n
|
|
||||||
depends on FS_ROMFS
|
|
||||||
---help---
|
|
||||||
Build a mountable ROMFS filesystem containing the TZ database
|
|
||||||
|
|
||||||
endif # SYSTEM_ZONEINFO
|
|
@ -1,40 +0,0 @@
|
|||||||
############################################################################
|
|
||||||
# apps/system/zoneinfo/Make.defs
|
|
||||||
# Adds selected applications to apps/ build
|
|
||||||
#
|
|
||||||
# Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in
|
|
||||||
# the documentation and/or other materials provided with the
|
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSTEM_ZONEINFO),y)
|
|
||||||
CONFIGURED_APPS += system/zoneinfo
|
|
||||||
endif
|
|
||||||
|
|
@ -1,175 +0,0 @@
|
|||||||
############################################################################
|
|
||||||
# apps/system/zoneinfo/Makefile
|
|
||||||
#
|
|
||||||
# Copyright (C) 2015, Gregory Nutt. All rights reserved.
|
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in
|
|
||||||
# the documentation and/or other materials provided with the
|
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
-include $(TOPDIR)/.config
|
|
||||||
-include $(TOPDIR)/Make.defs
|
|
||||||
include $(APPDIR)/Make.defs
|
|
||||||
|
|
||||||
ifeq ($(WINTOOL),y)
|
|
||||||
INCDIROPT = -w
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Zoneinfo database
|
|
||||||
|
|
||||||
ASRCS =
|
|
||||||
CSRCS =
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSTEM_ZONEINFO_ROMFS),y)
|
|
||||||
CSRCS += tzromfs.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
|
||||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
|
||||||
|
|
||||||
SRCS = $(ASRCS) $(CSRCS)
|
|
||||||
OBJS = $(AOBJS) $(COBJS)
|
|
||||||
|
|
||||||
ZONEINFO_PATH = $(APPDIR)/system/zoneinfo
|
|
||||||
TZBIN_PATH = $(ZONEINFO_PATH)/tzbin
|
|
||||||
TZCODE_PATH = $(ZONEINFO_PATH)/tzcode
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
|
||||||
BIN = ..\..\libapps$(LIBEXT)
|
|
||||||
else
|
|
||||||
ifeq ($(WINTOOL),y)
|
|
||||||
BIN = ..\\..\\libapps$(LIBEXT)
|
|
||||||
else
|
|
||||||
BIN = ../../libapps$(LIBEXT)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ROOTDEPPATH = --dep-path .
|
|
||||||
|
|
||||||
# Common build
|
|
||||||
|
|
||||||
VPATH =
|
|
||||||
|
|
||||||
all: .built
|
|
||||||
.PHONY: romfs register context depend clean distclean
|
|
||||||
|
|
||||||
$(AOBJS): %$(OBJEXT): %.S
|
|
||||||
$(call ASSEMBLE, $<, $@)
|
|
||||||
|
|
||||||
$(COBJS): %$(OBJEXT): %.c
|
|
||||||
$(call COMPILE, $<, $@)
|
|
||||||
|
|
||||||
.built: .tzbuilt romfs $(OBJS)
|
|
||||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
|
||||||
$(Q) touch .built
|
|
||||||
|
|
||||||
# ROMFS file system containing the TZ database
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SYSTEM_ZONEINFO_ROMFS),y)
|
|
||||||
|
|
||||||
checkgenromfs:
|
|
||||||
@genromfs -h 1>/dev/null 2>&1 || { \
|
|
||||||
echo "Host executable genromfs not available in PATH"; \
|
|
||||||
echo "You may need to download in from http://romfs.sourceforge.net/"; \
|
|
||||||
exit 1; \
|
|
||||||
}
|
|
||||||
|
|
||||||
romfs_zoneinfo.img : checkgenromfs .tzbuilt
|
|
||||||
@genromfs -f $@ -d $(TZBIN_PATH)/etc/zoneinfo -V "TZDatbase" || { echo "genromfs failed" ; exit 1 ; }
|
|
||||||
|
|
||||||
romfs_zoneinfo.h : romfs_zoneinfo.img
|
|
||||||
@xxd -i $< >$@ || { echo "xxd of $< failed" ; exit 1 ; }
|
|
||||||
|
|
||||||
romfs: romfs_zoneinfo.h
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
romfs:
|
|
||||||
|
|
||||||
endif # CONFIG_SYSTEM_ZONEINFO_ROMFS
|
|
||||||
|
|
||||||
# Build TZ database
|
|
||||||
|
|
||||||
tzcode:
|
|
||||||
mkdir tzcode
|
|
||||||
|
|
||||||
tzbin:
|
|
||||||
mkdir tzbin
|
|
||||||
|
|
||||||
tzcode-latest.tar.gz:
|
|
||||||
$(Q) wget --retr-symlinks ftp://ftp.iana.org/tz/tzcode-latest.tar.gz
|
|
||||||
|
|
||||||
tzdata-latest.tar.gz:
|
|
||||||
$(Q) wget --retr-symlinks ftp://ftp.iana.org/tz/tzdata-latest.tar.gz
|
|
||||||
|
|
||||||
.tzunpack: tzcode tzcode-latest.tar.gz tzdata-latest.tar.gz
|
|
||||||
$(Q) tar zx -C tzcode -f tzcode-latest.tar.gz
|
|
||||||
$(Q) tar zx -C tzcode -f tzdata-latest.tar.gz
|
|
||||||
$(Q) touch .tzunpack
|
|
||||||
|
|
||||||
.tzbuilt: tzcode tzbin .tzunpack
|
|
||||||
$(Q) $(MAKE) -C tzcode TOPDIR=$(TZBIN_PATH) install
|
|
||||||
$(Q) touch .tzbuilt
|
|
||||||
|
|
||||||
# Create initial context
|
|
||||||
|
|
||||||
context: .tzbuilt romfs
|
|
||||||
|
|
||||||
# Install application
|
|
||||||
|
|
||||||
install:
|
|
||||||
|
|
||||||
# Create dependencies
|
|
||||||
|
|
||||||
.depend: Makefile $(SRCS)
|
|
||||||
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
|
||||||
$(Q) touch $@
|
|
||||||
|
|
||||||
depend: .depend
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(call DELFILE, .built)
|
|
||||||
$(call CLEAN)
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
$(call DELFILE, Make.dep)
|
|
||||||
$(call DELFILE, .depend)
|
|
||||||
$(call DELFILE, .tzunpack)
|
|
||||||
$(call DELFILE, .tzbuilt)
|
|
||||||
$(call DELFILE, romfs_zoneinfo.img)
|
|
||||||
$(call DELFILE, romfs_zoneinfo.h)
|
|
||||||
$(call DELFILE, tzdata-latest.tar.gz)
|
|
||||||
$(call DELFILE, tzcode-latest.tar.gz)
|
|
||||||
$(call DELDIR, tzbin)
|
|
||||||
$(call DELDIR, tzcode)
|
|
||||||
|
|
||||||
-include Make.dep
|
|
||||||
.PHONY:preconfig
|
|
||||||
preconfig:
|
|
||||||
|
|
@ -1,180 +0,0 @@
|
|||||||
apps/system/zoninfo/README.txt
|
|
||||||
Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
|
|
||||||
Directory Contents
|
|
||||||
==================
|
|
||||||
|
|
||||||
This directory contains logic to create a version of the TZ/Olson database.
|
|
||||||
This database is required if localtime() support is selected via
|
|
||||||
CONFIG_LIBC_LOCALTIME. This logic in this directory does the following:
|
|
||||||
|
|
||||||
- It downloads the current TZ database from the IANA website
|
|
||||||
- It downloads the current timezone tools from the same location
|
|
||||||
- It builds the tools and constructs the binary TZ database
|
|
||||||
- It will then, optionally, build a ROMFS filesystem image containing
|
|
||||||
the data base.
|
|
||||||
|
|
||||||
Creating and Mounting a ROMFS TZ Database
|
|
||||||
=========================================
|
|
||||||
|
|
||||||
The ROMFS filesystem image can that be mounted during the boot-up sequence
|
|
||||||
so that it is available for the localtime() logic. There are two steps to
|
|
||||||
doing this:
|
|
||||||
|
|
||||||
- First, a ROM disk device must be created. This is done by calling
|
|
||||||
the function romdisk_register() as described in
|
|
||||||
nuttx/include/nuttx/fs/ramdisk.h. This is an OS level operation
|
|
||||||
and must be done in the board-level logic before your application
|
|
||||||
starts.
|
|
||||||
|
|
||||||
romdisk_register() will create a block driver at /dev/ramN where N
|
|
||||||
is the device minor number that was provided to romdisk_regsiter.
|
|
||||||
|
|
||||||
- The second step is to mount the file system. This step can be
|
|
||||||
performed either in your board configuration logic or by your
|
|
||||||
application using the mount() interface described in
|
|
||||||
nuttx/include/sys/mount.h.
|
|
||||||
|
|
||||||
These steps, however, must be done very early in initialization,
|
|
||||||
before there is any need for time-related services.
|
|
||||||
|
|
||||||
Both of these steps are shown together in the following code sample at the
|
|
||||||
end of this README file.
|
|
||||||
|
|
||||||
Example Configuration
|
|
||||||
=====================
|
|
||||||
|
|
||||||
I have tested this using the sim/nsh configuration. Here are the
|
|
||||||
modifications to the configuration that I used for testing:
|
|
||||||
|
|
||||||
CONFIG_BOARD_INITIALIZE=y
|
|
||||||
|
|
||||||
CONFIG_LIBC_LOCALTIME=y
|
|
||||||
CONFIG_LIBC_TZDIR="/share/zoneinfo"
|
|
||||||
CONFIG_LIBC_TZ_MAX_TIMES=370
|
|
||||||
CONFIG_LIBC_TZ_MAX_TYPES=20
|
|
||||||
|
|
||||||
CONFIG_SYSTEM_ZONEINFO=y
|
|
||||||
CONFIG_SYSTEM_ZONEINFO_ROMFS=y
|
|
||||||
|
|
||||||
NOTE: The full TZ database is quite large. To create a reasonable sized
|
|
||||||
ROMFS image, I had to trim some of the files like this:
|
|
||||||
|
|
||||||
cd nuttx
|
|
||||||
cd tools
|
|
||||||
./configure.sh sim/nsh
|
|
||||||
cd ..
|
|
||||||
make menuconfig
|
|
||||||
|
|
||||||
Select the above localtime() and apps/system/zoneinfo configuration settings.
|
|
||||||
Then:
|
|
||||||
|
|
||||||
make context
|
|
||||||
cd ../apps/system/zoneinfo/tzbin/etc/zoneinfo
|
|
||||||
|
|
||||||
Remove as many timezone files as you can. Do not remove the GMT, localtime,
|
|
||||||
or posixrules files. Those might be needed in any event. Then you can
|
|
||||||
force rebuilding of the ROMFS filesystem be removing some files:
|
|
||||||
|
|
||||||
cd ../../..
|
|
||||||
rm romfs_zoneinfo.*
|
|
||||||
rm *.o
|
|
||||||
cd ../../nuttx
|
|
||||||
make
|
|
||||||
|
|
||||||
If you have problems building the simulator on your platform, check out
|
|
||||||
nuttx/configs/sim/README.txt. You might find some help there.
|
|
||||||
|
|
||||||
Here is a sample run. I have not seen any errors in single stepping through
|
|
||||||
the logic but neither am I certain that everything is working properly:
|
|
||||||
|
|
||||||
NuttShell (NSH)
|
|
||||||
nsh> date
|
|
||||||
Jul 01 00:00:02 2008
|
|
||||||
nsh> set TZ US/Mountain
|
|
||||||
nsh> date -s "Apr 11 11:53:00 2015"
|
|
||||||
nsh> date
|
|
||||||
Apr 11 17:53:00 2015
|
|
||||||
|
|
||||||
NOTE: Because of daylight savings time, US/Mountain is GMT-6 on Apr 11. The
|
|
||||||
above suggests that perhaps the NSH data command may be setting local time,
|
|
||||||
but printing GMT time?
|
|
||||||
|
|
||||||
Sample Code to Mount the ROMFS Filesystem
|
|
||||||
=========================================
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <nuttx/fs/ramdisk.h>
|
|
||||||
#include <apps/zoneinfo.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CONFIG_LIBC_TZDIR
|
|
||||||
# errror CONFIG_LIBC_TZDIR is not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
|
||||||
# error "Mountpoint support is disabled"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS < 4
|
|
||||||
# error "Not enough file descriptors"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONFIG_FS_ROMFS
|
|
||||||
# error "ROMFS support not enabled"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SECTORSIZE 64
|
|
||||||
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int mount_zoneinfo(int minor)
|
|
||||||
{
|
|
||||||
char devname[32];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Create a RAM disk for the test */
|
|
||||||
|
|
||||||
ret = romdisk_register(minor, romfs_zoneinfo_img,
|
|
||||||
NSECTORS(romfs_zoneinfo_img_len), SECTORSIZE);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
printf("ERROR: Failed to create RAM disk\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use the minor number to create a name for the ROM disk block device */
|
|
||||||
|
|
||||||
snprintf(devname, 32, "/dev/ram%d", minor);
|
|
||||||
|
|
||||||
/* Mount the ROMFS file system */
|
|
||||||
|
|
||||||
printf("Mounting ROMFS filesystem at target=%s with source=%s\n",
|
|
||||||
CONFIG_LIBC_TZDIR, devname);
|
|
||||||
|
|
||||||
ret = mount(devname, CONFIG_LIBC_TZDIR, "romfs", MS_RDONLY, NULL);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
printf("ERROR: Mount failed: %d\n", errno);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("TZ database mounted at %s\n", CONFIG_LIBC_TZDIR);
|
|
||||||
return OK;
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* apps/system/zoneinfo/tzromfs.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
#include <apps/zoneinfo.h>
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "romfs_zoneinfo.h"
|
|
Loading…
Reference in New Issue
Block a user