Mercurial > nand-ecoscentric
changeset 2099:de02720a095b
* include/hal_io.h (struct cyg_hal_sys_old_stat): Make the
structure match the kernel version otherwise the stack gets
corrupt and we die 'orribly. Added cyg_hal_sys_new_stat for when
using the new?stat() calls.
* src/synth_syscall.c (cyg_hal_sys_ftok): use the correct structure
member names and use the newstat system call so we get
values back which are compatible with glibc ftok() function.
* tests/ftok.c (new): Test case for the cyg_hal_sys_ftok()
function added in the previous patch.
| author | asl |
|---|---|
| date | Sat, 05 Nov 2005 19:43:24 +0000 |
| parents | f34a4ac8a886 |
| children | b98f84205fdc |
| files | packages/hal/synth/arch/current/ChangeLog packages/hal/synth/arch/current/cdl/hal_synth.cdl packages/hal/synth/arch/current/include/hal_io.h packages/hal/synth/arch/current/src/synth_syscalls.c packages/hal/synth/arch/current/tests/ftok.c |
| diffstat | 5 files changed, 187 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/hal/synth/arch/current/ChangeLog +++ b/packages/hal/synth/arch/current/ChangeLog @@ -1,3 +1,19 @@ +2005-11-05 Andrew Lunn <andrew.lunn@ascom.ch> + + * include/hal_io.h (struct cyg_hal_sys_old_stat): Make the + structure match the kernel version otherwise the stack gets + corrupt and we die 'orribly. Added cyg_hal_sys_new_stat for when + using the new?stat() calls. + * src/synth_syscall.c (cyg_hal_sys_ftok): use the correct structure + member names and use the newstat system call so we get + values back which are compatible with glibc ftok() function. + * tests/ftok.c (new): Test case for the cyg_hal_sys_ftok() + function added in the previous patch. + +2005-10-19 Alexander Neundorf <neundorf@kde.org> + + * src/synth_syscall.c: add cyg_hal_sys_ftok(). + 2005-07-30 Andrew Lunn <andrew.lunn@ascom.ch> * src/synth_diag.c (hal_diag_write_char): Compiler warning fix.
--- a/packages/hal/synth/arch/current/cdl/hal_synth.cdl +++ b/packages/hal/synth/arch/current/cdl/hal_synth.cdl @@ -136,4 +136,26 @@ cdl_package CYGPKG_HAL_SYNTH { calculated { "src/synth.ld" } } + cdl_option CYGSEM_HAL_SYNTH_TESTS { + display "Build the Synth HAL tests" + default_value 0 + description " + The only test at the moment is disabled by default + because it has to be run manually. It should be run both within + eCos and natively on Linux and the results compared" + } + + cdl_component CYGPKG_HAL_SYNTH_TESTS { + display "Synth HAL tests" + active_if CYGSEM_HAL_SYNTH_TESTS + flavor data + no_define + calculated { "tests/ftok.c" } + + make { + <PREFIX>/tests/ftok: <PACKAGE>/tests/ftok.c + @mkdir -p "$(dir $@)" + @$(HOST_CC) -DHOST -g -O2 -o $@ $< || cc -DHOST -g -O2 -o $@ $< || -DHOST gcc -g -O2 -o $@ $< + } + } }
--- a/packages/hal/synth/arch/current/include/hal_io.h +++ b/packages/hal/synth/arch/current/include/hal_io.h @@ -438,21 +438,44 @@ struct cyg_hal_sys_timespec unsigned int tv_nsec; }; -struct cyg_hal_sys_stat +// NOTE: This corresponds to __old_kernel_stat in the kernel sources +// and should be used with cyg_hal_sys_oldstat etc. + +struct cyg_hal_sys_old_stat { - unsigned int dev; /* inode */ - unsigned long ino; /* device */ - unsigned short mode; /* protection */ - unsigned short nlink; /* number of hard links */ - unsigned short uid; /* user ID of owner */ - unsigned short gid; /* group ID of owner */ - unsigned long rdev; /* device type (if inode device) */ - unsigned long size; /* total size, in bytes */ - unsigned int blksize; /* blocksize for filesystem I/O */ - unsigned int blocks; /* number of blocks allocated */ - struct cyg_hal_sys_timespec atime; /* time of last access */ - struct cyg_hal_sys_timespec mtime; /* time of last modification */ - struct cyg_hal_sys_timespec ctime; /* time of last change */ + unsigned short st_dev; /* device */ + unsigned short st_ino; /* inode */ + unsigned short st_mode; /* protection */ + unsigned short st_nlink; /* number of hard links */ + unsigned short st_uid; /* user ID of owner */ + unsigned short st_gid; /* group ID of owner */ + unsigned short st_rdev; /* device type (if inode device) */ + unsigned long st_size; /* total size, in bytes */ + unsigned long st_atime; /* time of last access */ + unsigned long st_mtime; /* time of last modification */ + unsigned long st_ctime; /* time of last change */ +}; + +struct cyg_hal_sys_new_stat +{ + unsigned long st_dev; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned long st_rdev; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long __unused4; + unsigned long __unused5; }; // System calls, or rather the subset that is needed internally or by @@ -514,6 +537,9 @@ externC void * cyg_hal_sys_shma //detach from it again externC int cyg_hal_sys_shmdt (const void* shmaddr); +// Convert a pathname and an identifier into a System V IPC key +externC int cyg_hal_sys_ftok(const char* path, int id); + // The actual implementation appears to return the new brk() value. externC void* cyg_hal_sys_brk(void*); @@ -537,8 +563,19 @@ externC int cyg_hal_sys_mmap externC int cyg_hal_sys_readdir(unsigned int fd, struct cyg_hal_sys_dirent *dp, unsigned int count); -externC int cyg_hal_sys_lstat(const char* name, struct cyg_hal_sys_stat *buf); -externC int cyg_hal_sys_fstat(int fd, struct cyg_hal_sys_stat *buf); +// Old syscall versions +externC int cyg_hal_sys_oldlstat(const char* name, + struct cyg_hal_sys_old_stat *buf); +externC int cyg_hal_sys_oldfstat(int fd, struct cyg_hal_sys_old_stat *buf); +externC int cyg_hal_sys_oldstat(const char* name, + struct cyg_hal_sys_old_stat *buf); +// New syscall versions +externC int cyg_hal_sys_newlstat(const char* name, + struct cyg_hal_sys_new_stat *buf); +externC int cyg_hal_sys_newfstat(int fd, struct cyg_hal_sys_new_stat *buf); +externC int cyg_hal_sys_newstat(const char* name, + struct cyg_hal_sys_old_stat *buf); + externC int cyg_hal_sys_mkdir(const char* path, int mode); // Access to environmental data
--- a/packages/hal/synth/arch/current/src/synth_syscalls.c +++ b/packages/hal/synth/arch/current/src/synth_syscalls.c @@ -34,7 +34,6 @@ // This exception does not invalidate any other reasons why a work based on // this file might be covered by the GNU General Public License. // ------------------------------------------- -//####ECOSGPLCOPYRIGHTEND#### //============================================================================= //#####DESCRIPTIONBEGIN#### // @@ -92,3 +91,15 @@ cyg_hal_sys_mmap(void *addr, unsigned lo return (cyg_hal_sys_mmapx(&args)); } + +int cyg_hal_sys_ftok(const char* path, int id) +{ + struct cyg_hal_sys_old_stat st; + + if (cyg_hal_sys_oldstat(path, &st) != 0) + return (cyg_uint32)-1; + + return (cyg_uint32) (id << 24 | + (st.st_dev & 0xff) << 16 | + (st.st_ino & 0xffff)); +}
new file mode 100644 --- /dev/null +++ b/packages/hal/synth/arch/current/tests/ftok.c @@ -0,0 +1,84 @@ +/*================================================================= +// +// cache.c +// +// SYNTH ftok test +// +//========================================================================== +//####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 2005 Andrew Lunn +// +// eCos is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 2 or (at your option) any later version. +// +// eCos is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with eCos; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or inline functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. However the source code for this file must still be made available +// in accordance with section (3) of the GNU General Public License. +// +// This exception does not invalidate any other reasons why a work based on +// this file might be covered by the GNU General Public License. +// ------------------------------------------- +//####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): asl +// Contributors: asl +// Date: 05/11/2005 +//####DESCRIPTIONEND#### +*/ + +#ifndef HOST +#include <cyg/hal/hal_io.h> +#include <cyg/infra/diag.h> + +#define printf diag_printf +#define ftok cyg_hal_sys_ftok + +#else + +#include <stdio.h> +#include <sys/types.h> +#include <sys/ipc.h> +#endif + +int main(void) +{ + printf("ftok(\"/etc/passwd\",0x12)) = 0x%8x\n", + ftok("/etc/passwd",0x12)); + + printf("ftok(\"/etc/passwd\",0x72)) = 0x%8x\n", + ftok("/etc/passwd",0x72)); + + printf("ftok(\"/boot/vmlinuz\",0x72)) = 0x%8x\n", + ftok("/boot/vmlinuz",0x72)); + + printf("ftok(\"/boot/vmlinuz\",0x12)) = 0x%8x\n", + ftok("/boot/vmlinuz",0x12)); + + return 0; +} + +#ifndef HOST + +externC void +cyg_start( void ) +{ + main(); +} +#endif
