OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /or1k/trunk/rtems-20020807/cpukit/libfs
    from Rev 1028 to Rev 1765
    Reverse comparison

Rev 1028 → Rev 1765

/src/dosfs/msdos_misc.c
0,0 → 1,1087
/*
* Miscellaneous routines implementation for MSDOS filesystem
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_misc.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* This copied from Linux */
static int day_n[] = { 0,31,59,90,120,151,181,212,243,273,304,334,0,0,0,0 };
/* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */
 
#undef CONFIG_ATARI
 
/* MS-DOS "device special files" */
static const char *reserved_names[] = {
#ifndef CONFIG_ATARI /* GEMDOS is less stupid */
"CON ","PRN ","NUL ","AUX ",
"LPT1 ","LPT2 ","LPT3 ","LPT4 ",
"COM1 ","COM2 ","COM3 ","COM4 ",
#endif
NULL };
 
static char bad_chars[] = "*?<>|\"";
#ifdef CONFIG_ATARI
/* GEMDOS is less restrictive */
static char bad_if_strict[] = " ";
#else
static char bad_if_strict[] = "+=,; ";
#endif
 
/* The following three functions copied from Linux */
/*
* Formats an MS-DOS file name. Rejects invalid names
*
* conv is relaxed/normal/strict, name is proposed name,
* len is the length of the proposed name, res is the result name,
* dotsOK is if hidden files get dots.
*/
int
msdos_format_name(char conv, const char *name, int len, char *res,
char dotsOK)
{
char *walk;
const char **reserved;
unsigned char c;
int space;
if (name[0] == '.') { /* dotfile because . and .. already done */
if (!dotsOK) return -EINVAL;
/* Get rid of dot - test for it elsewhere */
name++; len--;
}
#ifndef CONFIG_ATARI
space = 1; /* disallow names that _really_ start with a dot */
#else
space = 0; /* GEMDOS does not care */
#endif
c = 0;
for (walk = res; len && walk-res < 8; walk++) {
c = *name++;
len--;
if (conv != 'r' && strchr(bad_chars,c)) return -EINVAL;
if (conv == 's' && strchr(bad_if_strict,c)) return -EINVAL;
if (c >= 'A' && c <= 'Z' && conv == 's') return -EINVAL;
if (c < ' ' || c == ':' || c == '\\') return -EINVAL;
/* 0xE5 is legal as a first character, but we must substitute 0x05 */
/* because 0xE5 marks deleted files. Yes, DOS really does this. */
/* It seems that Microsoft hacked DOS to support non-US characters */
/* after the 0xE5 character was already in use to mark deleted files. */
if((res==walk) && (c==0xE5)) c=0x05;
if (c == '.') break;
space = (c == ' ');
*walk = (c >= 'a' && c <= 'z') ? c-32 : c;
}
if (space) return -EINVAL;
if (conv == 's' && len && c != '.') {
c = *name++;
len--;
if (c != '.') return -EINVAL;
}
while (c != '.' && len--) c = *name++;
if (c == '.') {
while (walk-res < 8) *walk++ = ' ';
while (len > 0 && walk-res < MSDOS_NAME_MAX) {
c = *name++;
len--;
if (conv != 'r' && strchr(bad_chars,c)) return -EINVAL;
if (conv == 's' && strchr(bad_if_strict,c))
return -EINVAL;
if (c < ' ' || c == ':' || c == '\\')
return -EINVAL;
if (c == '.') {
if (conv == 's')
return -EINVAL;
break;
}
if (c >= 'A' && c <= 'Z' && conv == 's') return -EINVAL;
space = c == ' ';
*walk++ = c >= 'a' && c <= 'z' ? c-32 : c;
}
if (space) return -EINVAL;
if (conv == 's' && len) return -EINVAL;
}
while (walk-res < MSDOS_NAME_MAX) *walk++ = ' ';
for (reserved = reserved_names; *reserved; reserved++)
if (!strncmp(res,*reserved,8)) return -EINVAL;
return 0;
}
 
/* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70) */
unsigned int
msdos_date_dos2unix(unsigned short time_val,unsigned short date)
{
int month,year,secs;
 
month = ((date >> 5) & 15)-1;
year = date >> 9;
secs = (time_val & 31)*2+60*((time_val >> 5) & 63)+
(time_val >> 11)*3600+86400*
((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 &&
month < 2 ? 1 : 0)+3653);
/* days since 1.1.70 plus 80's leap day */
 
return secs;
}
 
 
/* Convert linear UNIX date to a MS-DOS time/date pair */
void msdos_date_unix2dos(int unix_date,
unsigned short *time_val,
unsigned short *date)
{
int day,year,nl_day,month;
 
*time_val = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+
(((unix_date/3600) % 24) << 11);
day = unix_date/86400-3652;
year = day/365;
if ((year+3)/4+365*year > day) year--;
day -= (year+3)/4+365*year;
if (day == 59 && !(year & 3)) {
nl_day = day;
month = 2;
}
else {
nl_day = (year & 3) || day <= 59 ? day : day-1;
for (month = 0; month < 12; month++)
if (day_n[month] > nl_day) break;
}
*date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9);
}
 
 
/* msdos_get_token --
* Routine to get a token (name or separator) from the path.
*
* PARAMETERS:
* path - path to get token from
* ret_token - returned token
* token_len - length of returned token
*
* RETURNS:
* token type, token and token length
*
*/
msdos_token_types_t
msdos_get_token(const char *path, char *ret_token, int *token_len)
{
int rc = RC_OK;
register int i = 0;
msdos_token_types_t type = MSDOS_NAME;
char token[MSDOS_NAME_MAX_WITH_DOT+1];
register char c;
 
/*
* Copy a name into token. (Remember NULL is a token.)
*/
c = path[i];
while ( (!msdos_is_separator(c)) && (i <= MSDOS_NAME_MAX_WITH_DOT) )
{
token[i] = c;
if ( i == MSDOS_NAME_MAX_WITH_DOT )
return MSDOS_INVALID_TOKEN;
if ( !msdos_is_valid_name_char(c) )
return MSDOS_INVALID_TOKEN;
c = path [++i];
}
 
/*
* Copy a seperator into token.
*/
if ( i == 0 )
{
token[i] = c;
if ( token[i] != '\0' )
{
i++;
type = MSDOS_CURRENT_DIR;
}
else
type = MSDOS_NO_MORE_PATH;
}
else if (token[ i-1 ] != '\0')
token[i] = '\0';
 
/*
* Set token_len to the number of characters copied.
*/
*token_len = i;
 
/*
* If we copied something that was not a seperator see if
* it was a special name.
*/
if ( type == MSDOS_NAME )
{
if ( strcmp( token, "..") == 0 )
{
strcpy(ret_token, MSDOS_DOTDOT_NAME);
type = MSDOS_UP_DIR;
return type;
}
 
if ( strcmp( token, "." ) == 0 )
{
strcpy(ret_token, MSDOS_DOT_NAME);
type = MSDOS_CURRENT_DIR;
return type;
}
 
rc = msdos_format_name('r', token, *token_len, ret_token, 0);
if ( rc != RC_OK )
return MSDOS_INVALID_TOKEN;
}
ret_token[MSDOS_NAME_MAX] = '\0';
return type;
}
 
 
/* msdos_find_name --
* Find the node which correspondes to the name, open fat-file which
* correspondes to the found node and close fat-file which correspondes
* to the node we searched in.
*
* PARAMETERS:
* parent_loc - parent node description
* name - name to find
*
* RETURNS:
* RC_OK and updated 'parent_loc' on success, or -1 if error
* occured (errno set apropriately)
*
*/
int
msdos_find_name(
rtems_filesystem_location_info_t *parent_loc,
char *name
)
{
int rc = RC_OK;
msdos_fs_info_t *fs_info = parent_loc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = NULL;
fat_auxiliary_t aux;
unsigned short time_val = 0;
unsigned short date = 0;
unsigned char node_entry[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE];
memset(node_entry, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
/*
* find the node which correspondes to the name in the directory pointed by
* 'parent_loc'
*/
rc = msdos_get_name_node(parent_loc, name, &aux, node_entry);
if (rc != RC_OK)
return rc;
 
/* open fat-file corresponded to the found node */
rc = fat_file_open(parent_loc->mt_entry, aux.cln, aux.ofs, &fat_fd);
if (rc != RC_OK)
return rc;
/*
* I don't like this if, but: we should do it , or should write new file
* size and first cluster num to the disk after each write operation
* (even if one byte is written - that is TOO non-optimize) because
* otherwise real values of these fields stored in fat-file descriptor
* may be accidentely rewritten with wrong values stored on the disk
*/
if (fat_fd->links_num == 1)
{
fat_fd->info_cln = aux.cln;
fat_fd->info_ofs = aux.ofs;
fat_fd->cln = MSDOS_EXTRACT_CLUSTER_NUM(node_entry);
fat_fd->first_char = *MSDOS_DIR_NAME(node_entry);
time_val = *MSDOS_DIR_WRITE_TIME(node_entry);
date = *MSDOS_DIR_WRITE_DATE(node_entry);
fat_fd->mtime = msdos_date_dos2unix(CF_LE_W(time_val), CF_LE_W(date));
if ((*MSDOS_DIR_ATTR(node_entry)) & MSDOS_ATTR_DIRECTORY)
{
fat_fd->fat_file_type = FAT_DIRECTORY;
fat_fd->size_limit = MSDOS_MAX_DIR_LENGHT;
rc = fat_file_size(parent_loc->mt_entry, fat_fd);
if (rc != RC_OK)
{
fat_file_close(parent_loc->mt_entry, fat_fd);
return rc;
}
}
else
{
fat_fd->fat_file_size = CF_LE_L(*MSDOS_DIR_FILE_SIZE(node_entry));
fat_fd->fat_file_type = FAT_FILE;
fat_fd->size_limit = MSDOS_MAX_FILE_SIZE;
}
/* these data is not actual for zero-length fat-file */
fat_fd->map.file_cln = 0;
fat_fd->map.disk_cln = fat_fd->cln;
if ((fat_fd->fat_file_size != 0) &&
(fat_fd->fat_file_size <= fs_info->fat.vol.bpc))
{
fat_fd->map.last_cln = fat_fd->cln;
}
else
{
fat_fd->map.last_cln = FAT_UNDEFINED_VALUE;
}
}
 
/* close fat-file corresponded to the node we searched in */
rc = fat_file_close(parent_loc->mt_entry, parent_loc->node_access);
if (rc != RC_OK)
{
fat_file_close(parent_loc->mt_entry, fat_fd);
return rc;
}
 
/* update node_info_ptr field */
parent_loc->node_access = fat_fd;
return rc;
}
 
/* msdos_get_name_node --
* This routine is used in two ways: for a new mode creation (a) or for
* search the node which correspondes to the name parameter (b).
* In case (a) 'name' should be set up to NULL and 'name_dir_entry' should
* point to initialized 32 bytes structure described a new node.
* In case (b) 'name' should contain a valid string.
*
* (a): reading fat-file which correspondes to directory we are going to
* create node in. If free slot is found write contents of
* 'name_dir_entry' into it. If reach end of fat-file and no free
* slot found, write 32 bytes to the end of fat-file.
*
* (b): reading fat-file which correspondes to directory and trying to
* find slot with the name field == 'name' parameter
*
*
* PARAMETERS:
* parent_loc - node description to create node in or to find name in
* name - NULL or name to find
* paux - identify a node location on the disk -
* cluster num and offset inside the cluster
* name_dir_entry - node to create/placeholder for found node (IN/OUT)
*
* RETURNS:
* RC_OK, filled aux_struct_ptr and name_dir_entry on success, or -1 if
* error occured (errno set apropriately)
*
*/
int
msdos_get_name_node(
rtems_filesystem_location_info_t *parent_loc,
char *name,
fat_auxiliary_t *paux,
char *name_dir_entry
)
{
int rc = RC_OK;
ssize_t ret = 0;
msdos_fs_info_t *fs_info = parent_loc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = parent_loc->node_access;
unsigned32 dotdot_cln = 0;
 
/* find name in fat-file which correspondes to the directory */
rc = msdos_find_name_in_fat_file(parent_loc->mt_entry, fat_fd, name, paux,
name_dir_entry);
if ((rc != RC_OK) && (rc != MSDOS_NAME_NOT_FOUND_ERR))
return rc;
/* if we search for valid name and name not found -> return */
if ((rc == MSDOS_NAME_NOT_FOUND_ERR) && (name != NULL))
return rc;
/*
* if we try to create new entry and the directory is not big enough
* currently - try to enlarge directory
*/
if ((rc == MSDOS_NAME_NOT_FOUND_ERR) && (name == NULL))
{
ret = fat_file_write(parent_loc->mt_entry, fat_fd,
fat_fd->fat_file_size,
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE,
name_dir_entry);
if (ret == -1)
return -1;
 
/* on success directory is enlarged by a new cluster */
fat_fd->fat_file_size += fs_info->fat.vol.bpc;
/* get cluster num where a new node located */
rc = fat_file_ioctl(parent_loc->mt_entry, fat_fd, F_CLU_NUM,
fat_fd->fat_file_size - 1, &paux->cln);
if (rc != RC_OK)
return rc;
 
/*
* if new cluster allocated succesfully then new node is at very
* beginning of the cluster (offset is computed in bytes)
*/
paux->ofs = 0;
return RC_OK;
}
/*
* if we have deal with ".." - it is a special case :(((
*
* Really, we should return cluster num and offset not of ".." slot, but
* slot which correspondes to real directory name.
*/
if ((rc == RC_OK) && (name != NULL))
{
if (strncmp(name, MSDOS_DOTDOT_NAME, MSDOS_SHORT_NAME_LEN) == 0)
{
dotdot_cln = MSDOS_EXTRACT_CLUSTER_NUM((name_dir_entry));
 
/* are we right under root dir ? */
if (dotdot_cln == 0)
{
/*
* we can relax about first_char field - it never should be
* used for root dir
*/
paux->cln = FAT_ROOTDIR_CLUSTER_NUM;
paux->ofs = 0;
}
else
{
rc = msdos_get_dotdot_dir_info_cluster_num_and_offset(
parent_loc->mt_entry,
dotdot_cln,
paux,
name_dir_entry
);
if (rc != RC_OK)
return rc;
}
}
}
return rc;
}
 
/*
* msdos_get_dotdot_dir_info_cluster_num_and_offset
*
* Unfortunately, in general, we cann't work here in fat-file ideologic
* (open fat_file "..", get ".." and ".", open "..", find an entry ...)
* because if we open
* fat-file ".." it may happend that we have two different fat-file
* descriptors ( for real name of directory and ".." name ) for a single
* file ( cluster num of both pointers to the same cluster )
* But...we do it because we protected by semaphore
*
*/
 
/* msdos_get_dotdot_dir_info_cluster_num_and_offset --
* Get cluster num and offset not of ".." slot, but slot which correspondes
* to real directory name.
*
* PARAMETERS:
* mt_entry - mount table entry
* cln - data cluster num extracted drom ".." slot
* paux - identify a node location on the disk -
* number of cluster and offset inside the cluster
* dir_entry - placeholder for found node
*
* RETURNS:
* RC_OK, filled 'paux' and 'dir_entry' on success, or -1 if error occured
* (errno set apropriately)
*
*/
int
msdos_get_dotdot_dir_info_cluster_num_and_offset(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
fat_auxiliary_t *paux,
char *dir_entry
)
{
int rc = RC_OK;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
fat_file_fd_t *fat_fd = NULL;
unsigned char dot_node[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE];
unsigned char dotdot_node[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE];
unsigned char cur_node[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE];
unsigned32 cl4find = 0;
memset(dot_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
memset(dotdot_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
memset(cur_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
/*
* open fat-file corresponded to ".."
*/
rc = fat_file_open(mt_entry, paux->cln, paux->ofs, &fat_fd);
if (rc != RC_OK)
return rc;
fat_fd->info_cln = paux->cln;
fat_fd->info_ofs = paux->ofs;
fat_fd->cln = cln;
fat_fd->fat_file_type = FAT_DIRECTORY;
fat_fd->size_limit = MSDOS_MAX_DIR_LENGHT;
fat_fd->map.file_cln = 0;
fat_fd->map.disk_cln = fat_fd->cln;
 
rc = fat_file_size(mt_entry, fat_fd);
if (rc != RC_OK)
{
fat_file_close(mt_entry, fat_fd);
return rc;
}
/* find "." node in opened directory */
rc = msdos_find_name_in_fat_file(mt_entry, fat_fd, MSDOS_DOT_NAME, paux,
dot_node);
if (rc != RC_OK)
{
fat_file_close(mt_entry, fat_fd);
return rc;
}
/* find ".." node in opened directory */
rc = msdos_find_name_in_fat_file(mt_entry, fat_fd, MSDOS_DOTDOT_NAME, paux,
dotdot_node);
if (rc != RC_OK)
{
fat_file_close(mt_entry, fat_fd);
return rc;
}
 
cl4find = MSDOS_EXTRACT_CLUSTER_NUM(dot_node);
/* close fat-file corresponded to ".." directory */
rc = fat_file_close(mt_entry, fat_fd);
if ( rc != RC_OK )
return rc;
 
if ( (MSDOS_EXTRACT_CLUSTER_NUM(dotdot_node)) == 0)
{
/*
* we handle root dir for all FAT types in the same way with the
* ordinary directories ( through fat_file_* calls )
*/
paux->cln = FAT_ROOTDIR_CLUSTER_NUM;
paux->ofs = 0;
}
 
/* open fat-file corresponded to second ".." */
rc = fat_file_open(mt_entry, paux->cln, paux->ofs, &fat_fd);
if (rc != RC_OK)
return rc;
 
fat_fd->info_cln = paux->cln;
fat_fd->info_ofs = paux->ofs;
 
if ((MSDOS_EXTRACT_CLUSTER_NUM(dotdot_node)) == 0)
fat_fd->cln = fs_info->fat.vol.rdir_cl;
else
fat_fd->cln = MSDOS_EXTRACT_CLUSTER_NUM(dotdot_node);
 
fat_fd->fat_file_type = FAT_DIRECTORY;
fat_fd->size_limit = MSDOS_MAX_DIR_LENGHT;
fat_fd->map.file_cln = 0;
fat_fd->map.disk_cln = fat_fd->cln;
 
rc = fat_file_size(mt_entry, fat_fd);
if (rc != RC_OK)
{
fat_file_close(mt_entry, fat_fd);
return rc;
}
/* in this directory find slot with specified cluster num */
rc = msdos_find_node_by_cluster_num_in_fat_file(mt_entry, fat_fd, cl4find,
paux, dir_entry);
if (rc != RC_OK)
{
fat_file_close(mt_entry, fat_fd);
return rc;
}
rc = fat_file_close(mt_entry, fat_fd);
return rc;
}
 
 
/* msdos_set_dir_wrt_time_and_date --
* Write last write date and time for a file to the disk (to corresponded
* 32bytes node)
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set apropriately).
*
*/
int
msdos_set_dir_wrt_time_and_date(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
)
{
ssize_t ret1 = 0, ret2 = 0;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
unsigned short time_val;
unsigned short date;
unsigned32 sec = 0;
unsigned32 byte = 0;
msdos_date_unix2dos(fat_fd->mtime, &time_val, &date);
/*
* calculate input for _fat_block_write: convert (cluster num, offset) to
* (sector num, new offset)
*/
sec = fat_cluster_num_to_sector_num(mt_entry, fat_fd->info_cln);
sec += (fat_fd->info_ofs >> fs_info->fat.vol.sec_log2);
/* byte points to start of 32bytes structure */
byte = fat_fd->info_ofs & (fs_info->fat.vol.bps - 1);
time_val = CT_LE_W(time_val);
ret1 = _fat_block_write(mt_entry, sec, byte + MSDOS_FILE_WTIME_OFFSET,
2, (char *)(&time_val));
date = CT_LE_W(date);
ret2 = _fat_block_write(mt_entry, sec, byte + MSDOS_FILE_WDATE_OFFSET,
2, (char *)(&date));
 
if ( (ret1 < 0) || (ret2 < 0) )
return -1;
 
return RC_OK;
}
 
/* msdos_set_first_cluster_num --
* Write number of first cluster of the file to the disk (to corresponded
* 32bytes slot)
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
*
* RETURNS:
* RC_OK on success, or -1 if error occured
*
*/
int
msdos_set_first_cluster_num(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
)
{
ssize_t ret1 = 0, ret2 = 0;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 new_cln = fat_fd->cln;
unsigned16 le_cl_low = 0;
unsigned16 le_cl_hi = 0;
unsigned32 sec = 0;
unsigned32 byte = 0;
 
/*
* calculate input for _fat_block_write: convert (cluster num, offset) to
* (sector num, new offset)
*/
sec = fat_cluster_num_to_sector_num(mt_entry, fat_fd->info_cln);
sec += (fat_fd->info_ofs >> fs_info->fat.vol.sec_log2);
/* byte from points to start of 32bytes structure */
byte = fat_fd->info_ofs & (fs_info->fat.vol.bps - 1);
le_cl_low = CT_LE_W((unsigned16)(new_cln & 0x0000FFFF));
ret1 = _fat_block_write(mt_entry, sec,
byte + MSDOS_FIRST_CLUSTER_LOW_OFFSET, 2,
(char *)(&le_cl_low));
le_cl_hi = CT_LE_W((unsigned16)((new_cln & 0xFFFF0000) >> 16));
ret2 = _fat_block_write(mt_entry, sec,
byte + MSDOS_FIRST_CLUSTER_HI_OFFSET, 2,
(char *)(&le_cl_hi));
if ( (ret1 < 0) || (ret2 < 0) )
return -1;
 
return RC_OK;
}
 
 
/* msdos_set_file size --
* Write file size of the file to the disk (to corresponded 32bytes slot)
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set apropriately).
*
*/
int
msdos_set_file_size(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
)
{
ssize_t ret = 0;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 le_new_length = 0;
unsigned32 sec = 0;
unsigned32 byte = 0;
 
sec = fat_cluster_num_to_sector_num(mt_entry, fat_fd->info_cln);
sec += (fat_fd->info_ofs >> fs_info->fat.vol.sec_log2);
byte = (fat_fd->info_ofs & (fs_info->fat.vol.bps - 1));
 
le_new_length = CT_LE_L((fat_fd->fat_file_size));
ret = _fat_block_write(mt_entry, sec, byte + MSDOS_FILE_SIZE_OFFSET, 4,
(char *)(&le_new_length));
if ( ret < 0 )
return -1;
 
return RC_OK;
}
 
/*
* We should not check whether this routine is called for root dir - it
* never can happend
*/
 
/* msdos_set_first_char4file_name --
* Write first character of the name of the file to the disk (to
* corresponded 32bytes slot)
*
* PARAMETERS:
* mt_entry - mount table entry
* cl - number of cluster
* ofs - offset inside cluster
* fchar - character to set up
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set apropriately)
*
*/
int
msdos_set_first_char4file_name(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cl,
unsigned32 ofs,
unsigned char fchar
)
{
ssize_t ret = 0;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 sec = 0;
unsigned32 byte = 0;
 
sec = fat_cluster_num_to_sector_num(mt_entry, cl);
sec += (ofs >> fs_info->fat.vol.sec_log2);
byte = (ofs & (fs_info->fat.vol.bps - 1));
 
ret = _fat_block_write(mt_entry, sec, byte + MSDOS_FILE_NAME_OFFSET, 1,
&fchar);
if ( ret < 0)
return -1;
 
return RC_OK;
}
 
/* msdos_dir_is_empty --
* Check whether directory which correspondes to the fat-file descriptor is
* empty.
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
* ret_val - placeholder for result
*
* RETURNS:
* RC_OK on success, or -1 if error occured
*
*/
int
msdos_dir_is_empty(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
rtems_boolean *ret_val
)
{
ssize_t ret = 0;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 j = 0, i = 0;
/* dir is not empty */
*ret_val = FALSE;
 
while ((ret = fat_file_read(mt_entry, fat_fd, j * fs_info->fat.vol.bps,
fs_info->fat.vol.bps,
fs_info->cl_buf)) != FAT_EOF)
{
if (ret < MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
return -1;
 
assert(ret == fs_info->fat.vol.bps);
for (i = 0;
i < fs_info->fat.vol.bps;
i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
{
if (((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_EMPTY) ||
(strncmp(MSDOS_DIR_NAME((fs_info->cl_buf + i)), MSDOS_DOT_NAME,
MSDOS_SHORT_NAME_LEN) == 0) ||
(strncmp(MSDOS_DIR_NAME((fs_info->cl_buf + i)),
MSDOS_DOTDOT_NAME,
MSDOS_SHORT_NAME_LEN) == 0))
continue;
 
if ((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY)
{
*ret_val = TRUE;
return RC_OK;
}
return RC_OK;
}
j++;
}
*ret_val = TRUE;
return RC_OK;
}
 
 
/* msdos_find_name_in_fat_file --
* This routine is used in two ways: for a new mode creation (a) or for
* search the node which correspondes to the 'name' parameter (b).
* In case (a) name should be set up to NULL and 'name_dir_entry' should
* point to initialized 32 bytes structure described a new node.
* In case (b) 'name' should contain a valid string.
*
* (a): reading fat-file corresponded to directory we are going to create
* node in. If found free slot write contents of name_dir_entry into
* it.
*
* (b): reading fat-file corresponded to directory and trying to find slot
* with the name field == name parameter
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
* name - NULL or name to find
* paux - identify a node location on the disk -
* number of cluster and offset inside the cluster
* name_dir_entry - node to create/placeholder for found node
*
* RETURNS:
* RC_OK on success, or error code if error occured (errno set
* appropriately)
*
*/
int
msdos_find_name_in_fat_file(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
char *name,
fat_auxiliary_t *paux,
char *name_dir_entry
)
{
int rc = RC_OK;
ssize_t ret = 0;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 i = 0, j = 0;
unsigned32 bts2rd = 0;
 
if (FAT_FD_OF_ROOT_DIR(fat_fd) &&
(fs_info->fat.vol.type & (FAT_FAT12 | FAT_FAT16)))
bts2rd = fat_fd->fat_file_size;
else
bts2rd = fs_info->fat.vol.bpc;
while ((ret = fat_file_read(mt_entry, fat_fd, (j * bts2rd), bts2rd,
fs_info->cl_buf)) != FAT_EOF)
{
if (ret < MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
set_errno_and_return_minus_one(EIO);
assert(ret == bts2rd);
 
for (i = 0; i < bts2rd; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
{
/* is the entry empty ? */
if (((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY) ||
((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_EMPTY))
{
/* whether we are looking for an empty entry */
if (name == NULL)
{
/* get current cluster number */
rc = fat_file_ioctl(mt_entry, fat_fd, F_CLU_NUM,
j * bts2rd, &paux->cln);
if (rc != RC_OK)
return rc;
 
/* offset is computed in bytes */
paux->ofs = i;
/* write new node entry */
ret = fat_file_write(mt_entry, fat_fd, j * bts2rd + i,
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE,
name_dir_entry);
if (ret != MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
return -1;
 
/*
* we don't update fat_file_size here - it should not
* increase
*/
return RC_OK;
}
 
/*
* if name != NULL and there is no more entries in the
* directory - return name-not-found
*/
if (((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY))
return MSDOS_NAME_NOT_FOUND_ERR;
}
else
{
/* entry not empty and name != NULL -> compare names */
if (name != NULL)
{
if (strncmp(MSDOS_DIR_NAME((fs_info->cl_buf + i)), name,
MSDOS_SHORT_NAME_LEN) == 0)
{
/*
* we get the entry we looked for - fill auxiliary
* structure and copy all 32 bytes of the entry
*/
rc = fat_file_ioctl(mt_entry, fat_fd, F_CLU_NUM,
j * bts2rd, &paux->cln);
if (rc != RC_OK)
return rc;
 
/* offset is computed in bytes */
paux->ofs = i;
memcpy(name_dir_entry,(fs_info->cl_buf + i),
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
return RC_OK;
}
}
}
}
j++;
}
return MSDOS_NAME_NOT_FOUND_ERR;
}
 
/* msdos_find_node_by_cluster_num_in_fat_file --
* Find node with specified number of cluster in fat-file.
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
* cl4find - number of cluster to find
* paux - identify a node location on the disk -
* cluster num and offset inside the cluster
* dir_entry - placeholder for found node
*
* RETURNS:
* RC_OK on success, or error code if error occured
*
*/
int
msdos_find_node_by_cluster_num_in_fat_file(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 cl4find,
fat_auxiliary_t *paux,
char *dir_entry
)
{
int rc = RC_OK;
ssize_t ret = 0;
msdos_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 bts2rd = 0;
unsigned32 i = 0, j = 0;
 
if (FAT_FD_OF_ROOT_DIR(fat_fd) &&
(fs_info->fat.vol.type & (FAT_FAT12 | FAT_FAT16)))
bts2rd = fat_fd->fat_file_size;
else
bts2rd = fs_info->fat.vol.bpc;
 
while ((ret = fat_file_read(mt_entry, fat_fd, j * bts2rd, bts2rd,
fs_info->cl_buf)) != FAT_EOF)
{
if ( ret < MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE )
set_errno_and_return_minus_one( EIO );
 
assert(ret == bts2rd);
for (i = 0; i < bts2rd; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
{
/* if this and all rest entries are empty - return not-found */
if ((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY)
return MSDOS_NAME_NOT_FOUND_ERR;
 
/* if this entry is empty - skip it */
if ((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_EMPTY)
continue;
 
/* if get a non-empty entry - compare clusters num */
if (MSDOS_EXTRACT_CLUSTER_NUM((fs_info->cl_buf + i)) == cl4find)
{
/* on success fill aux structure and copy all 32 bytes */
rc = fat_file_ioctl(mt_entry, fat_fd, F_CLU_NUM, j * bts2rd,
&paux->cln);
if (rc != RC_OK)
return rc;
 
paux->ofs = i;
memcpy(dir_entry, fs_info->cl_buf + i,
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
return RC_OK;
}
}
j++;
}
return MSDOS_NAME_NOT_FOUND_ERR;
}
/src/dosfs/Makefile.in
0,0 → 1,508
# Makefile.in generated by automake 1.6.2 from Makefile.am.
# @configure_input@
 
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
 
@SET_MAKE@
SHELL = @SHELL@
 
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
 
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
 
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
 
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
 
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PATH_SEPARATOR = @PATH_SEPARATOR@
AMTAR = @AMTAR@
AWK = @AWK@
BARE_CPU_CFLAGS = @BARE_CPU_CFLAGS@
BARE_CPU_MODEL = @BARE_CPU_MODEL@
 
CC = @CC@ $(GCCSPECS)
CPP = @CPP@ $(GCCSPECS)
DEPDIR = @DEPDIR@
ENDIF = @ENDIF@
GCCSED = @GCCSED@
GCC_SPECS = @GCC_SPECS@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
MAINT = @MAINT@
MAKE = @MAKE@
MULTIBUILDTOP = @MULTIBUILDTOP@
MULTISUBDIR = @MULTISUBDIR@
PACKAGE = @PACKAGE@
PROJECT_INCLUDE = @PROJECT_INCLUDE@
PROJECT_ROOT = @PROJECT_ROOT@
PROJECT_TOPdir = @PROJECT_TOPdir@
RANLIB = @RANLIB@
RTEMS_BSP = @RTEMS_BSP@
RTEMS_CPU = @RTEMS_CPU@
RTEMS_HOST = @RTEMS_HOST@
RTEMS_ROOT = @RTEMS_ROOT@
RTEMS_TOPdir = @RTEMS_TOPdir@
STRIP = @STRIP@
VERSION = @VERSION@
am__include = @am__include@
am__quote = @am__quote@
install_sh = @install_sh@
multilib_basedir = @multilib_basedir@
project_libdir = @project_libdir@
 
@MULTILIB_TRUE@MULTISRCTOP =
@MULTILIB_TRUE@MULTIDIRS =
@MULTILIB_TRUE@MULTIDO = true
@MULTILIB_TRUE@MULTICLEAN = true
 
@RTEMS_USE_GCC_TRUE@CFLAGS_DEFAULT = -g -Wall
@RTEMS_USE_GCC_TRUE@GCCSPECS = $(GCC_SPECS)
 
DEFS = @DEFS@
 
CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) \
$(DEFINES) $(XCPPFLAGS) $(CPPFLAGS_GCC)
 
CFLAGS = $(CFLAGS_DEFAULT) $(CPU_CFLAGS) $(XCFLAGS)
ASFLAGS = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS)
 
# when debugging, optimize flag: typically empty
# some compilers do allow optimization with their "-g"
CFLAGS_DEBUG_OPTIMIZE_V = -g
 
# profile flag; use gprof(1)
CFLAGS_PROFILE_V = -pg
 
 
#
# How to compile stuff into ${ARCH} subdirectory
#
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 
CCLD = $(CC)
 
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
 
 
# Dependency files for use by gmake
# NOTE: we don't put them into $(ARCH)
# so that 'make clean' doesn't blow it away
DEPEND = Depends-${ARCH}
 
CLEAN_DEPEND = $(DEPEND).tmp
CLOBBER_DEPEND = $(DEPEND)
 
VARIANT = OPTIMIZE
 
VARIANT_OPTIMIZE_V = OPTIMIZE
VARIANT_DEBUG_V = DEBUG
VARIANT_PROFILE_V = PROFILE
VARIANT_optimize_V = OPTIMIZE
VARIANT_debug_V = DEBUG
VARIANT_profile_V = PROFILE
 
VARIANT_V = $(VARIANT_$(VARIANT)_V)
 
ARCH_OPTIMIZE_V = o-optimize
ARCH_DEBUG_V = o-debug
ARCH_PROFILE_V = o-profile
 
ARCH__V = $(ARCH_OPTIMIZE_V)
ARCH = $(ARCH_$(VARIANT_V)_V)
 
LIBSUFFIX_OPTIMIZE_V =
LIBSUFFIX_DEBUG_V = _g
LIBSUFFIX_PROFILE_V = _p
LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V)
 
LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V)
LIBSUFFIX_VA = $(LIB_VARIANT).a
 
CFLAGS__V = $(CFLAGS_OPTIMIZE_V)
 
@RTEMS_USE_GCC_TRUE@RTEMS_CFLAGS_OPTIMIZE_V =
@RTEMS_USE_GCC_TRUE@RTEMS_CFLAGS_DEBUG_V = -Wno-unused
@RTEMS_USE_GCC_TRUE@RTEMS_CFLAGS_PROFILE_V =
 
RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V)
 
AM_CPPFLAGS = $(RTEMS_CPPFLAGS) -I../.. $(LIBC_DEFINES)
 
AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
 
# AM_CFLAGS = $(RTEMS_BSP_CFLAGS) $(RTEMS_CFLAGS)
AM_CCASFLAGS = $(RTEMS_BSP_CFLAGS) $(RTEMS_CPPFLAGS) $(RTEMS_ASFLAGS)
 
AR = @AR@
 
ARFLAGS = ruv
 
TMPINSTALL_FILES = $(project_libdir)$(MULTISUBDIR) $(H_FILES)
 
FATFS_C_FILES = fat.c fat_fat_operations.c fat_file.c
 
DOSFS_C_FILES = msdos_create.c msdos_dir.c msdos_eval.c msdos_file.c \
msdos_free.c msdos_fsunmount.c msdos_handlers_dir.c \
msdos_handlers_file.c msdos_init.c msdos_initsupp.c \
msdos_misc.c msdos_mknod.c msdos_node_type.c
 
 
@UNIX_FALSE@LIB = ${ARCH}/libdosfs.a
 
@UNIX_FALSE@C_FILES = $(FATFS_C_FILES) $(DOSFS_C_FILES)
 
@UNIX_FALSE@C_O_FILES = $(C_FILES:%.c=${ARCH}/%.$(OBJEXT))
 
@UNIX_FALSE@include_HEADERS = dosfs.h
 
@UNIX_FALSE@H_FILES = $(PROJECT_INCLUDE) \
@UNIX_FALSE@ $(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
 
 
@UNIX_FALSE@OBJS = $(C_O_FILES)
 
EXTRA_DIST = $(DOSFS_C_FILES) $(FATFS_C_FILES)
 
PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools
subdir = src/dosfs
mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
HEADERS = $(include_HEADERS)
 
DIST_COMMON = $(include_HEADERS) Makefile.am Makefile.in
all: all-am
 
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/../automake/multilib.am $(top_srcdir)/../automake/compile.am $(top_srcdir)/../automake/lib.am $(top_srcdir)/../automake/local.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign src/dosfs/Makefile
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
uninstall-info-am:
includeHEADERS_INSTALL = $(INSTALL_HEADER)
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f"; \
$(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f; \
done
 
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(include_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f $(DESTDIR)$(includedir)/$$f"; \
rm -f $(DESTDIR)$(includedir)/$$f; \
done
 
ETAGS = etags
ETAGSFLAGS =
 
tags: TAGS
 
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
 
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
 
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
 
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 
top_distdir = ../..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
 
distdir: $(DISTFILES)
@list='$(DISTFILES)'; for file in $$list; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS) all-local
 
installdirs:
$(mkinstalldirs) $(DESTDIR)$(includedir)
 
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
 
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
 
clean-generic:
 
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
 
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
 
clean-am: clean-generic clean-local mostlyclean-am
 
distclean: distclean-am
 
distclean-am: clean-am distclean-generic distclean-local distclean-tags
 
dvi: dvi-am
 
dvi-am:
 
info: info-am
 
info-am:
 
install-data-am: install-includeHEADERS
 
install-exec-am:
 
install-info: install-info-am
 
install-man:
 
installcheck-am:
 
maintainer-clean: maintainer-clean-am
 
maintainer-clean-am: distclean-am maintainer-clean-generic
 
mostlyclean: mostlyclean-am
 
mostlyclean-am: mostlyclean-generic
 
uninstall-am: uninstall-includeHEADERS uninstall-info-am
 
.PHONY: GTAGS all all-am all-local check check-am clean clean-generic \
clean-local distclean distclean-generic distclean-local \
distclean-tags distdir dvi dvi-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-includeHEADERS install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic tags \
uninstall uninstall-am uninstall-includeHEADERS \
uninstall-info-am
 
 
# Multilib support rules
.PHONY: all-multi install-multi mostlyclean-multi clean-multi distclean-multi \
maintainer-clean-multi
 
@MULTILIB_TRUE@all-recursive: all-multi
@MULTILIB_TRUE@install-recursive: install-multi
 
@MULTILIB_TRUE@mostlyclean-recursive: mostlyclean-multi
@MULTILIB_TRUE@clean-recursive: clean-multi
@MULTILIB_TRUE@distclean-recursive: distclean-multi
@MULTILIB_TRUE@maintainer-clean-recursive: maintainer-clean-multi
 
@MULTILIB_TRUE@all-multi:
@MULTILIB_TRUE@ $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do
@MULTILIB_TRUE@install-multi:
@MULTILIB_TRUE@ $(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do
 
@MULTILIB_TRUE@mostlyclean-multi:
@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean
@MULTILIB_TRUE@clean-multi:
@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean
@MULTILIB_TRUE@distclean-multi:
@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean
@MULTILIB_TRUE@maintainer-clean-multi:
@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean
@MULTILIB_FALSE@include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
@RTEMS_USE_GCC_FALSE@include $(CONFIG.CC)
 
${ARCH}/%.$(OBJEXT): %.c
${COMPILE} -o $@ -c $<
 
${ARCH}/%.$(OBJEXT): %.S
${CCASCOMPILE} -o $@ -c $<
 
# Make foo.rel from foo.$(OBJEXT)
${ARCH}/%.rel: ${ARCH}/%.$(OBJEXT)
${make-rel}
 
# We deliberately don't have anything depend on the
# $(DEPEND) file; otherwise it will get rebuilt even
# on 'make clean'
#
 
depend-am: $(C_FILES) $(CC_FILES) $(S_FILES)
$(COMPILE) -M $^ | \
sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \
-e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp
mv $(DEPEND).tmp $(DEPEND)
depend: depend-am
 
# pull in dependencies if they exist
ifeq (${DEPEND},$(wildcard ${DEPEND}))
include ${DEPEND}
@ENDIF@
 
define make-library
$(RM) $@
$(AR) $(ARFLAGS) $@ $^
$(RANLIB) $@
endef
 
$(project_libdir)$(MULTISUBDIR):
@$(mkinstalldirs) $@
 
.PRECIOUS: $(LIB)
 
@UNIX_FALSE@$(PROJECT_INCLUDE):
@UNIX_FALSE@ @$(mkinstalldirs) $@
 
@UNIX_FALSE@$(PROJECT_INCLUDE)/%.h: %.h
@UNIX_FALSE@ $(INSTALL_DATA) $< $@
 
#
# Add local stuff here using +=
#
@UNIX_FALSE@all-local: ${ARCH} $(LIB)
 
@UNIX_FALSE@$(LIB): ${OBJS}
@UNIX_FALSE@ $(make-library)
 
debug:
@echo
@echo "\"make debug\" is obsolete, instead use:"
@echo " make VARIANT=DEBUG"
@echo
 
.PHONY: debug
 
profile:
@echo
@echo "\"make profile\" is obsolete, instead use:"
@echo " make VARIANT=PROFILE"
@echo
 
.PHONY: profile
 
preinstall-am: $(PREINSTALL_FILES)
preinstall: preinstall-am
.PHONY: preinstall preinstall-am
 
depend-am:
depend: depend-am
.PHONY: depend depend-am
 
${ARCH}:
mkdir ${ARCH}
 
clean-local:
$(RM) -r o-optimize o-debug o-profile $(CLEANDIRS)
$(RM) Depends-o-optimize.tmp Depends-o-debug.tmp Depends-o-profile.tmp
 
distclean-local:
$(RM) Depends-o-optimize Depends-o-debug Depends-o-profile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
/src/dosfs/msdos_fsunmount.c
0,0 → 1,71
/*
* MSDOS shut down handler implementation
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_fsunmount.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
 
#include <assert.h>
#include <rtems.h>
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_shut_down --
* Shut down MSDOS filesystem - free all allocated resources (don't
* return if deallocation of some resource failed - free as much as
* possible).
*
* PARAMETERS:
* temp_mt_entry - mount table entry
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set apropriately).
*
*/
int
msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry)
{
int rc = RC_OK;
msdos_fs_info_t *fs_info = temp_mt_entry->fs_info;
fat_file_fd_t *fat_fd = temp_mt_entry->mt_fs_root.node_access;
 
/* close fat-file which correspondes to root directory */
if (fat_file_close(temp_mt_entry, fat_fd) != RC_OK)
{
/* no return - try to free as much as possible */
rc = -1;
}
 
if (fat_shutdown_drive(temp_mt_entry) != RC_OK)
{
/* no return - try to free as much as possible */
rc = -1;
}
rtems_semaphore_delete(fs_info->vol_sema);
free(fs_info->cl_buf);
free(temp_mt_entry->fs_info);
return rc;
}
/src/dosfs/msdos_handlers_dir.c
0,0 → 1,36
/*
* Directory Handlers Table for MSDOS filesystem
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_handlers_dir.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <rtems/libio.h>
#include "msdos.h"
 
rtems_filesystem_file_handlers_r msdos_dir_handlers = {
msdos_dir_open,
msdos_dir_close,
msdos_dir_read,
NULL, /* msdos_dir_write */
NULL, /* msdos_dir_ioctl */
msdos_dir_lseek,
msdos_dir_stat,
NULL,
NULL, /* msdos_dir_ftruncate */
NULL,
msdos_dir_sync,
msdos_dir_sync,
NULL, /* msdos_dir_fcntl */
msdos_dir_rmnod
};
/src/dosfs/msdos_handlers_file.c
0,0 → 1,36
/*
* File Operations Table for MSDOS filesystem
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_handlers_file.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <rtems/libio.h>
#include "msdos.h"
 
rtems_filesystem_file_handlers_r msdos_file_handlers = {
msdos_file_open,
msdos_file_close,
msdos_file_read,
msdos_file_write,
msdos_file_ioctl,
msdos_file_lseek,
msdos_file_stat,
NULL,
msdos_file_ftruncate,
NULL,
msdos_file_sync,
msdos_file_datasync,
NULL, /* msdos_file_fcntl */
msdos_file_rmnod
};
/src/dosfs/fat_fat_operations.c
0,0 → 1,445
/*
* fat_fat_operations.c
*
* General operations on File Allocation Table
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* @(#) fat_fat_operations.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <assert.h>
 
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
 
/* fat_scan_fat_for_free_clusters --
* Allocate chain of free clusters from Files Allocation Table
*
* PARAMETERS:
* mt_entry - mount table entry
* chain - the number of the first allocated cluster (first cluster
* in the chain)
* count - count of clusters to allocate (chain length)
*
* RETURNS:
* RC_OK on success, or error code if error occured (errno set
* appropriately)
*
*
*/
int
fat_scan_fat_for_free_clusters(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 *chain,
unsigned32 count,
unsigned32 *cls_added,
unsigned32 *last_cl
)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cl4find = 2;
unsigned32 next_cln = 0;
unsigned32 save_cln = 0;
unsigned32 data_cls_val = fs_info->vol.data_cls + 2;
unsigned32 i = 2;
*cls_added = 0;
 
if (count == 0)
return rc;
if ((fs_info->vol.type & FAT_FAT32) &&
(fs_info->vol.next_cl != FAT_UNDEFINED_VALUE))
cl4find = fs_info->vol.next_cl;
 
/*
* fs_info->vol.data_cls is exactly the count of data clusters
* starting at cluster 2, so the maximum valid cluster number is
* (fs_info->vol.data_cls + 1)
*/
while (i < data_cls_val)
{
rc = fat_get_fat_cluster(mt_entry, cl4find, &next_cln);
if ( rc != RC_OK )
{
if (*cls_added != 0)
fat_free_fat_clusters_chain(mt_entry, (*chain));
return rc;
}
 
if ((next_cln & fs_info->vol.mask) == FAT_GENFAT_FREE)
{
/*
* We are enforced to process allocation of the first free cluster
* by separate 'if' statement because otherwise undo function
* wouldn't work properly
*/
if (*cls_added == 0)
{
*chain = cl4find;
rc = fat_set_fat_cluster(mt_entry, cl4find, FAT_GENFAT_EOC);
if ( rc != RC_OK )
{
/*
* this is the first cluster we tried to allocate so no
* cleanup activity needed
*/
return rc;
}
}
else
{
/* set EOC value to new allocated cluster */
rc = fat_set_fat_cluster(mt_entry, cl4find, FAT_GENFAT_EOC);
if ( rc != RC_OK )
{
/* cleanup activity */
fat_free_fat_clusters_chain(mt_entry, (*chain));
return rc;
}
 
rc = fat_set_fat_cluster(mt_entry, save_cln, cl4find);
if ( rc != RC_OK )
{
/* cleanup activity */
fat_free_fat_clusters_chain(mt_entry, (*chain));
/* trying to save last allocated cluster for future use */
fat_set_fat_cluster(mt_entry, cl4find, FAT_GENFAT_FREE);
fat_buf_release(fs_info);
return rc;
}
}
 
save_cln = cl4find;
(*cls_added)++;
 
/* have we satisfied request ? */
if (*cls_added == count)
{
if (fs_info->vol.type & FAT_FAT32)
{
fs_info->vol.next_cl = save_cln;
if (fs_info->vol.free_cls != 0xFFFFFFFF)
fs_info->vol.free_cls -= (*cls_added);
}
*last_cl = save_cln;
fat_buf_release(fs_info);
return rc;
}
}
i++;
cl4find++;
if (cl4find >= data_cls_val)
cl4find = 2;
}
 
if (fs_info->vol.type & FAT_FAT32)
{
fs_info->vol.next_cl = save_cln;
if (fs_info->vol.free_cls != 0xFFFFFFFF)
fs_info->vol.free_cls -= (*cls_added);
}
*last_cl = save_cln;
fat_buf_release(fs_info);
return RC_OK;
}
 
/* fat_free_fat_clusters_chain --
* Free chain of clusters in Files Allocation Table.
*
* PARAMETERS:
* mt_entry - mount table entry
* chain - number of the first cluster in the chain
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
fat_free_fat_clusters_chain(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 chain
)
{
int rc = RC_OK, rc1 = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cur_cln = chain;
unsigned32 next_cln = 0;
unsigned32 freed_cls_cnt = 0;
while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
{
rc = fat_get_fat_cluster(mt_entry, cur_cln, &next_cln);
if ( rc != RC_OK )
{
if ((fs_info->vol.type & FAT_FAT32) &&
(fs_info->vol.free_cls != FAT_UNDEFINED_VALUE))
fs_info->vol.free_cls += freed_cls_cnt;
fat_buf_release(fs_info);
return rc;
}
 
rc = fat_set_fat_cluster(mt_entry, cur_cln, FAT_GENFAT_FREE);
if ( rc != RC_OK )
rc1 = rc;
 
freed_cls_cnt++;
cur_cln = next_cln;
}
 
if (fs_info->vol.type & FAT_FAT32)
{
fs_info->vol.next_cl = chain;
if (fs_info->vol.free_cls != FAT_UNDEFINED_VALUE)
fs_info->vol.free_cls += freed_cls_cnt;
}
 
fat_buf_release(fs_info);
if (rc1 != RC_OK)
return rc1;
 
return RC_OK;
}
 
/* fat_get_fat_cluster --
* Fetches the contents of the cluster (link to next cluster in the chain)
* from Files Allocation Table.
*
* PARAMETERS:
* mt_entry - mount table entry
* cln - number of cluster to fetch the contents from
* ret_val - contents of the cluster 'cln' (link to next cluster in
* the chain)
*
* RETURNS:
* RC_OK on success, or -1 if error occured
* and errno set appropriately
*/
int
fat_get_fat_cluster(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
unsigned32 *ret_val
)
{
int rc = RC_OK;
register fat_fs_info_t *fs_info = mt_entry->fs_info;
bdbuf_buffer *block0 = NULL;
unsigned32 sec = 0;
unsigned32 ofs = 0;
 
/* sanity check */
if ( (cln < 2) || (cln > (fs_info->vol.data_cls + 1)) )
set_errno_and_return_minus_one(EIO);
 
sec = (FAT_FAT_OFFSET(fs_info->vol.type, cln) >> fs_info->vol.sec_log2) +
fs_info->vol.afat_loc;
ofs = FAT_FAT_OFFSET(fs_info->vol.type, cln) & (fs_info->vol.bps - 1);
 
rc = fat_buf_access(fs_info, sec, FAT_OP_TYPE_READ, &block0);
if (rc != RC_OK)
return rc;
 
switch ( fs_info->vol.type )
{
case FAT_FAT12:
/*
* we are enforced in complex computations for FAT12 to escape CPU
* align problems for some architectures
*/
*ret_val = (*((unsigned8 *)(block0->buffer + ofs)));
if ( ofs == (fs_info->vol.bps - 1) )
{
rc = fat_buf_access(fs_info, sec + 1, FAT_OP_TYPE_READ,
&block0);
if (rc != RC_OK)
return rc;
 
*ret_val |= (*((unsigned8 *)(block0->buffer)))<<8;
}
else
{
*ret_val |= (*((unsigned8 *)(block0->buffer + ofs + 1)))<<8;
}
 
if ( FAT_CLUSTER_IS_ODD(cln) )
*ret_val = (*ret_val) >> FAT12_SHIFT;
else
*ret_val = (*ret_val) & FAT_FAT12_MASK;
 
break;
 
case FAT_FAT16:
*ret_val = *((unsigned16 *)(block0->buffer + ofs));
*ret_val = CF_LE_W(*ret_val);
break;
 
case FAT_FAT32:
*ret_val = *((unsigned32 *)(block0->buffer + ofs));
*ret_val = CF_LE_L(*ret_val);
break;
 
default:
set_errno_and_return_minus_one(EIO);
break;
}
 
return RC_OK;
}
 
/* fat_set_fat_cluster --
* Set the contents of the cluster (link to next cluster in the chain)
* from Files Allocation Table.
*
* PARAMETERS:
* mt_entry - mount table entry
* cln - number of cluster to set contents to
* in_val - value to set
*
* RETURNS:
* RC_OK on success, or -1 if error occured
* and errno set appropriately
*/
int
fat_set_fat_cluster(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
unsigned32 in_val
)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 sec = 0;
unsigned32 ofs = 0;
unsigned16 fat16_clv = 0;
unsigned32 fat32_clv = 0;
bdbuf_buffer *block0 = NULL;
 
/* sanity check */
if ( (cln < 2) || (cln > (fs_info->vol.data_cls + 1)) )
set_errno_and_return_minus_one(EIO);
 
sec = (FAT_FAT_OFFSET(fs_info->vol.type, cln) >> fs_info->vol.sec_log2) +
fs_info->vol.afat_loc;
ofs = FAT_FAT_OFFSET(fs_info->vol.type, cln) & (fs_info->vol.bps - 1);
rc = fat_buf_access(fs_info, sec, FAT_OP_TYPE_READ, &block0);
if (rc != RC_OK)
return rc;
 
switch ( fs_info->vol.type )
{
case FAT_FAT12:
if ( FAT_CLUSTER_IS_ODD(cln) )
{
fat16_clv = CT_LE_W((((unsigned16)in_val) << FAT_FAT12_SHIFT));
 
*((unsigned8 *)(block0->buffer + ofs)) =
(*((unsigned8 *)(block0->buffer + ofs))) & 0x0F;
 
*((unsigned8 *)(block0->buffer + ofs)) =
(*((unsigned8 *)(block0->buffer + ofs))) |
(unsigned8)(fat16_clv & 0x00FF);
 
fat_buf_mark_modified(fs_info);
if ( ofs == (fs_info->vol.bps - 1) )
{
rc = fat_buf_access(fs_info, sec + 1, FAT_OP_TYPE_READ,
&block0);
if (rc != RC_OK)
return rc;
 
*((unsigned8 *)(block0->buffer)) &= 0x00;
*((unsigned8 *)(block0->buffer)) =
(*((unsigned8 *)(block0->buffer))) |
(unsigned8)((fat16_clv & 0xFF00)>>8);
fat_buf_mark_modified(fs_info);
}
else
{
*((unsigned8 *)(block0->buffer + ofs + 1)) &= 0x00;
*((unsigned8 *)(block0->buffer + ofs + 1)) =
(*((unsigned8 *)(block0->buffer + ofs + 1))) |
(unsigned8)((fat16_clv & 0xFF00)>>8);
}
}
else
{
fat16_clv = CT_LE_W((((unsigned16)in_val) & FAT_FAT12_MASK));
 
*((unsigned8 *)(block0->buffer + ofs)) &= 0x00;
 
*((unsigned8 *)(block0->buffer + ofs)) =
(*((unsigned8 *)(block0->buffer + ofs))) |
(unsigned8)(fat16_clv & 0x00FF);
fat_buf_mark_modified(fs_info);
if ( ofs == (fs_info->vol.bps - 1) )
{
rc = fat_buf_access(fs_info, sec + 1, FAT_OP_TYPE_READ,
&block0);
if (rc != RC_OK)
return rc;
 
*((unsigned8 *)(block0->buffer)) =
(*((unsigned8 *)(block0->buffer))) & 0xF0;
*((unsigned8 *)(block0->buffer)) =
(*((unsigned8 *)(block0->buffer))) |
(unsigned8)((fat16_clv & 0xFF00)>>8);
fat_buf_mark_modified(fs_info);
}
else
{
*((unsigned8 *)(block0->buffer + ofs + 1)) =
(*((unsigned8 *)(block0->buffer + ofs + 1))) & 0xF0;
 
*((unsigned8 *)(block0->buffer + ofs+1)) =
(*((unsigned8 *)(block0->buffer + ofs+1))) |
(unsigned8)((fat16_clv & 0xFF00)>>8);
}
}
break;
 
case FAT_FAT16:
*((unsigned16 *)(block0->buffer + ofs)) =
(unsigned16)(CT_LE_W(in_val));
fat_buf_mark_modified(fs_info);
break;
 
case FAT_FAT32:
fat32_clv = CT_LE_L((in_val & FAT_FAT32_MASK));
 
*((unsigned32 *)(block0->buffer + ofs)) =
(*((unsigned32 *)(block0->buffer + ofs))) & (CT_LE_L(0xF0000000));
 
*((unsigned32 *)(block0->buffer + ofs)) =
fat32_clv | (*((unsigned32 *)(block0->buffer + ofs)));
fat_buf_mark_modified(fs_info);
break;
 
default:
set_errno_and_return_minus_one(EIO);
break;
 
}
 
return RC_OK;
}
/src/dosfs/msdos_create.c
0,0 → 1,208
/*
* Routine to create a new MSDOS filesystem node
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_create.c,v 1.1 2002/02/28 20:43:50 joel Exp
*
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <rtems/libio_.h>
#include <time.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_creat_node --
* Create a new node. If a new node is file, FAT 32 Bytes Directory
* Entry Structure (see M$ White Paper) is initialized, free space is
* found in parent directory and structure is written to the disk.
* In case of directory, all above steps present and also new cluster
* is allocated for a new directory and dot and dotdot nodes are created
* in alloceted cluster.
*
* PARAMETERS:
* parent_loc - parent (directory we are going to create node in)
* type - new node type (file or directory)
* name - new node name
* mode - mode
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately).
*
*/
int
msdos_creat_node(
rtems_filesystem_location_info_t *parent_loc,
msdos_node_type_t type,
char *name,
mode_t mode
)
{
int rc = RC_OK;
ssize_t ret = 0;
msdos_fs_info_t *fs_info = parent_loc->mt_entry->fs_info;
fat_file_fd_t *parent_fat_fd = parent_loc->node_access;
fat_file_fd_t *fat_fd = NULL;
time_t time_ret = 0;
unsigned16 time_val = 0;
unsigned16 date = 0;
fat_auxiliary_t aux;
unsigned char new_node[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE];
unsigned char dot_dotdot[MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2];
memset(new_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
memset(dot_dotdot, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2);
/* set up name */
strncpy(MSDOS_DIR_NAME(new_node), name, MSDOS_NAME_MAX);
 
/* fill reserved field */
*MSDOS_DIR_NT_RES(new_node) = MSDOS_RES_NT_VALUE;
/* set up last write date and time */
time_ret = time(NULL);
if ( time_ret == -1 )
return -1;
 
msdos_date_unix2dos(time_ret, &time_val, &date);
*MSDOS_DIR_WRITE_TIME(new_node) = CT_LE_W(time_val);
*MSDOS_DIR_WRITE_DATE(new_node) = CT_LE_W(date);
/* initialize directory/file size */
*MSDOS_DIR_FILE_SIZE(new_node) = MSDOS_INIT_DIR_SIZE;
 
if (type == MSDOS_DIRECTORY)
*MSDOS_DIR_ATTR(new_node) |= MSDOS_ATTR_DIRECTORY;
else
*MSDOS_DIR_ATTR(new_node) |= MSDOS_ATTR_ARCHIVE;
 
/*
* find free space in the parent directory and write new initialized
* FAT 32 Bytes Directory Entry Structure (see M$ White Paper)
* to the disk
*/
rc = msdos_get_name_node(parent_loc, NULL, &aux, new_node);
if ( rc != RC_OK )
return rc;
/*
* if we create a new file we are done, if directory there are more steps
* to do
*/
if (type == MSDOS_DIRECTORY)
{
/* open new directory as fat-file */
rc = fat_file_open(parent_loc->mt_entry, aux.cln, aux.ofs, &fat_fd);
if (rc != RC_OK)
goto err;
 
/*
* we opened fat-file for node we just created, so initialize fat-file
* descritor
*/
fat_fd->info_cln = aux.cln;
fat_fd->info_ofs = aux.ofs;
fat_fd->fat_file_size = 0;
fat_fd->fat_file_type = FAT_DIRECTORY;
fat_fd->size_limit = MSDOS_MAX_DIR_LENGHT;
/*
* dot and dotdot entries are identical to new node except the
* names
*/
memcpy(DOT_NODE_P(dot_dotdot), new_node,
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
memcpy(DOTDOT_NODE_P(dot_dotdot), new_node,
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
memcpy(MSDOS_DIR_NAME(DOT_NODE_P(dot_dotdot)), MSDOS_DOT_NAME,
MSDOS_NAME_MAX);
memcpy(MSDOS_DIR_NAME(DOTDOT_NODE_P(dot_dotdot)), MSDOS_DOTDOT_NAME,
MSDOS_NAME_MAX);
/* set up cluster num for dotdot entry */
/*
* here we can ommit FAT32 condition because for all FAT types dirs
* right under root dir should contain 0 in dotdot entry but for
* FAT12/16 parent_fat_fd->cluster_num always contains such value
*/
if ((FAT_FD_OF_ROOT_DIR(parent_fat_fd)) &&
(fs_info->fat.vol.type & FAT_FAT32))
{
*MSDOS_DIR_FIRST_CLUSTER_LOW(DOTDOT_NODE_P(dot_dotdot)) = 0x0000;
*MSDOS_DIR_FIRST_CLUSTER_HI(DOTDOT_NODE_P(dot_dotdot)) = 0x0000;
}
else
{
*MSDOS_DIR_FIRST_CLUSTER_LOW(DOTDOT_NODE_P(dot_dotdot)) =
CT_LE_W((unsigned16)((parent_fat_fd->cln) & 0x0000FFFF));
*MSDOS_DIR_FIRST_CLUSTER_HI(DOTDOT_NODE_P(dot_dotdot)) =
CT_LE_W((unsigned16)(((parent_fat_fd->cln) & 0xFFFF0000)>>16));
}
/*
* write dot and dotdot entries to new fat-file: currently fat-file
* correspondes to a new node is zero length, so it will be extended
* by one cluster and entries will be written
*/
ret = fat_file_write(parent_loc->mt_entry, fat_fd, 0,
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2,
dot_dotdot);
if (ret < 0)
{
rc = -1;
goto error;
}
/* increment fat-file size by cluster size */
fat_fd->fat_file_size += fs_info->fat.vol.bpc;
 
/* set up cluster num for dot entry */
*MSDOS_DIR_FIRST_CLUSTER_LOW(DOT_NODE_P(dot_dotdot)) =
CT_LE_W((unsigned16)((fat_fd->cln) & 0x0000FFFF));
*MSDOS_DIR_FIRST_CLUSTER_HI(DOT_NODE_P(dot_dotdot)) =
CT_LE_W((unsigned16)(((fat_fd->cln) & 0xFFFF0000) >> 16));
 
/* rewrite dot entry */
ret = fat_file_write(parent_loc->mt_entry, fat_fd, 0,
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE,
DOT_NODE_P(dot_dotdot));
if (ret < 0)
{
rc = -1;
goto error;
}
/* write first cluster num of a new directory to disk */
rc = msdos_set_first_cluster_num(parent_loc->mt_entry, fat_fd);
if (rc != RC_OK)
goto error;
fat_file_close(parent_loc->mt_entry, fat_fd);
}
return RC_OK;
 
error:
fat_file_close(parent_loc->mt_entry, fat_fd);
 
err:
/* mark 32bytes structure on the disk as free */
msdos_set_first_char4file_name(parent_loc->mt_entry, aux.cln, aux.ofs,
0xE5);
return rc;
}
/src/dosfs/msdos_init.c
0,0 → 1,60
/*
* Init routine for MSDOS
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_init.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <rtems/libio_.h>
#include "msdos.h"
 
rtems_filesystem_operations_table msdos_ops = {
msdos_eval_path,
msdos_eval4make,
NULL, /* msdos_link */
msdos_file_rmnod,
msdos_node_type,
msdos_mknod,
NULL, /* msdos_chown */
msdos_free_node_info,
NULL,
msdos_initialize,
NULL,
msdos_shut_down, /* msdos_shut_down */
NULL, /* msdos_utime */
NULL,
NULL,
NULL
};
 
/* msdos_initialize --
* MSDOS filesystem initialization
*
* PARAMETERS:
* temp_mt_entry - mount table entry
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set apropriately).
*
*/
int
msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry)
{
int rc = RC_OK;
rc = msdos_initialize_support(temp_mt_entry,
&msdos_ops,
&msdos_file_handlers,
&msdos_dir_handlers);
return rc;
}
/src/dosfs/fat_file.c
0,0 → 1,978
/*
* fat_file.c
*
* General operations on "fat-file"
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* @(#) fat_file.c,v 1.2 2002/03/28 13:52:49 joel Exp
*
*/
 
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdarg.h>
#include <errno.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
 
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
static inline void
_hash_insert(Chain_Control *hash, unsigned32 key1, unsigned32 key2,
fat_file_fd_t *el);
 
static inline void
_hash_delete(Chain_Control *hash, unsigned32 key1, unsigned32 key2,
fat_file_fd_t *el);
 
static inline int
_hash_search(
rtems_filesystem_mount_table_entry_t *mt_entry,
Chain_Control *hash,
unsigned32 key1,
unsigned32 key2,
void **ret
);
 
static int
fat_file_lseek(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 file_cln,
unsigned32 *disk_cln
);
 
/* fat_file_open --
* Open fat-file. Two hash tables are accessed by key
* constructed from cluster num and offset of the node (i.e.
* files/directories are distinguished by location on the disk).
* First, hash table("vhash") consists of fat-file descriptors corresponded
* to "valid" files is accessed. Search is made by 2 fields equal to key
* constructed. If descriptor is found in the "vhash" - return it.
* Otherwise search is made in hash table("rhash") consits of fat-file
* descriptors corresponded to "removed-but-still-open" files with the
* same keys.
* If search failed, new fat-file descriptor is added to "vhash"
* with both key fields equal to constructed key. Otherwise new fat-file
* descriptor is added to "vhash" with first key field equal to key
* constructed and the second equal to an unique (unique among all values
* of second key fields) value.
*
* PARAMETERS:
* mt_entry - mount table entry
* cln - cluster num of the node
* ofs - offset of the node
* fat_fd - placeholder for returned fat-file descriptor
*
* RETURNS:
* RC_OK and pointer to opened descriptor on success, or -1 if error
* occured (errno set appropriately)
*/
int
fat_file_open(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
unsigned32 ofs,
fat_file_fd_t **fat_fd
)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
fat_file_fd_t *lfat_fd = NULL;
unsigned32 key = 0;
/* construct key */
key = fat_construct_key(mt_entry, cln, ofs);
/* access "valid" hash table */
rc = _hash_search(mt_entry, fs_info->vhash, key, 0, (void **)&lfat_fd);
if ( rc == RC_OK )
{
/* return pointer to fat_file_descriptor allocated before */
(*fat_fd) = lfat_fd;
lfat_fd->links_num++;
return rc;
}
 
/* access "removed-but-still-open" hash table */
rc = _hash_search(mt_entry, fs_info->rhash, key, key, (void **)&lfat_fd);
 
lfat_fd = (*fat_fd) = (fat_file_fd_t*)malloc(sizeof(fat_file_fd_t));
if ( lfat_fd == NULL )
set_errno_and_return_minus_one( ENOMEM );
 
lfat_fd->links_num = 1;
lfat_fd->flags &= ~FAT_FILE_REMOVED;
lfat_fd->map.last_cln = FAT_UNDEFINED_VALUE;
if ( rc != RC_OK )
lfat_fd->ino = key;
else
{
lfat_fd->ino = fat_get_unique_ino(mt_entry);
if ( lfat_fd->ino == 0 )
{
free((*fat_fd));
/*
* XXX: kernel resource is unsufficient, but not the memory,
* but there is no suitable errno :(
*/
set_errno_and_return_minus_one( ENOMEM );
}
}
_hash_insert(fs_info->vhash, key, lfat_fd->ino, lfat_fd);
 
/*
* other fields of fat-file descriptor will be initialized on upper
* level
*/
 
return RC_OK;
}
 
 
/* fat_file_reopen --
* Increment by 1 number of links
*
* PARAMETERS:
* fat_fd - fat-file descriptor
*
* RETURNS:
* RC_OK
*/
int
fat_file_reopen(fat_file_fd_t *fat_fd)
{
fat_fd->links_num++;
return RC_OK;
}
 
/* fat_file_close --
* Close fat-file. If count of links to fat-file
* descriptor is greater than 1 (i.e. somebody esle holds pointer
* to this descriptor) just decrement it. Otherwise
* do the following. If this descriptor corresponded to removed fat-file
* then free clusters contained fat-file data, delete descriptor from
* "rhash" table and free memory allocated by descriptor. If descriptor
* correspondes to non-removed fat-file and 'ino' field has value from
* unique inode numbers pool then set count of links to descriptor to zero
* and leave it in hash, otherwise delete descriptor from "vhash" and free
* memory allocated by the descriptor
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
*
* RETURNS:
* RC_OK, or -1 if error occured (errno set appropriately)
*/
int
fat_file_close(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 key = 0;
 
/*
* if links_num field of fat-file descriptor is greater than 1
* decrement the count of links and return
*/
if (fat_fd->links_num > 1)
{
fat_fd->links_num--;
return rc;
}
 
key = fat_construct_key(mt_entry, fat_fd->info_cln, fat_fd->info_ofs);
 
if (fat_fd->flags & FAT_FILE_REMOVED)
{
rc = fat_file_truncate(mt_entry, fat_fd, 0);
if ( rc != RC_OK )
return rc;
 
_hash_delete(fs_info->rhash, key, fat_fd->ino, fat_fd);
 
if ( fat_ino_is_unique(mt_entry, fat_fd->ino) )
fat_free_unique_ino(mt_entry, fat_fd->ino);
 
free(fat_fd);
}
else
{
if (fat_ino_is_unique(mt_entry, fat_fd->ino))
{
fat_fd->links_num = 0;
}
else
{
_hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd);
free(fat_fd);
}
}
return rc;
}
 
/* fat_file_read --
* Read 'count' bytes from 'start' position from fat-file. This
* interface hides the architecture of fat-file, represents it as
* linear file
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
* start - offset in fat-file (in bytes) to read from
* count - count of bytes to read
* buf - buffer provided by user
*
* RETURNS:
* the number of bytes read on success, or -1 if error occured (errno
* set appropriately)
*/
ssize_t
fat_file_read(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 start,
unsigned32 count,
char *buf
)
{
int rc = RC_OK;
ssize_t ret = 0;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cmpltd = 0;
unsigned32 cur_cln = 0;
unsigned32 cl_start = 0;
unsigned32 save_cln = 0;
unsigned32 ofs = 0;
unsigned32 save_ofs;
unsigned32 sec = 0;
unsigned32 byte = 0;
unsigned32 c = 0;
 
/* it couldn't be removed - otherwise cache update will be broken */
if (count == 0)
return cmpltd;
 
/*
* >= because start is offset and computed from 0 and file_size
* computed from 1
*/
if ( start >= fat_fd->fat_file_size )
return FAT_EOF;
if ((count > fat_fd->fat_file_size) ||
(start > fat_fd->fat_file_size - count))
count = fat_fd->fat_file_size - start;
if ((FAT_FD_OF_ROOT_DIR(fat_fd)) &&
(fs_info->vol.type & (FAT_FAT12 | FAT_FAT16)))
{
sec = fat_cluster_num_to_sector_num(mt_entry, fat_fd->cln);
sec += (start >> fs_info->vol.sec_log2);
byte = start & (fs_info->vol.bps - 1);
 
ret = _fat_block_read(mt_entry, sec, byte, count, buf);
if ( ret < 0 )
return -1;
 
return ret;
}
cl_start = start >> fs_info->vol.bpc_log2;
save_ofs = ofs = start & (fs_info->vol.bpc - 1);
 
rc = fat_file_lseek(mt_entry, fat_fd, cl_start, &cur_cln);
if (rc != RC_OK)
return rc;
while (count > 0)
{
c = MIN(count, (fs_info->vol.bpc - ofs));
 
sec = fat_cluster_num_to_sector_num(mt_entry, cur_cln);
sec += (ofs >> fs_info->vol.sec_log2);
byte = ofs & (fs_info->vol.bps - 1);
 
ret = _fat_block_read(mt_entry, sec, byte, c, buf + cmpltd);
if ( ret < 0 )
return -1;
 
count -= c;
cmpltd += c;
save_cln = cur_cln;
rc = fat_get_fat_cluster(mt_entry, cur_cln, &cur_cln);
if ( rc != RC_OK )
return rc;
 
ofs = 0;
}
 
/* update cache */
/* XXX: check this - I'm not sure :( */
fat_fd->map.file_cln = cl_start +
((save_ofs + cmpltd - 1) >> fs_info->vol.bpc_log2);
fat_fd->map.disk_cln = save_cln;
 
return cmpltd;
}
 
/* fat_file_write --
* Write 'count' bytes of data from user supplied buffer to fat-file
* starting at offset 'start'. This interface hides the architecture
* of fat-file, represents it as linear file
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
* start - offset(in bytes) to write from
* count - count
* buf - buffer provided by user
*
* RETURNS:
* number of bytes actually written to the file on success, or -1 if
* error occured (errno set appropriately)
*/
ssize_t
fat_file_write(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 start,
unsigned32 count,
const char *buf
)
{
int rc = 0;
ssize_t ret = 0;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cmpltd = 0;
unsigned32 cur_cln = 0;
unsigned32 save_cln = 0; /* FIXME: This might be incorrect, cf. below */
unsigned32 cl_start = 0;
unsigned32 ofs = 0;
unsigned32 save_ofs;
unsigned32 sec = 0;
unsigned32 byte = 0;
unsigned32 c = 0;
if ( count == 0 )
return cmpltd;
 
if ( start > fat_fd->fat_file_size )
set_errno_and_return_minus_one( EIO );
 
if ((count > fat_fd->size_limit) ||
(start > fat_fd->size_limit - count))
set_errno_and_return_minus_one( EIO );
rc = fat_file_extend(mt_entry, fat_fd, start + count, &c);
if (rc != RC_OK)
return rc;
 
/*
* check whether there was enough room on device to locate
* file of 'start + count' bytes
*/
if (c != (start + count))
count = c - start;
if ((FAT_FD_OF_ROOT_DIR(fat_fd)) &&
(fs_info->vol.type & (FAT_FAT12 | FAT_FAT16)))
{
sec = fat_cluster_num_to_sector_num(mt_entry, fat_fd->cln);
sec += (start >> fs_info->vol.sec_log2);
byte = start & (fs_info->vol.bps - 1);
 
ret = _fat_block_write(mt_entry, sec, byte, count, buf);
if ( ret < 0 )
return -1;
 
return ret;
}
cl_start = start >> fs_info->vol.bpc_log2;
save_ofs = ofs = start & (fs_info->vol.bpc - 1);
 
rc = fat_file_lseek(mt_entry, fat_fd, cl_start, &cur_cln);
if (rc != RC_OK)
return rc;
 
while (count > 0)
{
c = MIN(count, (fs_info->vol.bpc - ofs));
 
sec = fat_cluster_num_to_sector_num(mt_entry, cur_cln);
sec += (ofs >> fs_info->vol.sec_log2);
byte = ofs & (fs_info->vol.bps - 1);
 
ret = _fat_block_write(mt_entry, sec, byte, c, buf + cmpltd);
if ( ret < 0 )
return -1;
 
count -= c;
cmpltd += c;
save_cln = cur_cln;
rc = fat_get_fat_cluster(mt_entry, cur_cln, &cur_cln);
if ( rc != RC_OK )
return rc;
 
ofs = 0;
}
 
/* update cache */
/* XXX: check this - I'm not sure :( */
fat_fd->map.file_cln = cl_start +
((save_ofs + cmpltd - 1) >> fs_info->vol.bpc_log2);
fat_fd->map.disk_cln = save_cln;
 
return cmpltd;
}
 
/* fat_file_extend --
* Extend fat-file. If new length less than current fat-file size -
* do nothing. Otherwise calculate necessary count of clusters to add,
* allocate it and add new clusters chain to the end of
* existing clusters chain.
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
* new_length - new length
* a_length - placeholder for result - actual new length of file
*
* RETURNS:
* RC_OK and new length of file on success, or -1 if error occured (errno
* set appropriately)
*/
int
fat_file_extend(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 new_length,
unsigned32 *a_length
)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 chain = 0;
unsigned32 bytes2add = 0;
unsigned32 cls2add = 0;
unsigned32 old_last_cl;
unsigned32 last_cl = 0;
unsigned32 bytes_remain = 0;
unsigned32 cls_added;
*a_length = new_length;
 
if (new_length <= fat_fd->fat_file_size)
return RC_OK;
 
if ((FAT_FD_OF_ROOT_DIR(fat_fd)) &&
(fs_info->vol.type & (FAT_FAT12 | FAT_FAT16)))
set_errno_and_return_minus_one( ENOSPC );
 
bytes_remain = (fs_info->vol.bpc -
(fat_fd->fat_file_size & (fs_info->vol.bpc - 1))) &
(fs_info->vol.bpc - 1);
 
bytes2add = new_length - fat_fd->fat_file_size;
if (bytes2add > bytes_remain)
bytes2add -= bytes_remain;
else
bytes2add = 0;
 
/*
* if in last cluster allocated for the file there is enough room to
* handle extention (hence we don't need to add even one cluster to the
* file ) - return
*/
if (bytes2add == 0)
return RC_OK;
 
cls2add = ((bytes2add - 1) >> fs_info->vol.bpc_log2) + 1;
rc = fat_scan_fat_for_free_clusters(mt_entry, &chain, cls2add,
&cls_added, &last_cl);
 
/* this means that low level I/O error occured */
if (rc != RC_OK)
return rc;
 
/* this means that no space left on device */
if ((cls_added == 0) && (bytes_remain == 0))
set_errno_and_return_minus_one(ENOSPC);
 
/* check wether we satisfied request for 'cls2add' clusters */
if (cls2add != cls_added)
*a_length = new_length -
((cls2add - cls_added - 1) << fs_info->vol.bpc_log2) -
(bytes2add & (fs_info->vol.bpc - 1));
 
/* add new chain to the end of existed */
if ( fat_fd->fat_file_size == 0 )
{
fat_fd->map.disk_cln = fat_fd->cln = chain;
fat_fd->map.file_cln = 0;
}
else
{
if (fat_fd->map.last_cln != FAT_UNDEFINED_VALUE)
{
old_last_cl = fat_fd->map.last_cln;
}
else
{
rc = fat_file_ioctl(mt_entry, fat_fd, F_CLU_NUM,
(fat_fd->fat_file_size - 1), &old_last_cl);
if ( rc != RC_OK )
{
fat_free_fat_clusters_chain(mt_entry, chain);
return rc;
}
}
 
rc = fat_set_fat_cluster(mt_entry, old_last_cl, chain);
if ( rc != RC_OK )
{
fat_free_fat_clusters_chain(mt_entry, chain);
return rc;
}
fat_buf_release(fs_info);
}
/* update number of the last cluster of the file if it changed */
if (cls_added != 0)
{
fat_fd->map.last_cln = last_cl;
if (fat_fd->fat_file_type == FAT_DIRECTORY)
{
rc = fat_init_clusters_chain(mt_entry, chain);
if ( rc != RC_OK )
{
fat_free_fat_clusters_chain(mt_entry, chain);
return rc;
}
}
}
 
return RC_OK;
}
 
/* fat_file_truncate --
* Truncate fat-file. If new length greater than current fat-file size -
* do nothing. Otherwise find first cluster to free and free all clusters
* in the chain starting from this cluster.
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
* new_length - new length
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
fat_file_truncate(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 new_length
)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cur_cln = 0;
unsigned32 cl_start = 0;
unsigned32 new_last_cln = FAT_UNDEFINED_VALUE;
if ( new_length >= fat_fd->fat_file_size )
return rc;
 
assert(fat_fd->fat_file_size);
cl_start = (new_length + fs_info->vol.bpc - 1) >> fs_info->vol.bpc_log2;
if ((cl_start << fs_info->vol.bpc_log2) >= fat_fd->fat_file_size)
return RC_OK;
if (cl_start != 0)
{
rc = fat_file_lseek(mt_entry, fat_fd, cl_start - 1, &new_last_cln);
if (rc != RC_OK)
return rc;
 
}
 
rc = fat_file_lseek(mt_entry, fat_fd, cl_start, &cur_cln);
if (rc != RC_OK)
return rc;
 
rc = fat_free_fat_clusters_chain(mt_entry, cur_cln);
if (rc != RC_OK)
return rc;
 
if (cl_start != 0)
{
rc = fat_set_fat_cluster(mt_entry, new_last_cln, FAT_GENFAT_EOC);
if ( rc != RC_OK )
return rc;
fat_fd->map.file_cln = cl_start - 1;
fat_fd->map.disk_cln = new_last_cln;
fat_fd->map.last_cln = new_last_cln;
}
return RC_OK;
}
 
/* fat_file_ioctl --
* F_CLU_NUM:
* make mapping between serial number of the cluster in fat-file and
* its real number on the volume
*
* PARAMETERS:
* fat_fd - fat-file descriptor
* mt_entry - mount table entry
* cmd - command
* ...
*
* RETURNS:
* RC_OK on success, or -1 if error occured and errno set appropriately
*/
int
fat_file_ioctl(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
int cmd,
...)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cur_cln = 0;
unsigned32 cl_start = 0;
unsigned32 pos = 0;
unsigned32 *ret;
va_list ap;
va_start(ap, cmd);
 
switch (cmd)
{
case F_CLU_NUM:
pos = va_arg(ap, int);
ret = va_arg(ap, int *);
 
/* sanity check */
if ( pos >= fat_fd->fat_file_size )
set_errno_and_return_minus_one( EIO );
 
if ((FAT_FD_OF_ROOT_DIR(fat_fd)) &&
(fs_info->vol.type & (FAT_FAT12 | FAT_FAT16)))
{
/* cluster 0 (zero) reserved for root dir */
*ret = 0;
return RC_OK;
}
cl_start = pos >> fs_info->vol.bpc_log2;
rc = fat_file_lseek(mt_entry, fat_fd, cl_start, &cur_cln);
if ( rc != RC_OK )
return rc;
 
*ret = cur_cln;
break;
 
default:
errno = EINVAL;
rc = -1;
break;
}
return rc;
}
 
/* fat_file_mark_removed --
* Remove the fat-file descriptor from "valid" hash table, insert it
* into "removed-but-still-open" hash table and set up "removed" bit.
*
* PARAMETERS:
* fat_fd - fat-file descriptor
* mt_entry - mount table entry
*
* RETURNS:
* None
*/
void
fat_file_mark_removed(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
)
{
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 key = 0;
key = fat_construct_key(mt_entry, fat_fd->info_cln, fat_fd->info_ofs);
_hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd);
 
_hash_insert(fs_info->rhash, key, fat_fd->ino, fat_fd);
 
fat_fd->flags |= FAT_FILE_REMOVED;
}
 
/* fat_file_datasync --
* Synchronize fat-file - flush all buffered data to the media.
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
*
* RETURNS:
* RC_OK on success, or -1 if error occured and errno set appropriately
*/
int
fat_file_datasync(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cur_cln = fat_fd->cln;
bdbuf_buffer *block = NULL;
unsigned32 sec = 0;
unsigned32 i = 0;
if (fat_fd->fat_file_size == 0)
return RC_OK;
/*
* we can use only one bdbuf :( and we also know that cache is useless
* for sync operation, so don't use it
*/
rc = fat_buf_release(fs_info);
if (rc != RC_OK)
return rc;
/* for each cluster of the file ... */
while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
{
sec = fat_cluster_num_to_sector_num(mt_entry, cur_cln);
/* for each sector in cluster ... */
for ( i = 0; i < fs_info->vol.spc; i++ )
{
/* ... sync it */
sc = rtems_bdbuf_read(fs_info->vol.dev, (sec + i), &block);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one( EIO );
 
sc = rtems_bdbuf_sync(block);
if ( sc != RTEMS_SUCCESSFUL )
set_errno_and_return_minus_one( EIO );
}
 
rc = fat_get_fat_cluster(mt_entry, cur_cln, &cur_cln);
if ( rc != RC_OK )
return rc;
}
return rc;
}
 
/* fat_file_size --
* Calculate fat-file size - fat-file is nothing that clusters chain, so
* go through all clusters in the chain and count it. Only
* special case is root directory for FAT12/16 volumes.
* This function is used only for directories which are fat-files with
* non-zero length, hence 'fat_fd->cln' always contains valid data.
* Calculated size is stored in 'fat_file_size' field of fat-file
* descriptor.
*
* PARAMETERS:
* mt_entry - mount table entry
* fat_fd - fat-file descriptor
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
fat_file_size(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cur_cln = fat_fd->cln;
unsigned32 save_cln = 0;
/* Have we requested root dir size for FAT12/16? */
if ((FAT_FD_OF_ROOT_DIR(fat_fd)) &&
(fs_info->vol.type & (FAT_FAT12 | FAT_FAT16)))
{
fat_fd->fat_file_size = fs_info->vol.rdir_size;
return rc;
}
fat_fd->fat_file_size = 0;
while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
{
save_cln = cur_cln;
rc = fat_get_fat_cluster(mt_entry, cur_cln, &cur_cln);
if ( rc != RC_OK )
return rc;
 
fat_fd->fat_file_size += fs_info->vol.bpc;
}
fat_fd->map.last_cln = save_cln;
return rc;
}
 
/* hash support routines */
 
/* _hash_insert --
* Insert elemnt into hash based on key 'key1'
*
* PARAMETERS:
* hash - hash element will be inserted into
* key1 - key on which insertion is based on
* key2 - not used during insertion
* el - element to insert
*
* RETURNS:
* None
*/
static inline void
_hash_insert(Chain_Control *hash, unsigned32 key1, unsigned32 key2,
fat_file_fd_t *el)
{
_Chain_Append((hash) + ((key1) % FAT_HASH_MODULE), &(el)->link);
}
 
 
/* _hash_delete --
* Remove element from hash
*
* PARAMETERS:
* hash - hash element will be removed from
* key1 - not used
* key2 - not used
* el - element to delete
*
* RETURNS:
* None
*/
static inline void
_hash_delete(Chain_Control *hash, unsigned32 key1, unsigned32 key2,
fat_file_fd_t *el)
{
_Chain_Extract(&(el)->link);
}
 
/* _hash_search --
* Search element in hash. If both keys match pointer to found element
* is returned
*
* PARAMETERS:
* mt_entry - mount table entry
* hash - hash element will be removed from
* key1 - search key
* key2 - search key
* ret - placeholder for result
*
* RETURNS:
* 0 and pointer to found element on success, -1 otherwise
*/
static inline int
_hash_search(
rtems_filesystem_mount_table_entry_t *mt_entry,
Chain_Control *hash,
unsigned32 key1,
unsigned32 key2,
void **ret
)
{
unsigned32 mod = (key1) % FAT_HASH_MODULE;
Chain_Node *the_node = ((Chain_Control *)((hash) + mod))->first;
 
for ( ; !_Chain_Is_tail((hash) + mod, the_node) ; )
{
fat_file_fd_t *ffd = (fat_file_fd_t *)the_node;
unsigned32 ck =
fat_construct_key(mt_entry, ffd->info_cln, ffd->info_ofs);
 
if ( (key1) == ck)
{
if ( ((key2) == 0) || ((key2) == ffd->ino) )
{
*ret = (void *)the_node;
return 0;
}
}
the_node = the_node->next;
}
return -1;
}
 
static int
fat_file_lseek(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 file_cln,
unsigned32 *disk_cln
)
{
int rc = RC_OK;
/*
assert(fat_fd->fat_file_size);
*/
if (file_cln == fat_fd->map.file_cln)
*disk_cln = fat_fd->map.disk_cln;
else
{
unsigned32 cur_cln;
unsigned32 count;
unsigned32 i;
if (file_cln > fat_fd->map.file_cln)
{
cur_cln = fat_fd->map.disk_cln;
count = file_cln - fat_fd->map.file_cln;
}
else
{
cur_cln = fat_fd->cln;
count = file_cln;
}
 
/* skip over the clusters */
for (i = 0; i < count; i++)
{
rc = fat_get_fat_cluster(mt_entry, cur_cln, &cur_cln);
if ( rc != RC_OK )
return rc;
}
 
/* update cache */
fat_fd->map.file_cln = file_cln;
fat_fd->map.disk_cln = cur_cln;
*disk_cln = cur_cln;
}
return RC_OK;
}
/src/dosfs/fat.c
0,0 → 1,695
/*
* fat.c
*
* Low-level operations on a volume with FAT filesystem
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* @(#) fat.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <assert.h>
 
#include <rtems/libio_.h>
 
#include "fat.h"
 
/* _fat_block_read --
* This function reads 'count' bytes from device filesystem is mounted on,
* starts at 'start+offset' position where 'start' computed in sectors
* and 'offset' is offset inside sector (reading may cross sectors
* boundary; in this case assumed we want to read sequential sector(s))
*
* PARAMETERS:
* mt_entry - mount table entry
* start - sector num to start read from
* offset - offset inside sector 'start'
* count - count of bytes to read
* buff - buffer provided by user
*
* RETURNS:
* bytes read on success, or -1 if error occured
* and errno set appropriately
*/
ssize_t
_fat_block_read(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 start,
unsigned32 offset,
unsigned32 count,
void *buff
)
{
int rc = RC_OK;
register fat_fs_info_t *fs_info = mt_entry->fs_info;
ssize_t cmpltd = 0;
unsigned32 blk = start;
unsigned32 ofs = offset;
bdbuf_buffer *block = NULL;
unsigned32 c = 0;
while (count > 0)
{
rc = fat_buf_access(fs_info, blk, FAT_OP_TYPE_READ, &block);
if (rc != RC_OK)
return rc;
c = MIN(count, (fs_info->vol.bps - ofs));
memcpy((buff + cmpltd), (block->buffer + ofs), c);
 
count -= c;
cmpltd += c;
blk++;
ofs = 0;
}
return cmpltd;
}
 
/* _fat_block_write --
* This function write 'count' bytes to device filesystem is mounted on,
* starts at 'start+offset' position where 'start' computed in sectors
* and 'offset' is offset inside sector (writing may cross sectors
* boundary; in this case assumed we want to write sequential sector(s))
*
* PARAMETERS:
* mt_entry - mount table entry
* start - sector num to start read from
* offset - offset inside sector 'start'
* count - count of bytes to write
* buff - buffer provided by user
*
* RETURNS:
* bytes written on success, or -1 if error occured
* and errno set appropriately
*/
ssize_t
_fat_block_write(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 start,
unsigned32 offset,
unsigned32 count,
const void *buff)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
ssize_t cmpltd = 0;
unsigned32 blk = start;
unsigned32 ofs = offset;
bdbuf_buffer *block = NULL;
unsigned32 c = 0;
while(count > 0)
{
c = MIN(count, (fs_info->vol.bps - ofs));
 
if (c == fs_info->vol.bps)
rc = fat_buf_access(fs_info, blk, FAT_OP_TYPE_GET, &block);
else
rc = fat_buf_access(fs_info, blk, FAT_OP_TYPE_READ, &block);
if (rc != RC_OK)
return rc;
memcpy((block->buffer + ofs), (buff + cmpltd), c);
 
fat_buf_mark_modified(fs_info);
 
count -= c;
cmpltd +=c;
blk++;
ofs = 0;
}
return cmpltd;
}
 
 
 
 
/* fat_cluster_read --
* wrapper for reading a whole cluster at once
*
* PARAMETERS:
* mt_entry - mount table entry
* cln - number of cluster to read
* buff - buffer provided by user
*
* RETURNS:
* bytes read on success, or -1 if error occured
* and errno set appropriately
*/
ssize_t
fat_cluster_read(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
void *buff
)
{
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 fsec = 0;
fsec = fat_cluster_num_to_sector_num(mt_entry, cln);
 
return _fat_block_read(mt_entry, fsec, 0,
fs_info->vol.spc << fs_info->vol.sec_log2, buff);
}
 
/* fat_cluster_write --
* wrapper for writting a whole cluster at once
*
* PARAMETERS:
* mt_entry - mount table entry
* cln - number of cluster to write
* buff - buffer provided by user
*
* RETURNS:
* bytes written on success, or -1 if error occured
* and errno set appropriately
*/
ssize_t
fat_cluster_write(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
const void *buff
)
{
fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 fsec = 0;
fsec = fat_cluster_num_to_sector_num(mt_entry, cln);
return _fat_block_write(mt_entry, fsec, 0,
fs_info->vol.spc << fs_info->vol.sec_log2, buff);
}
 
/* fat_init_volume_info --
* Get inforamtion about volume on which filesystem is mounted on
*
* PARAMETERS:
* mt_entry - mount table entry
*
* RETURNS:
* RC_OK on success, or -1 if error occured
* and errno set appropriately
*/
int
fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
register fat_vol_t *vol = &fs_info->vol;
unsigned32 data_secs = 0;
char boot_rec[FAT_MAX_BPB_SIZE];
char fs_info_sector[FAT_USEFUL_INFO_SIZE];
ssize_t ret = 0;
int fd;
struct stat stat_buf;
int i = 0;
 
rc = stat(mt_entry->dev, &stat_buf);
if (rc == -1)
return rc;
 
/* rtmes feature: no block devices, all are character devices */
if (!S_ISCHR(stat_buf.st_mode))
set_errno_and_return_minus_one(ENOTBLK);
 
/* check that device is registred as block device and lock it */
vol->dd = rtems_disk_lookup(stat_buf.st_dev);
if (vol->dd == NULL)
set_errno_and_return_minus_one(ENOTBLK);
vol->dev = stat_buf.st_dev;
 
fd = open(mt_entry->dev, O_RDONLY);
if (fd == -1)
{
rtems_disk_release(vol->dd);
return -1;
}
ret = read(fd, (void *)boot_rec, FAT_MAX_BPB_SIZE);
if ( ret != FAT_MAX_BPB_SIZE )
{
close(fd);
rtems_disk_release(vol->dd);
set_errno_and_return_minus_one( EIO );
}
close(fd);
 
vol->bps = FAT_BR_BYTES_PER_SECTOR(boot_rec);
if ( (vol->bps != 512) &&
(vol->bps != 1024) &&
(vol->bps != 2048) &&
(vol->bps != 4096))
{
rtems_disk_release(vol->dd);
set_errno_and_return_minus_one( EINVAL );
}
 
for (vol->sec_mul = 0, i = (vol->bps >> FAT_SECTOR512_BITS); (i & 1) == 0;
i >>= 1, vol->sec_mul++);
for (vol->sec_log2 = 0, i = vol->bps; (i & 1) == 0;
i >>= 1, vol->sec_log2++);
 
vol->spc = FAT_BR_SECTORS_PER_CLUSTER(boot_rec);
for (vol->spc_log2 = 0, i = vol->spc; (i & 1) == 0;
i >>= 1, vol->spc_log2++);
/*
* According to M$ White Paper "bytes per cluster" value
* greater than 32K is invalid
*/
if ((vol->bpc = vol->bps << vol->spc_log2) > MS_BYTES_PER_CLUSTER_LIMIT)
{
rtems_disk_release(vol->dd);
set_errno_and_return_minus_one(EINVAL);
}
 
for (vol->bpc_log2 = 0, i = vol->bpc; (i & 1) == 0;
i >>= 1, vol->bpc_log2++);
 
vol->fats = FAT_BR_FAT_NUM(boot_rec);
vol->fat_loc = FAT_BR_RESERVED_SECTORS_NUM(boot_rec);
 
vol->rdir_entrs = FAT_BR_FILES_PER_ROOT_DIR(boot_rec);
/* calculate the count of sectors occupied by the root directory */
vol->rdir_secs = ((vol->rdir_entrs * FAT_DIRENTRY_SIZE) + (vol->bps - 1)) /
vol->bps;
 
vol->rdir_size = vol->rdir_secs << vol->sec_log2;
 
if ( (FAT_BR_SECTORS_PER_FAT(boot_rec)) != 0)
vol->fat_length = FAT_BR_SECTORS_PER_FAT(boot_rec);
else
vol->fat_length = FAT_BR_SECTORS_PER_FAT32(boot_rec);
vol->data_fsec = vol->fat_loc + vol->fats * vol->fat_length +
vol->rdir_secs;
 
/* for FAT12/16 root dir starts at(sector) */
vol->rdir_loc = vol->fat_loc + vol->fats * vol->fat_length;
if ( (FAT_BR_TOTAL_SECTORS_NUM16(boot_rec)) != 0)
vol->tot_secs = FAT_BR_TOTAL_SECTORS_NUM16(boot_rec);
else
vol->tot_secs = FAT_BR_TOTAL_SECTORS_NUM32(boot_rec);
data_secs = vol->tot_secs - vol->data_fsec;
vol->data_cls = data_secs / vol->spc;
 
/* determine FAT type at least */
if ( vol->data_cls < FAT_FAT12_MAX_CLN)
{
vol->type = FAT_FAT12;
vol->mask = FAT_FAT12_MASK;
vol->eoc_val = FAT_FAT12_EOC;
}
else
{
if ( vol->data_cls < FAT_FAT16_MAX_CLN)
{
vol->type = FAT_FAT16;
vol->mask = FAT_FAT16_MASK;
vol->eoc_val = FAT_FAT16_EOC;
}
else
{
vol->type = FAT_FAT32;
vol->mask = FAT_FAT32_MASK;
vol->eoc_val = FAT_FAT32_EOC;
}
}
if (vol->type == FAT_FAT32)
{
vol->rdir_cl = FAT_BR_FAT32_ROOT_CLUSTER(boot_rec);
vol->mirror = FAT_BR_EXT_FLAGS(boot_rec) & FAT_BR_EXT_FLAGS_MIRROR;
if (vol->mirror)
vol->afat = FAT_BR_EXT_FLAGS(boot_rec) & FAT_BR_EXT_FLAGS_FAT_NUM;
else
vol->afat = 0;
 
vol->info_sec = FAT_BR_FAT32_FS_INFO_SECTOR(boot_rec);
if( vol->info_sec == 0 )
{
rtems_disk_release(vol->dd);
set_errno_and_return_minus_one( EINVAL );
}
else
{
ret = _fat_block_read(mt_entry, vol->info_sec , 0,
FAT_FSI_LEADSIG_SIZE, fs_info_sector);
if ( ret < 0 )
{
rtems_disk_release(vol->dd);
return -1;
}
if (FAT_FSINFO_LEAD_SIGNATURE(fs_info_sector) !=
FAT_FSINFO_LEAD_SIGNATURE_VALUE)
{
rtems_disk_release(vol->dd);
set_errno_and_return_minus_one( EINVAL );
}
else
{
ret = _fat_block_read(mt_entry, vol->info_sec , FAT_FSI_INFO,
FAT_USEFUL_INFO_SIZE, fs_info_sector);
if ( ret < 0 )
{
rtems_disk_release(vol->dd);
return -1;
}
vol->free_cls = FAT_FSINFO_FREE_CLUSTER_COUNT(fs_info_sector);
vol->next_cl = FAT_FSINFO_NEXT_FREE_CLUSTER(fs_info_sector);
rc = fat_fat32_update_fsinfo_sector(mt_entry, 0xFFFFFFFF,
0xFFFFFFFF);
if ( rc != RC_OK )
{
rtems_disk_release(vol->dd);
return rc;
}
}
}
}
else
{
vol->rdir_cl = 0;
vol->mirror = 0;
vol->afat = 0;
vol->free_cls = 0xFFFFFFFF;
vol->next_cl = 0xFFFFFFFF;
}
vol->afat_loc = vol->fat_loc + vol->fat_length * vol->afat;
 
/* set up collection of fat-files fd */
fs_info->vhash = calloc(FAT_HASH_SIZE, sizeof(Chain_Control));
if ( fs_info->vhash == NULL )
{
rtems_disk_release(vol->dd);
set_errno_and_return_minus_one( ENOMEM );
}
 
for (i = 0; i < FAT_HASH_SIZE; i++)
_Chain_Initialize_empty(fs_info->vhash + i);
 
fs_info->rhash = calloc(FAT_HASH_SIZE, sizeof(Chain_Control));
if ( fs_info->rhash == NULL )
{
rtems_disk_release(vol->dd);
free(fs_info->vhash);
set_errno_and_return_minus_one( ENOMEM );
}
for (i = 0; i < FAT_HASH_SIZE; i++)
_Chain_Initialize_empty(fs_info->rhash + i);
fs_info->uino_pool_size = FAT_UINO_POOL_INIT_SIZE;
fs_info->uino_base = (vol->tot_secs << vol->sec_mul) << 4;
fs_info->index = 0;
fs_info->uino = (char *)calloc(fs_info->uino_pool_size, sizeof(char));
if ( fs_info->uino == NULL )
{
rtems_disk_release(vol->dd);
free(fs_info->vhash);
free(fs_info->rhash);
set_errno_and_return_minus_one( ENOMEM );
}
fs_info->sec_buf = (char *)calloc(vol->bps, sizeof(char));
if (fs_info->sec_buf == NULL)
{
rtems_disk_release(vol->dd);
free(fs_info->vhash);
free(fs_info->rhash);
free(fs_info->uino);
set_errno_and_return_minus_one( ENOMEM );
}
return RC_OK;
}
 
/* fat_shutdown_drive --
* Free all allocated resources and synchronize all necessary data
*
* PARAMETERS:
* mt_entry - mount table entry
*
* RETURNS:
* RC_OK on success, or -1 if error occured
* and errno set appropriately
*/
int
fat_shutdown_drive(rtems_filesystem_mount_table_entry_t *mt_entry)
{
int rc = RC_OK;
fat_fs_info_t *fs_info = mt_entry->fs_info;
int i = 0;
 
if (fs_info->vol.type & FAT_FAT32)
{
rc = fat_fat32_update_fsinfo_sector(mt_entry, fs_info->vol.free_cls,
fs_info->vol.next_cl);
if ( rc != RC_OK )
rc = -1;
}
 
fat_buf_release(fs_info);
if (rtems_bdbuf_syncdev(fs_info->vol.dev) != RTEMS_SUCCESSFUL)
rc = -1;
 
for (i = 0; i < FAT_HASH_SIZE; i++)
{
Chain_Node *node = NULL;
Chain_Control *the_chain = fs_info->vhash + i;
while ( (node = _Chain_Get(the_chain)) != NULL )
free(node);
}
 
for (i = 0; i < FAT_HASH_SIZE; i++)
{
Chain_Node *node = NULL;
Chain_Control *the_chain = fs_info->rhash + i;
 
while ( (node = _Chain_Get(the_chain)) != NULL )
free(node);
}
 
free(fs_info->vhash);
free(fs_info->rhash);
 
free(fs_info->uino);
free(fs_info->sec_buf);
rtems_disk_release(fs_info->vol.dd);
 
if (rc)
errno = EIO;
return rc;
}
 
/* fat_init_clusters_chain --
* Zeroing contents of all clusters in the chain
*
* PARAMETERS:
* mt_entry - mount table entry
* start_cluster_num - num of first cluster in the chain
*
* RETURNS:
* RC_OK on success, or -1 if error occured
* and errno set appropriately
*/
int
fat_init_clusters_chain(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 start_cln
)
{
int rc = RC_OK;
ssize_t ret = 0;
register fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 cur_cln = start_cln;
char *buf;
buf = calloc(fs_info->vol.bpc, sizeof(char));
if ( buf == NULL )
set_errno_and_return_minus_one( EIO );
 
while ((cur_cln & fs_info->vol.mask) != fs_info->vol.eoc_val)
{
ret = fat_cluster_write(mt_entry, cur_cln, buf);
if ( ret == -1 )
{
free(buf);
return -1;
}
 
rc = fat_get_fat_cluster(mt_entry, cur_cln, &cur_cln);
if ( rc != RC_OK )
{
free(buf);
return rc;
}
}
free(buf);
return rc;
}
#define FAT_UNIQ_INO_BASE 0x0FFFFF00
 
#define FAT_UNIQ_INO_IS_BUSY(index, arr) \
(((arr)[((index)>>3)]>>((index) & (8-1))) & 0x01)
 
#define FAT_SET_UNIQ_INO_BUSY(index, arr) \
((arr)[((index)>>3)] |= (0x01<<((index) & (8-1))))
 
#define FAT_SET_UNIQ_INO_FREE(index, arr) \
((arr)[((index)>>3)] &= (~(0x01<<((index) & (8-1)))))
 
/* fat_get_unique_ino --
* Allocate unique ino from unique ino pool
*
* PARAMETERS:
* mt_entry - mount table entry
*
* RETURNS:
* unique inode number on success, or 0 if there is no free unique inode
* number in the pool
*
* ATTENTION:
* 0 means FAILED !!!
*
*/
unsigned32
fat_get_unique_ino(rtems_filesystem_mount_table_entry_t *mt_entry)
{
register fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 j = 0;
rtems_boolean resrc_unsuff = FALSE;
 
while (!resrc_unsuff)
{
for (j = 0; j < fs_info->uino_pool_size; j++)
{
if (!FAT_UNIQ_INO_IS_BUSY(fs_info->index, fs_info->uino))
{
FAT_SET_UNIQ_INO_BUSY(fs_info->index, fs_info->uino);
return (fs_info->uino_base + fs_info->index);
}
fs_info->index++;
if (fs_info->index >= fs_info->uino_pool_size)
fs_info->index = 0;
}
 
if ((fs_info->uino_pool_size << 1) < (0x0FFFFFFF - fs_info->uino_base))
{
fs_info->uino_pool_size <<= 1;
fs_info->uino = realloc(fs_info->uino, fs_info->uino_pool_size);
if (fs_info->uino != NULL)
fs_info->index = fs_info->uino_pool_size;
else
resrc_unsuff = TRUE;
}
else
resrc_unsuff = TRUE;
}
return 0;
}
 
/* fat_free_unique_ino --
* Return unique ino to unique ino pool
*
* PARAMETERS:
* mt_entry - mount table entry
* ino - inode number to free
*
* RETURNS:
* None
*/
void
fat_free_unique_ino(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 ino
)
{
fat_fs_info_t *fs_info = mt_entry->fs_info;
FAT_SET_UNIQ_INO_FREE((ino - fs_info->uino_base), fs_info->uino);
}
 
/* fat_ino_is_unique --
* Test whether ino is from unique ino pool
*
* PARAMETERS:
* mt_entry - mount table entry
* ino - ino to be tested
*
* RETURNS:
* TRUE if ino is allocated from unique ino pool, FALSE otherwise
*/
inline rtems_boolean
fat_ino_is_unique(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 ino
)
{
fat_fs_info_t *fs_info = mt_entry->fs_info;
return (ino >= fs_info->uino_base);
}
 
/* fat_fat32_update_fsinfo_sector --
* Synchronize fsinfo sector for FAT32 volumes
*
* PARAMETERS:
* mt_entry - mount table entry
* free_count - count of free clusters
* next_free - the next free cluster num
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
fat_fat32_update_fsinfo_sector(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 free_count,
unsigned32 next_free
)
{
ssize_t ret1 = 0, ret2 = 0;
register fat_fs_info_t *fs_info = mt_entry->fs_info;
unsigned32 le_free_count = 0;
unsigned32 le_next_free = 0;
 
le_free_count = CT_LE_L(free_count);
le_next_free = CT_LE_L(next_free);
 
ret1 = _fat_block_write(mt_entry,
fs_info->vol.info_sec,
FAT_FSINFO_FREE_CLUSTER_COUNT_OFFSET,
4,
(char *)(&le_free_count));
 
ret2 = _fat_block_write(mt_entry,
fs_info->vol.info_sec,
FAT_FSINFO_NEXT_FREE_CLUSTER_OFFSET,
4,
(char *)(&le_next_free));
 
if ( (ret1 < 0) || (ret2 < 0) )
return -1;
 
return RC_OK;
}
/src/dosfs/fat_fat_operations.h
0,0 → 1,58
/*
* fat_fat_operations.h
*
* Constants/data structures/prototypes for operations on Files Allocation
* Table
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) fat_fat_operations.h,v 1.1 2002/02/28 20:43:50 joel Exp
*/
#ifndef __DOSFS_FAT_FAT_OPERATIONS_H__
#define __DOSFS_FAT_FAT_OPERATIONS_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <rtems.h>
#include <rtems/libio_.h>
 
#include <rtems/bdbuf.h>
#include "fat.h"
 
int
fat_get_fat_cluster(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
unsigned32 *ret_val);
 
int
fat_set_fat_cluster(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
unsigned32 in_val);
 
int
fat_scan_fat_for_free_clusters(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 *chain,
unsigned32 count,
unsigned32 *cls_added,
unsigned32 *last_cl
);
 
int
fat_free_fat_clusters_chain(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 chain
);
 
#ifdef __cplusplus
}
#endif
 
#endif /* __DOSFS_FAT_FAT_OPERATIONS_H__ */
/src/dosfs/msdos_mknod.c
0,0 → 1,90
/*
* Routine for node creation in MSDOS filesystem.
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_mknod.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <rtems.h>
 
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_mknod --
* The following function checks spelling and formats name for a new node,
* determines type of the node to be created and creates it.
*
* PARAMETERS:
* token - non-formatted name of a new node
* mode - node type
* dev - dev
* pathloc - parent directory description
*
* RETURNS:
* RC_OK on succes, or -1 if error occured and set errno
*
*/
int
msdos_mknod(
const char *token,
mode_t mode,
dev_t dev,
rtems_filesystem_location_info_t *pathloc
)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
msdos_token_types_t type = 0;
char new_name[ MSDOS_NAME_MAX + 1 ];
int len;
 
/* check spelling and format new node name */
msdos_get_token(token, new_name, &len);
 
/*
* Figure out what type of msdos node this is.
*/
if (S_ISDIR(mode))
{
type = MSDOS_DIRECTORY;
}
else if (S_ISREG(mode))
{
type = MSDOS_REGULAR_FILE;
}
else
set_errno_and_return_minus_one(EINVAL);
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
 
/* Create an MSDOS node */
rc = msdos_creat_node(pathloc, type, new_name, mode);
 
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
/src/dosfs/fat_file.h
0,0 → 1,195
/*
* fat_file.h
*
* Constants/data structures/prototypes for operations on "fat-file"
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) fat_file.h,v 1.2 2002/03/28 13:52:49 joel Exp
*/
#ifndef __DOSFS_FAT_FILE_H__
#define __DOSFS_FAT_FILE_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <rtems.h>
#include <rtems/libio_.h>
 
#include <time.h>
 
/* "fat-file" representation
*
* the idea is: fat-file is nothing but a cluster chain, any open fat-file is
* represented in system by fat-file descriptor and has well-known
* file interface:
*
* fat_file_open()
* fat_file_close()
* fat_file_read()
* fat_file_write()
*
* Such interface hides the architecture of fat-file and represents it like
* linear file
*/
typedef rtems_filesystem_node_types_t fat_file_type_t;
 
#define FAT_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY
#define FAT_FILE RTEMS_FILESYSTEM_MEMORY_FILE
 
typedef struct fat_file_map_s
{
unsigned32 file_cln;
unsigned32 disk_cln;
unsigned32 last_cln;
} fat_file_map_t;
/*
* descriptor of a fat-file
*
* To each particular clusters chain
*/
typedef struct fat_file_fd_s
{
Chain_Node link; /*
* fat-file descriptors organized into hash;
* collision lists are handled via link
* field
*/
unsigned32 links_num; /*
* the number of fat_file_open call on
* this fat-file
*/
unsigned32 ino; /* inode, file serial number :)))) */
fat_file_type_t fat_file_type;
unsigned32 size_limit;
unsigned32 fat_file_size; /* length */
unsigned32 info_cln;
unsigned32 cln;
unsigned16 info_ofs;
unsigned char first_char;
unsigned8 flags;
fat_file_map_t map;
time_t mtime;
} fat_file_fd_t;
 
 
#define FAT_FILE_REMOVED 0x01
 
#define FAT_FILE_IS_REMOVED(p)\
(((p)->flags & FAT_FILE_REMOVED) ? 1 : 0)
 
/* ioctl macros */
#define F_CLU_NUM 0x01
 
/*
* Each file and directory on a MSDOS volume is unique identified by it
* location, i.e. location of it 32 Bytes Directory Entry Structure. We can
* distinguish them by cluster number it locates on and offset inside this
* cluster. But root directory on any volumes (FAT12/16/32) has no 32 Bytes
* Directory Entry Structure corresponded to it. So we assume 32 Bytes
* Directory Entry Structure of root directory locates at cluster 1 (invalid
* cluaster number) and offset 0
*/
#define FAT_ROOTDIR_CLUSTER_NUM 0x01
 
#define FAT_FD_OF_ROOT_DIR(fat_fd) \
((fat_fd->info_cln == FAT_ROOTDIR_CLUSTER_NUM ) && \
(fat_fd->info_ofs == 0))
 
#define FAT_EOF 0x00
 
/* fat_construct_key --
* Construct key for hash access: convert (cluster num, offset) to
* (sector512 num, new offset) and than construct key as
* key = (sector512 num) << 4 | (new offset)
*
* PARAMETERS:
* cl - cluster number
* ofs - offset inside cluster 'cl'
* mt_entry - mount table entry
*
* RETURNS:
* constructed key
*/
static inline unsigned32
fat_construct_key(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cl,
unsigned32 ofs)
{
return ( ((fat_cluster_num_to_sector512_num(mt_entry, cl) +
(ofs >> FAT_SECTOR512_BITS)) << 4) +
((ofs >> 5) & (FAT_DIRENTRIES_PER_SEC512 - 1)) );
}
 
/* Prototypes for "fat-file" operations */
int
fat_file_open(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
unsigned32 ofs,
fat_file_fd_t **fat_fd);
 
int
fat_file_reopen(fat_file_fd_t *fat_fd);
 
int
fat_file_close(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd);
 
ssize_t
fat_file_read(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 start,
unsigned32 count,
char *buf);
 
ssize_t
fat_file_write(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 start,
unsigned32 count,
const char *buf);
 
int
fat_file_extend(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 new_length,
unsigned32 *a_length);
 
int
fat_file_truncate(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 new_length);
int
fat_file_datasync(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd);
 
int
fat_file_ioctl(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
int cmd,
...);
 
int
fat_file_size(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd);
 
void
fat_file_mark_removed(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd);
 
#ifdef __cplusplus
}
#endif
 
#endif /* __DOSFS_FAT_FILE_H__ */
/src/dosfs/fat.h
0,0 → 1,488
/*
* fat.h
*
* Constants/data structures/prototypes for low-level operations on a volume
* with FAT filesystem
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) fat.h,v 1.2 2002/04/04 18:22:23 joel Exp
*/
 
#ifndef __DOSFS_FAT_H__
#define __DOSFS_FAT_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <string.h>
 
#include <rtems/seterr.h>
 
/* XXX: temporary hack :(( */
#ifndef set_errno_and_return_minus_one
#define set_errno_and_return_minus_one rtems_set_errno_and_return_minus_one
#endif /* set_errno_and_return_minus_one */
 
#include <rtems/score/cpu.h>
#include <errno.h>
#include <rtems/bdbuf.h>
 
#ifndef RC_OK
#define RC_OK 0x00000000
#endif
 
/*
* Remember that all FAT file system on disk data structure is
* "little endian"!
* (derived from linux)
*/
/*
* Conversion from and to little-endian byte order. (no-op on i386/i486)
*
* Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
* BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
*/
 
#if (CPU_BIG_ENDIAN == TRUE)
# define CF_LE_W(v) CPU_swap_u16(v)
# define CF_LE_L(v) CPU_swap_u32(v)
# define CT_LE_W(v) CPU_swap_u16(v)
# define CT_LE_L(v) CPU_swap_u32(v)
#else
# define CF_LE_W(v) (v)
# define CF_LE_L(v) (v)
# define CT_LE_W(v) (v)
# define CT_LE_L(v) (v)
#endif
 
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
 
#define FAT_HASH_SIZE 2
#define FAT_HASH_MODULE FAT_HASH_SIZE
 
 
#define FAT_SECTOR512_SIZE 512 /* sector size (bytes) */
#define FAT_SECTOR512_BITS 9 /* log2(SECTOR_SIZE) */
 
/* maximum + 1 number of clusters for FAT12 */
#define FAT_FAT12_MAX_CLN 4085
 
/* maximum + 1 number of clusters for FAT16 */
#define FAT_FAT16_MAX_CLN 65525
 
#define FAT_FAT12 0x01
#define FAT_FAT16 0x02
#define FAT_FAT32 0x04
#define FAT_UNDEFINED_VALUE 0xFFFFFFFF
 
#define FAT_FAT12_EOC 0x0FFF
#define FAT_FAT16_EOC 0xFFFF
#define FAT_FAT32_EOC 0x0FFFFFFF
 
#define FAT_FAT12_FREE 0x0000
#define FAT_FAT16_FREE 0x0000
#define FAT_FAT32_FREE 0x00000000
 
#define FAT_GENFAT_EOC 0xFFFFFFFF
#define FAT_GENFAT_FREE 0x00000000
 
#define FAT_FAT12_SHIFT 0x04
 
#define FAT_FAT12_MASK 0x00000FFF
#define FAT_FAT16_MASK 0x0000FFFF
#define FAT_FAT32_MASK 0x0FFFFFFF
 
#define FAT_MAX_BPB_SIZE 90
 
/* size of useful information in FSInfo sector */
#define FAT_USEFUL_INFO_SIZE 12
 
#define FAT_VAL8(x, ofs) (unsigned8)(*((unsigned8 *)(x) + (ofs)))
#define FAT_VAL16(x, ofs) \
(unsigned16)( (*((unsigned8 *)(x) + (ofs))) | \
((*((unsigned8 *)(x) + (ofs) + 1)) << 8) )
 
#define FAT_VAL32(x, ofs) \
(unsigned32)( (*((unsigned8 *)(x) + (ofs))) | \
((*((unsigned8 *)(x) + (ofs) + 1)) << 8) | \
((*((unsigned8 *)(x) + (ofs) + 2)) << 16) | \
((*((unsigned8 *)(x) + (ofs) + 3)) << 24) )
/* macros to access boot sector fields */
#define FAT_BR_BYTES_PER_SECTOR(x) FAT_VAL16(x, 11)
#define FAT_BR_SECTORS_PER_CLUSTER(x) FAT_VAL8(x, 13)
#define FAT_BR_RESERVED_SECTORS_NUM(x) FAT_VAL16(x, 14)
#define FAT_BR_FAT_NUM(x) FAT_VAL8(x, 16)
#define FAT_BR_FILES_PER_ROOT_DIR(x) FAT_VAL16(x, 17)
#define FAT_BR_TOTAL_SECTORS_NUM16(x) FAT_VAL16(x, 19)
#define FAT_BR_MEDIA(x) FAT_VAL8(x, 21)
#define FAT_BR_SECTORS_PER_FAT(x) FAT_VAL16(x, 22)
#define FAT_BR_TOTAL_SECTORS_NUM32(x) FAT_VAL32(x, 32)
#define FAT_BR_SECTORS_PER_FAT32(x) FAT_VAL32(x, 36)
#define FAT_BR_EXT_FLAGS(x) FAT_VAL16(x, 40)
#define FAT_BR_FAT32_ROOT_CLUSTER(x) FAT_VAL32(x, 44)
#define FAT_BR_FAT32_FS_INFO_SECTOR(x) FAT_VAL16(x, 48)
#define FAT_FSINFO_LEAD_SIGNATURE(x) FAT_VAL32(x, 0)
/*
* I read FSInfo sector from offset 484 to access the information, so offsets
* of these fields a relative
*/
#define FAT_FSINFO_FREE_CLUSTER_COUNT(x) FAT_VAL32(x, 4)
#define FAT_FSINFO_NEXT_FREE_CLUSTER(x) FAT_VAL32(x, 8)
 
#define FAT_FSINFO_FREE_CLUSTER_COUNT_OFFSET 488
 
#define FAT_FSINFO_NEXT_FREE_CLUSTER_OFFSET 492
 
#define FAT_RSRVD_CLN 0x02
 
#define FAT_FSINFO_LEAD_SIGNATURE_VALUE 0x41615252
 
#define FAT_FSI_LEADSIG_SIZE 0x04
 
#define FAT_FSI_INFO 484
 
#define MS_BYTES_PER_CLUSTER_LIMIT 0x8000 /* 32K */
 
#define FAT_BR_EXT_FLAGS_MIRROR 0x0080
 
#define FAT_BR_EXT_FLAGS_FAT_NUM 0x000F
 
 
#define FAT_DIRENTRY_SIZE 32
#define FAT_DIRENTRIES_PER_SEC512 16
 
/*
* Volume descriptor
* Description of the volume the FAT filesystem is located on - generally
* the fields of the structure corresponde to Boot Sector and BPB Srtucture
* (see M$ White Paper) fields
*/
typedef struct fat_vol_s
{
unsigned16 bps; /* bytes per sector */
unsigned8 sec_log2; /* log2 of bps */
unsigned8 sec_mul; /* log2 of 512bts sectors number per sector */
unsigned8 spc; /* sectors per cluster */
unsigned8 spc_log2; /* log2 of spc */
unsigned16 bpc; /* bytes per cluster */
unsigned8 bpc_log2; /* log2 of bytes per cluster */
unsigned8 fats; /* number of FATs */
unsigned8 type; /* FAT type */
unsigned32 mask;
unsigned32 eoc_val;
unsigned16 fat_loc; /* FAT start */
unsigned32 fat_length; /* sectors per FAT */
unsigned32 rdir_loc; /* root directory start */
unsigned16 rdir_entrs; /* files per root directory */
unsigned32 rdir_secs; /* sectors per root directory */
unsigned32 rdir_size; /* root directory size in bytes */
unsigned32 tot_secs; /* total count of sectors */
unsigned32 data_fsec; /* first data sector */
unsigned32 data_cls; /* count of data clusters */
unsigned32 rdir_cl; /* first cluster of the root directory */
unsigned16 info_sec; /* FSInfo Sector Structure location */
unsigned32 free_cls; /* last known free clusters count */
unsigned32 next_cl; /* next free cluster number */
unsigned8 mirror; /* mirroring enabla/disable */
unsigned32 afat_loc; /* active FAT location */
unsigned8 afat; /* the number of active FAT */
dev_t dev; /* device ID */
disk_device *dd; /* disk device (see libblock) */
void *private_data; /* reserved */
} fat_vol_t;
 
 
typedef struct fat_cache_s
{
unsigned32 blk_num;
rtems_boolean modified;
unsigned8 state;
bdbuf_buffer *buf;
} fat_cache_t;
/*
* This structure identifies the instance of the filesystem on the FAT
* ("fat-file") level.
*/
typedef struct fat_fs_info_s
{
fat_vol_t vol; /* volume descriptor */
Chain_Control *vhash; /* "vhash" of fat-file descriptors */
Chain_Control *rhash; /* "rhash" of fat-file descriptors */
char *uino; /* array of unique ino numbers */
unsigned32 index;
unsigned32 uino_pool_size; /* size */
unsigned32 uino_base;
fat_cache_t c; /* cache */
unsigned8 *sec_buf; /* just placeholder for anything */
} fat_fs_info_t;
 
/*
* if the name we looking for is file we store not only first data cluster
* number, but and cluster number and offset for directory entry for this
* name
*/
typedef struct fat_auxiliary_s
{
unsigned32 cln;
unsigned32 ofs;
} fat_auxiliary_t;
 
#define FAT_FAT_OFFSET(fat_type, cln) \
((fat_type) & FAT_FAT12 ? ((cln) + ((cln) >> 1)) : \
(fat_type) & FAT_FAT16 ? ((cln) << 1) : \
((cln) << 2))
 
#define FAT_CLUSTER_IS_ODD(n) ((n) & 0x0001)
 
#define FAT12_SHIFT 0x4 /* half of a byte */
 
/* initial size of array of unique ino */
#define FAT_UINO_POOL_INIT_SIZE 0x100
 
/* cache support */
#define FAT_CACHE_EMPTY 0x0
#define FAT_CACHE_ACTUAL 0x1
 
#define FAT_OP_TYPE_READ 0x1
#define FAT_OP_TYPE_GET 0x2
 
static inline unsigned32
fat_cluster_num_to_sector_num(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln
)
{
register fat_fs_info_t *fs_info = mt_entry->fs_info;
if ( (cln == 0) && (fs_info->vol.type & (FAT_FAT12 | FAT_FAT16)) )
return fs_info->vol.rdir_loc;
 
return (((cln - FAT_RSRVD_CLN) << fs_info->vol.spc_log2) +
fs_info->vol.data_fsec);
}
 
static inline unsigned32
fat_cluster_num_to_sector512_num(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln
)
{
fat_fs_info_t *fs_info = mt_entry->fs_info;
 
if (cln == 1)
return 1;
 
return (fat_cluster_num_to_sector_num(mt_entry, cln) <<
fs_info->vol.sec_mul);
}
 
static inline int
fat_buf_access(fat_fs_info_t *fs_info, unsigned32 blk, int op_type,
bdbuf_buffer **buf)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
unsigned8 i;
rtems_boolean sec_of_fat;
 
if (fs_info->c.state == FAT_CACHE_EMPTY)
{
if (op_type == FAT_OP_TYPE_READ)
sc = rtems_bdbuf_read(fs_info->vol.dev, blk, &fs_info->c.buf);
else
sc = rtems_bdbuf_get(fs_info->vol.dev, blk, &fs_info->c.buf);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
fs_info->c.blk_num = blk;
fs_info->c.state = FAT_CACHE_ACTUAL;
}
sec_of_fat = ((fs_info->c.blk_num >= fs_info->vol.fat_loc) &&
(fs_info->c.blk_num < fs_info->vol.rdir_loc));
 
if (fs_info->c.blk_num != blk)
{
if (fs_info->c.modified)
{
if (sec_of_fat && !fs_info->vol.mirror)
memcpy(fs_info->sec_buf, fs_info->c.buf->buffer,
fs_info->vol.bps);
sc = rtems_bdbuf_release_modified(fs_info->c.buf);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
fs_info->c.modified = 0;
if (sec_of_fat && !fs_info->vol.mirror)
{
bdbuf_buffer *b;
for (i = 1; i < fs_info->vol.fats; i++)
{
sc = rtems_bdbuf_get(fs_info->vol.dev,
fs_info->c.blk_num +
fs_info->vol.fat_length * i,
&b);
if ( sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(ENOMEM);
memcpy(b->buffer, fs_info->sec_buf, fs_info->vol.bps);
sc = rtems_bdbuf_release_modified(b);
if ( sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(ENOMEM);
}
}
}
else
{
sc = rtems_bdbuf_release(fs_info->c.buf);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
}
if (op_type == FAT_OP_TYPE_READ)
sc = rtems_bdbuf_read(fs_info->vol.dev, blk, &fs_info->c.buf);
else
sc = rtems_bdbuf_get(fs_info->vol.dev, blk, &fs_info->c.buf);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
fs_info->c.blk_num = blk;
}
*buf = fs_info->c.buf;
return RC_OK;
}
 
 
static inline int
fat_buf_release(fat_fs_info_t *fs_info)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
unsigned8 i;
rtems_boolean sec_of_fat;
if (fs_info->c.state == FAT_CACHE_EMPTY)
return RC_OK;
sec_of_fat = ((fs_info->c.blk_num >= fs_info->vol.fat_loc) &&
(fs_info->c.blk_num < fs_info->vol.rdir_loc));
 
if (fs_info->c.modified)
{
if (sec_of_fat && !fs_info->vol.mirror)
memcpy(fs_info->sec_buf, fs_info->c.buf->buffer, fs_info->vol.bps);
sc = rtems_bdbuf_release_modified(fs_info->c.buf);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
fs_info->c.modified = 0;
if (sec_of_fat && !fs_info->vol.mirror)
{
bdbuf_buffer *b;
for (i = 1; i < fs_info->vol.fats; i++)
{
sc = rtems_bdbuf_get(fs_info->vol.dev,
fs_info->c.blk_num +
fs_info->vol.fat_length * i,
&b);
if ( sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(ENOMEM);
memcpy(b->buffer, fs_info->sec_buf, fs_info->vol.bps);
sc = rtems_bdbuf_release_modified(b);
if ( sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(ENOMEM);
}
}
}
else
{
sc = rtems_bdbuf_release(fs_info->c.buf);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
}
fs_info->c.state = FAT_CACHE_EMPTY;
return RC_OK;
}
 
static inline void
fat_buf_mark_modified(fat_fs_info_t *fs_info)
{
fs_info->c.modified = TRUE;
}
 
 
 
ssize_t
_fat_block_read(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 start,
unsigned32 offset,
unsigned32 count,
void *buff);
 
ssize_t
_fat_block_write(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 start,
unsigned32 offset,
unsigned32 count,
const void *buff);
 
ssize_t
fat_cluster_read(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
void *buff);
 
ssize_t
fat_cluster_write(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
const void *buff);
 
int
fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry);
 
int
fat_init_clusters_chain(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 start_cln);
 
unsigned32
fat_cluster_num_to_sector_num(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln);
 
int
fat_shutdown_drive(rtems_filesystem_mount_table_entry_t *mt_entry);
 
 
unsigned32
fat_get_unique_ino(rtems_filesystem_mount_table_entry_t *mt_entry);
rtems_boolean
fat_ino_is_unique(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 ino);
 
void
fat_free_unique_ino(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 ino);
 
int
fat_fat32_update_fsinfo_sector(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 free_count,
unsigned32 next_free
);
#ifdef __cplusplus
}
#endif
#endif /* __DOSFS_FAT_H__ */
/src/dosfs/msdos_initsupp.c
0,0 → 1,149
/*
* MSDOS Initialization support routine implementation
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_initsupp.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
 
#include <assert.h>
#include <rtems.h>
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_initialize_support --
* MSDOS filesystem initialization
*
* PARAMETERS:
* temp_mt_entry - mount table entry
* op_table - filesystem operations table
* file_handlers - file operations table
* directory_handlers - directory operations table
*
* RETURNS:
* RC_OK and filled temp_mt_entry on success, or -1 if error occured
* (errno set apropriately)
*
*/
int
msdos_initialize_support(
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
rtems_filesystem_operations_table *op_table,
rtems_filesystem_file_handlers_r *file_handlers,
rtems_filesystem_file_handlers_r *directory_handlers
)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = NULL;
fat_file_fd_t *fat_fd = NULL;
unsigned32 cl_buf_size;
 
fs_info = (msdos_fs_info_t *)calloc(1, sizeof(msdos_fs_info_t));
if (!fs_info)
set_errno_and_return_minus_one(ENOMEM);
 
temp_mt_entry->fs_info = fs_info;
 
rc = fat_init_volume_info(temp_mt_entry);
if (rc != RC_OK)
{
free(fs_info);
return rc;
}
 
fs_info->file_handlers = file_handlers;
fs_info->directory_handlers = directory_handlers;
 
/*
* open fat-file which correspondes to root directory
* (so inode number 0x00000010 is always used for root directory)
*/
rc = fat_file_open(temp_mt_entry, FAT_ROOTDIR_CLUSTER_NUM, 0, &fat_fd);
if (rc != RC_OK)
{
fat_shutdown_drive(temp_mt_entry);
free(fs_info);
return rc;
}
 
/* again: unfortunately "fat-file" is just almost fat file :( */
fat_fd->fat_file_type = FAT_DIRECTORY;
fat_fd->size_limit = MSDOS_MAX_DIR_LENGHT;
fat_fd->info_cln = FAT_ROOTDIR_CLUSTER_NUM;
fat_fd->info_ofs = 0;
fat_fd->cln = fs_info->fat.vol.rdir_cl;
fat_fd->map.file_cln = 0;
fat_fd->map.disk_cln = fat_fd->cln;
 
/* if we have FAT12/16 */
if ( fat_fd->cln == 0 )
{
fat_fd->fat_file_size = fs_info->fat.vol.rdir_size;
cl_buf_size = (fs_info->fat.vol.bpc > fs_info->fat.vol.rdir_size) ?
fs_info->fat.vol.bpc :
fs_info->fat.vol.rdir_size;
}
else
{
rc = fat_file_size(temp_mt_entry, fat_fd);
if ( rc != RC_OK )
{
fat_file_close(temp_mt_entry, fat_fd);
fat_shutdown_drive(temp_mt_entry);
free(fs_info);
return rc;
}
cl_buf_size = fs_info->fat.vol.bpc;
}
fs_info->cl_buf = (char *)calloc(cl_buf_size, sizeof(char));
if (fs_info->cl_buf == NULL)
{
fat_file_close(temp_mt_entry, fat_fd);
fat_shutdown_drive(temp_mt_entry);
free(fs_info);
set_errno_and_return_minus_one(ENOMEM);
}
 
sc = rtems_semaphore_create(3,
1,
RTEMS_BINARY_SEMAPHORE | RTEMS_FIFO,
RTEMS_INHERIT_PRIORITY,
&fs_info->vol_sema);
if (sc != RTEMS_SUCCESSFUL)
{
fat_file_close(temp_mt_entry, fat_fd);
fat_shutdown_drive(temp_mt_entry);
free(fs_info->cl_buf);
free(fs_info);
set_errno_and_return_minus_one( EIO );
}
 
temp_mt_entry->mt_fs_root.node_access = fat_fd;
temp_mt_entry->mt_fs_root.handlers = directory_handlers;
temp_mt_entry->mt_fs_root.ops = op_table;
return rc;
}
/src/dosfs/msdos_dir.c
0,0 → 1,483
/*
* MSDOS directory handlers implementation
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_dir.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <rtems/libio_.h>
#include <sys/types.h>
#include <sys/stat.h>
 
#include <dirent.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_dir_open --
* Open fat-file which correspondes to the directory being opened and
* set offset field of file control block to zero.
*
* PARAMETERS:
* iop - file control block
* pathname - name
* flag - flags
* mode - mode
*
* RETURNS:
* RC_OK, if directory opened successfully, or -1 if error occured (errno
* set apropriately)
*/
int
msdos_dir_open(rtems_libio_t *iop, const char *pathname, unsigned32 flag,
unsigned32 mode)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one( EIO );
rc = fat_file_reopen(fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
iop->offset = 0;
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
/* msdos_dir_close --
* Close fat-file which correspondes to the directory being closed
*
* PARAMETERS:
* iop - file control block
*
* RETURNS:
* RC_OK, if directory closed successfully, or -1 if error occured (errno
* set apropriately.
*/
int
msdos_dir_close(rtems_libio_t *iop)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one( EIO );
rc = fat_file_close(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
/* msdos_dir_read --
* This routine will read the next directory entry based on the directory
* offset. The offset should be equal to -n- time the size of an
* individual dirent structure. If n is not an integer multiple of the
* sizeof a dirent structure, an integer division will be performed to
* determine directory entry that will be returned in the buffer. Count
* should reflect -m- times the sizeof dirent bytes to be placed in the
* buffer.
* If there are not -m- dirent elements from the current directory
* position to the end of the exisiting file, the remaining entries will
* be placed in the buffer and the returned value will be equal to
* -m actual- times the size of a directory entry.
*
* PARAMETERS:
* iop - file control block
* buffer - buffer provided by user
* count - count of bytes to read
*
* RETURNS:
* the number of bytes read on success, or -1 if error occured (errno
* set apropriately).
*/
ssize_t
msdos_dir_read(rtems_libio_t *iop, void *buffer, unsigned32 count)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
fat_file_fd_t *tmp_fat_fd = NULL;
struct dirent tmp_dirent;
unsigned32 start = 0;
ssize_t ret = 0;
unsigned32 cmpltd = 0;
unsigned32 j = 0, i = 0;
unsigned32 bts2rd = 0;
unsigned32 cur_cln = 0;
/*
* cast start and count - protect against using sizes that are not exact
* multiples of the -dirent- size. These could result in unexpected
* results
*/
start = iop->offset / sizeof(struct dirent);
count = (count / sizeof(struct dirent)) * sizeof(struct dirent);
/*
* optimization: we know that root directory for FAT12/16 volumes is
* sequential set of sectors and any cluster is sequential set of sectors
* too, so read such set of sectors is quick operation for low-level IO
* layer.
*/
bts2rd = (FAT_FD_OF_ROOT_DIR(fat_fd) &&
(fs_info->fat.vol.type & (FAT_FAT12 | FAT_FAT16))) ?
fat_fd->fat_file_size :
fs_info->fat.vol.bpc;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
while (count > 0)
{
/*
* fat-file is already opened by open call, so read it
* Always read directory fat-file from the beggining because of MSDOS
* directories feature :( - we should count elements currently
* present in the directory because there may be holes :)
*/
ret = fat_file_read(iop->pathinfo.mt_entry, fat_fd, (j * bts2rd),
bts2rd, fs_info->cl_buf);
if (ret < MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
{
rtems_semaphore_release(fs_info->vol_sema);
set_errno_and_return_minus_one(EIO);
}
 
for (i = 0; i < ret; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
{
if ((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY)
{
rtems_semaphore_release(fs_info->vol_sema);
return cmpltd;
}
if ((*MSDOS_DIR_NAME(fs_info->cl_buf + i)) ==
MSDOS_THIS_DIR_ENTRY_EMPTY)
continue;
/*
* skip active entries until get the entry to start from
*/
if (start)
{
start--;
continue;
}
/*
* Move the entry to the return buffer
*
* unfortunately there is no method to extract ino except to
* open fat-file descriptor :( ... so, open it
*/
/* get number of cluster we are working with */
rc = fat_file_ioctl(iop->pathinfo.mt_entry, fat_fd, F_CLU_NUM,
j * bts2rd, &cur_cln);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
rc = fat_file_open(iop->pathinfo.mt_entry, cur_cln, i,
&tmp_fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
tmp_fat_fd->info_cln = cur_cln;
tmp_fat_fd->info_ofs = i;
 
/* fill in dirent structure */
/* XXX: from what and in what d_off should be computed ?! */
tmp_dirent.d_off = start + cmpltd;
tmp_dirent.d_reclen = sizeof(struct dirent);
tmp_dirent.d_ino = tmp_fat_fd->ino;
tmp_dirent.d_namlen = MSDOS_SHORT_NAME_LEN;
memcpy(tmp_dirent.d_name, MSDOS_DIR_NAME((fs_info->cl_buf + i)),
MSDOS_SHORT_NAME_LEN);
/* d_name is null-terminated */
tmp_dirent.d_name[MSDOS_SHORT_NAME_LEN] = 0;
memcpy(buffer + cmpltd, &tmp_dirent, sizeof(struct dirent));
iop->offset = iop->offset + sizeof(struct dirent);
cmpltd += (sizeof(struct dirent));
count -= (sizeof(struct dirent));
/* inode number extracted, close fat-file */
rc = fat_file_close(iop->pathinfo.mt_entry, tmp_fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
if (count <= 0)
break;
}
j++;
}
 
rtems_semaphore_release(fs_info->vol_sema);
return cmpltd;
}
 
/* msdos_dir_write --
* no write for directory
*/
 
/* msdos_dir_lseek --
*
* This routine will behave in one of three ways based on the state of
* argument whence. Based on the state of its value the offset argument will
* be interpreted using one of the following methods:
*
* SEEK_SET - offset is the absolute byte offset from the start of the
* logical start of the dirent sequence that represents the
* directory
* SEEK_CUR - offset is used as the relative byte offset from the current
* directory position index held in the iop structure
* SEEK_END - N/A --> This will cause an assert.
*
* PARAMETERS:
* iop - file control block
* offset - offset
* whence - predefine directive
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno
* set apropriately).
*/
int
msdos_dir_lseek(rtems_libio_t *iop, off_t offset, int whence)
{
switch (whence)
{
case SEEK_SET:
case SEEK_CUR:
break;
/*
* Movement past the end of the directory via lseek is not a
* permitted operation
*/
case SEEK_END:
default:
set_errno_and_return_minus_one( EINVAL );
break;
}
return RC_OK;
}
 
/* msdos_dir_stat --
*
* This routine will obtain the following information concerning the current
* directory:
* st_dev device id
* st_ino node serial number :)
* st_mode mode extracted from the node
* st_size total size in bytes
* st_blksize blocksize for filesystem I/O
* st_blocks number of blocks allocated
* stat_mtime time of last modification
*
* PARAMETERS:
* loc - this directory
* buf - stat buffer provided by user
*
* RETURNS:
* RC_OK and filled stat buffer on success, or -1 if error occured (errno
* set apropriately).
*/
int
msdos_dir_stat(
rtems_filesystem_location_info_t *loc,
struct stat *buf
)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = loc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = loc->node_access;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
buf->st_dev = fs_info->fat.vol.dev;
buf->st_ino = fat_fd->ino;
buf->st_mode = S_IFDIR;
buf->st_rdev = 0ll;
buf->st_size = fat_fd->fat_file_size;
buf->st_blocks = fat_fd->fat_file_size >> FAT_SECTOR512_BITS;
buf->st_blksize = fs_info->fat.vol.bps;
buf->st_mtime = fat_fd->mtime;
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
/* msdos_dir_truncate --
* No truncate for directory.
*
* PARAMETERS:
*
* RETURNS:
*
*/
 
/* msdos_dir_sync --
* The following routine does a syncronization on a MSDOS directory node.
* DIR_WrtTime, DIR_WrtDate and DIR_fileSize fields of 32 Bytes Directory
* Entry Structure(see M$ White Paper) should not be updated for
* directories, so only call to corresponding fat-file routine.
*
* PARAMETERS:
* iop - file control block
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set apropriately).
*/
int
msdos_dir_sync(rtems_libio_t *iop)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
fat_file_fd_t *fat_fd = iop->file_info;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
rc = fat_file_datasync(iop->pathinfo.mt_entry, fat_fd);
 
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
/* msdos_dir_rmnod --
* Remove directory node.
*
* Check that this directory node is not opened as fat-file, is empty and
* not filesystem root node. If all this conditions met then delete.
*
* PARAMETERS:
* pathloc - node description
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set apropriately).
*/
int
msdos_dir_rmnod(rtems_filesystem_location_info_t *pathloc)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = pathloc->node_access;
rtems_boolean is_empty = FALSE;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
/*
* We deny attemp to delete open directory (if directory is current
* directory we assume it is open one)
*/
if (fat_fd->links_num > 1)
{
rtems_semaphore_release(fs_info->vol_sema);
set_errno_and_return_minus_one(EBUSY);
}
/*
* You cannot remove a node that still has children
*/
rc = msdos_dir_is_empty(pathloc->mt_entry, fat_fd, &is_empty);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
if (!is_empty)
{
rtems_semaphore_release(fs_info->vol_sema);
set_errno_and_return_minus_one(ENOTEMPTY);
}
 
/*
* You cannot remove the file system root node.
*/
if (pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access)
{
rtems_semaphore_release(fs_info->vol_sema);
set_errno_and_return_minus_one(EBUSY);
}
 
/*
* You cannot remove a mountpoint.
* not used - mount() not implemenetd yet.
*/
 
/* mark file removed */
rc = msdos_set_first_char4file_name(pathloc->mt_entry, fat_fd->info_cln,
fat_fd->info_ofs,
MSDOS_THIS_DIR_ENTRY_EMPTY);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
fat_file_mark_removed(pathloc->mt_entry, fat_fd);
 
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
/src/dosfs/dosfs.h
0,0 → 1,31
/*
* dosfs.h
*
* Application interface to MSDOS filesystem.
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) dosfs.h,v 1.1 2002/02/28 20:43:50 joel Exp
*/
#ifndef __DOSFS_DOSFS_H__
#define __DOSFS_DOSFS_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <rtems.h>
#include <rtems/libio.h>
 
extern rtems_filesystem_operations_table msdos_ops;
 
#ifdef __cplusplus
}
#endif
 
#endif /* __DOSFS_DOSFS_H__ */
/src/dosfs/msdos_file.c
0,0 → 1,485
/*
* MSDOS file handlers implementation
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_file.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
 
#include <rtems.h>
#include <rtems/libio.h>
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_file_open --
* Open fat-file which correspondes to the file
*
* PARAMETERS:
* iop - file control block
* pathname - name
* flag - flags
* mode - mode
*
* RETURNS:
* RC_OK, if file opened successfully, or -1 if error occured
* and errno set appropriately
*/
int
msdos_file_open(rtems_libio_t *iop, const char *pathname, unsigned32 flag,
unsigned32 mode)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
 
rc = fat_file_reopen(fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
if (iop->flags & LIBIO_FLAGS_APPEND)
iop->offset = fat_fd->fat_file_size;
iop->size = fat_fd->fat_file_size;
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
/* msdos_file_close --
* Close fat-file which correspondes to the file. If fat-file descriptor
* which correspondes to the file is not marked "removed", synchronize
* size, first cluster number, write time and date fields of the file.
*
* PARAMETERS:
* iop - file control block
*
* RETURNS:
* RC_OK, if file closed successfully, or -1 if error occured (errno set
* appropriately)
*/
int
msdos_file_close(rtems_libio_t *iop)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
/*
* if fat-file descriptor is not marked as "removed", synchronize
* size, first cluster number, write time and date fields of the file
*/
if (!FAT_FILE_IS_REMOVED(fat_fd))
{
rc = msdos_set_first_cluster_num(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
rc = msdos_set_file_size(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
rc = msdos_set_dir_wrt_time_and_date(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
}
rc = fat_file_close(iop->pathinfo.mt_entry, fat_fd);
 
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
/* msdos_file_read --
* This routine read from file pointed to by file control block into
* the specified data buffer provided by user
*
* PARAMETERS:
* iop - file control block
* buffer - buffer provided by user
* count - the number of bytes to read
*
* RETURNS:
* the number of bytes read on success, or -1 if error occured (errno set
* appropriately)
*/
ssize_t
msdos_file_read(rtems_libio_t *iop, void *buffer, unsigned32 count)
{
ssize_t ret = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
 
ret = fat_file_read(iop->pathinfo.mt_entry, fat_fd, iop->offset, count,
buffer);
 
rtems_semaphore_release(fs_info->vol_sema);
return ret;
}
 
/* msdos_file_write --
* This routine writes the specified data buffer into the file pointed to
* by file control block.
*
* PARAMETERS:
* iop - file control block
* buffer - data to write
* count - count of bytes to write
*
* RETURNS:
* the number of bytes written on success, or -1 if error occured
* and errno set appropriately
*/
ssize_t
msdos_file_write(rtems_libio_t *iop,const void *buffer, unsigned32 count)
{
ssize_t ret = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
 
ret = fat_file_write(iop->pathinfo.mt_entry, fat_fd, iop->offset, count,
buffer);
if (ret < 0)
{
rtems_semaphore_release(fs_info->vol_sema);
return -1;
}
 
/*
* update file size in both fat-file descriptor and file control block if
* file was extended
*/
if (iop->offset + ret > fat_fd->fat_file_size)
fat_fd->fat_file_size = iop->offset + ret;
 
iop->size = fat_fd->fat_file_size;
 
rtems_semaphore_release(fs_info->vol_sema);
return ret;
}
 
/* msdos_file_lseek --
* Process lseek call to the file: extend file if lseek is up to the end
* of the file.
*
* PARAMETERS:
* iop - file control block
* offset - new offset
* whence - predefine directive
*
* RETURNS:
* new offset on success, or -1 if error occured (errno set
* appropriately).
*/
int
msdos_file_lseek(rtems_libio_t *iop, off_t offset, int whence)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
unsigned32 real_size = 0;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
 
rc = fat_file_extend(iop->pathinfo.mt_entry, fat_fd, iop->offset,
&real_size);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
if (real_size > fat_fd->fat_file_size)
fat_fd->fat_file_size = iop->offset = real_size;
iop->size = fat_fd->fat_file_size;
 
rtems_semaphore_release(fs_info->vol_sema);
return iop->offset;
}
 
/* msdos_file_stat --
*
* PARAMETERS:
* loc - node description
* buf - stat buffer provided by user
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
msdos_file_stat(
rtems_filesystem_location_info_t *loc,
struct stat *buf
)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = loc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = loc->node_access;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
buf->st_dev = fs_info->fat.vol.dev;
buf->st_ino = fat_fd->ino;
buf->st_mode = S_IFREG;
buf->st_rdev = 0ll;
buf->st_size = fat_fd->fat_file_size;
buf->st_blocks = fat_fd->fat_file_size >> FAT_SECTOR512_BITS;
buf->st_blksize = fs_info->fat.vol.bps;
buf->st_mtime = fat_fd->mtime;
 
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
/* msdos_file_ftruncate --
* Truncate the file (if new length is greater then current do nothing).
*
* PARAMETERS:
* iop - file control block
* length - new length
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately).
*/
int
msdos_file_ftruncate(rtems_libio_t *iop, off_t length)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
fat_file_fd_t *fat_fd = iop->file_info;
 
if (length >= fat_fd->fat_file_size)
return RC_OK;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
rc = fat_file_truncate(iop->pathinfo.mt_entry, fat_fd, length);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
/*
* fat_file_truncate do nothing if new length >= fat-file size, so update
* file size only if length < fat-file size
*/
if (length < fat_fd->fat_file_size)
iop->size = fat_fd->fat_file_size = length;
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
/* msdos_file_sync --
* Synchronize file - synchronize file data and if file is not removed
* synchronize file metadata.
*
* PARAMETERS:
* iop - file control block
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
msdos_file_sync(rtems_libio_t *iop)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
fat_file_fd_t *fat_fd = iop->file_info;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
/* synchronize file data */
rc = fat_file_datasync(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
/*
* if fat-file descriptor is not marked "removed" - synchronize file
* metadata
*/
if (!FAT_FILE_IS_REMOVED(fat_fd))
{
rc = msdos_set_first_cluster_num(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
rc = msdos_set_file_size(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
rc = msdos_set_dir_wrt_time_and_date(iop->pathinfo.mt_entry, fat_fd);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
}
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
/* msdos_file_datasync --
* Synchronize file - synchronize only file data (metadata is letf intact).
*
* PARAMETERS:
* iop - file control block
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
msdos_file_datasync(rtems_libio_t *iop)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
fat_file_fd_t *fat_fd = iop->file_info;
msdos_fs_info_t *fs_info = iop->pathinfo.mt_entry->fs_info;
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
/* synchronize file data */
rc = fat_file_datasync(iop->pathinfo.mt_entry, fat_fd);
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
 
 
/* msdos_file_ioctl --
*
*
* PARAMETERS:
* iop - file control block
* ...
*
* RETURNS:
*
*/
int
msdos_file_ioctl(rtems_libio_t *iop,unsigned32 command, void *buffer)
{
int rc = RC_OK;
 
return rc;
}
 
/* msdos_file_rmnod --
* Remove node associated with a file - set up first name character to
* predefined value(and write it to the disk), and mark fat-file which
* correspondes to the file as "removed"
*
* PARAMETERS:
* pathloc - node description
*
* RETURNS:
* RC_OK on success, or -1 if error occured (errno set appropriately)
*/
int
msdos_file_rmnod(rtems_filesystem_location_info_t *pathloc)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = pathloc->node_access;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
 
/* mark file removed */
rc = msdos_set_first_char4file_name(pathloc->mt_entry, fat_fd->info_cln,
fat_fd->info_ofs,
MSDOS_THIS_DIR_ENTRY_EMPTY);
if (rc != RC_OK)
{
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
fat_file_mark_removed(pathloc->mt_entry, fat_fd);
 
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
}
/src/dosfs/msdos_free.c
0,0 → 1,56
/*
* Free node handler implementation for the filesystem
* operations table.
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_free.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <rtems.h>
#include <rtems/libio_.h>
 
#include <errno.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_free_node_info --
* Call fat-file close routine.
*
* PARAMETERS:
* pathloc - node description
*
* RETURNS:
* RC_OK on success, or -1 code if error occured
*
*/
int
msdos_free_node_info(rtems_filesystem_location_info_t *pathloc)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
 
rc = fat_file_close(pathloc->mt_entry, pathloc->node_access);
 
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
/src/dosfs/Makefile.am
0,0 → 1,52
##
## Makefile.am,v 1.9 2002/07/22 13:44:42 ralf Exp
##
 
 
include $(top_srcdir)/../automake/multilib.am
include $(top_srcdir)/../automake/compile.am
include $(top_srcdir)/../automake/lib.am
 
AM_CPPFLAGS += -I../.. $(LIBC_DEFINES)
 
FATFS_C_FILES = fat.c fat_fat_operations.c fat_file.c
 
DOSFS_C_FILES = msdos_create.c msdos_dir.c msdos_eval.c msdos_file.c \
msdos_free.c msdos_fsunmount.c msdos_handlers_dir.c \
msdos_handlers_file.c msdos_init.c msdos_initsupp.c \
msdos_misc.c msdos_mknod.c msdos_node_type.c
 
if !UNIX
LIB = ${ARCH}/libdosfs.a
 
C_FILES = $(FATFS_C_FILES) $(DOSFS_C_FILES)
 
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.$(OBJEXT))
 
include_HEADERS = dosfs.h
 
H_FILES = $(PROJECT_INCLUDE) \
$(include_HEADERS:%=$(PROJECT_INCLUDE)/%)
 
$(PROJECT_INCLUDE):
@$(mkinstalldirs) $@
 
$(PROJECT_INCLUDE)/%.h: %.h
$(INSTALL_DATA) $< $@
 
OBJS = $(C_O_FILES)
 
#
# Add local stuff here using +=
#
all-local: ${ARCH} $(LIB)
 
$(LIB): ${OBJS}
$(make-library)
endif
 
TMPINSTALL_FILES += $(H_FILES)
 
EXTRA_DIST = $(DOSFS_C_FILES) $(FATFS_C_FILES)
 
include $(top_srcdir)/../automake/local.am
/src/dosfs/msdos.h
0,0 → 1,408
/*
* msdos.h
*
* The MSDOS filesystem constants/data structures/prototypes
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos.h,v 1.1 2002/02/28 20:43:50 joel Exp
*/
#ifndef __DOSFS_MSDOS_H__
#define __DOSFS_MSDOS_H__
 
#ifdef __cplusplus
extern "C" {
#endif
 
#include <rtems.h>
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_file.h"
#ifndef RC_OK
#define RC_OK 0x00000000
#endif
 
#define MSDOS_NAME_NOT_FOUND_ERR 0xDD000001
 
/*
* This structure identifies the instance of the filesystem on the MSDOS
* level.
*/
typedef struct msdos_fs_info_s
{
fat_fs_info_t fat; /*
* volume
* description
*/
rtems_filesystem_file_handlers_r *directory_handlers; /*
* a set of routines
* that handles the
* nodes of directory
* type
*/
rtems_filesystem_file_handlers_r *file_handlers; /*
* a set of routines
* that handles the
* nodes of file
* type
*/
rtems_id vol_sema; /*
* semaphore
* associated with
* the volume
*/
unsigned8 *cl_buf; /*
* just placeholder
* for anything
*/
} msdos_fs_info_t;
 
/* a set of routines that handle the nodes which are directories */
extern rtems_filesystem_file_handlers_r msdos_dir_handlers;
 
/* a set of routines that handle the nodes which are files */
extern rtems_filesystem_file_handlers_r msdos_file_handlers;
 
/* Volume semaphore timeout value */
#define MSDOS_VOLUME_SEMAPHORE_TIMEOUT 100
 
/* Node types */
#define MSDOS_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY
#define MSDOS_REGULAR_FILE RTEMS_FILESYSTEM_MEMORY_FILE
typedef rtems_filesystem_node_types_t msdos_node_type_t;
 
/*
* Macros for fetching fields from 32 bytes long FAT Directory Entry
* Structure (see M$ White Paper)
*/
#define MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE 32 /* 32 bytes */
 
#define MSDOS_DIR_NAME(x) (unsigned8 *)((x) + 0)
#define MSDOS_DIR_ATTR(x) (unsigned8 *)((x) + 11)
#define MSDOS_DIR_NT_RES(x) (unsigned8 *)((x) + 12)
#define MSDOS_DIR_CRT_TIME_TENTH(x) (unsigned8 *)((x) + 13)
#define MSDOS_DIR_CRT_TIME(x) (unsigned16 *)((x) + 14)
#define MSDOS_DIR_CRT_DATE(x) (unsigned16 *)((x) + 16)
#define MSDOS_DIR_LAST_ACCESS_DATE(x) (unsigned16 *)((x) + 18)
#define MSDOS_DIR_FIRST_CLUSTER_HI(x) (unsigned16 *)((x) + 20)
#define MSDOS_DIR_WRITE_TIME(x) (unsigned16 *)((x) + 22)
#define MSDOS_DIR_WRITE_DATE(x) (unsigned16 *)((x) + 24)
#define MSDOS_DIR_FIRST_CLUSTER_LOW(x) (unsigned16 *)((x) + 26)
#define MSDOS_DIR_FILE_SIZE(x) (unsigned32 *)((x) + 28)
 
#define MSDOS_EXTRACT_CLUSTER_NUM(p) \
(unsigned32)( (CF_LE_W(*MSDOS_DIR_FIRST_CLUSTER_LOW(p))) | \
((CF_LE_W((*MSDOS_DIR_FIRST_CLUSTER_HI(p))))<<16) )
 
/*
* Fields offset in 32 bytes long FAT Directory Entry
* Structure (see M$ White Paper)
*/
#define MSDOS_FILE_SIZE_OFFSET 28
#define MSDOS_FILE_NAME_OFFSET 0
#define MSDOS_FIRST_CLUSTER_HI_OFFSET 20
#define MSDOS_FIRST_CLUSTER_LOW_OFFSET 26
#define MSDOS_FILE_WDATE_OFFSET 24
#define MSDOS_FILE_WTIME_OFFSET 22
 
/*
* Possible values of DIR_Attr field of 32 bytes long FAT Directory Entry
* Structure (see M$ White Paper)
*/
#define MSDOS_ATTR_READ_ONLY 0x01
#define MSDOS_ATTR_HIDDEN 0x02
#define MSDOS_ATTR_SYSTEM 0x04
#define MSDOS_ATTR_VOLUME_ID 0x08
#define MSDOS_ATTR_DIRECTORY 0x10
#define MSDOS_ATTR_ARCHIVE 0x20
 
/*
* Possible values of DIR_Name[0] field of 32 bytes long FAT Directory Entry
* Structure (see M$ White Paper)
*/
#define MSDOS_THIS_DIR_ENTRY_EMPTY 0xE5
#define MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY 0x00
 
 
/*
* Macros for names parsing and formatting
*/
#define msdos_is_valid_name_char(_ch) (1)
#define msdos_is_separator(_ch) rtems_filesystem_is_separator(_ch)
 
#define MSDOS_SHORT_NAME_LEN 11 /* 11 characters */
#define MSDOS_NAME_MAX MSDOS_SHORT_NAME_LEN
#define MSDOS_NAME_MAX_WITH_DOT (MSDOS_NAME_MAX + 1)
 
#define MSDOS_DOT_NAME ". " /* ".", padded to MSDOS_NAME chars */
#define MSDOS_DOTDOT_NAME ".. " /* "..", padded to MSDOS_NAME chars */
 
typedef enum msdos_token_types_e
{
MSDOS_NO_MORE_PATH,
MSDOS_CURRENT_DIR,
MSDOS_UP_DIR,
MSDOS_NAME,
MSDOS_INVALID_TOKEN
} msdos_token_types_t;
 
/* Others macros */
#define MSDOS_RES_NT_VALUE 0x00
#define MSDOS_INIT_DIR_SIZE 0x00
 
/* "dot" entry offset in a directory */
#define MSDOS_DOT_DIR_ENTRY_OFFSET 0x00 /* first entry in directory */
 
/* "dotdot" entry offset in a directory */
#define MSDOS_DOTDOT_DIR_ENTRY_OFFSET 0x20 /* second entry in directory */
 
/* 'p' should be char* */
#define DOT_NODE_P(p) ((char *)(p))
#define DOTDOT_NODE_P(p) ((char *)((p) + MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE))
 
/* Size limits for files and directories (see M$ White Paper) */
#define MSDOS_MAX_DIR_LENGHT 0x200000 /* 2,097,152 bytes */
#define MSDOS_MAX_FILE_SIZE 0xFFFFFFFF /* 4 Gb */
 
/*
* The number of 32 bytes long FAT Directory Entry
* Structures per 512 bytes sector
*/
#define MSDOS_DPS512_NUM 16
 
/* Prototypes */
int
msdos_initialize(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
 
int
msdos_shut_down(rtems_filesystem_mount_table_entry_t *temp_mt_entry);
 
int
msdos_eval_path(const char *pathname, /* IN */
int flags, /* IN */
rtems_filesystem_location_info_t *pathloc /* IN/OUT */);
 
int
msdos_eval4make(const char *path, /* IN */
rtems_filesystem_location_info_t *pathloc, /* IN/OUT */
const char **name /* OUT */);
int
msdos_unlink(rtems_filesystem_location_info_t *pathloc /* IN */);
 
int
msdos_free_node_info(rtems_filesystem_location_info_t *pathloc /* IN */);
 
rtems_filesystem_node_types_t
msdos_node_type(rtems_filesystem_location_info_t *pathloc);
 
int
msdos_mknod(const char *path, /* IN */
mode_t mode, /* IN */
dev_t dev, /* IN */
rtems_filesystem_location_info_t *pathloc /* IN/OUT */);
 
int
msdos_utime(rtems_filesystem_location_info_t *pathloc, /* IN */
time_t actime, /* IN */
time_t modtime /* IN */);
 
int
msdos_initialize_support(
rtems_filesystem_mount_table_entry_t *temp_mt_entry,
rtems_filesystem_operations_table *op_table,
rtems_filesystem_file_handlers_r *file_handlers,
rtems_filesystem_file_handlers_r *directory_handlers
);
 
int
msdos_file_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
 
int
msdos_file_close(rtems_libio_t *iop /* IN */);
 
ssize_t
msdos_file_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
 
ssize_t
msdos_file_write(
rtems_libio_t *iop, /* IN */
const void *buffer, /* IN */
unsigned32 count /* IN */
);
 
int
msdos_file_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
 
int
msdos_file_stat(rtems_filesystem_location_info_t *loc, /* IN */
struct stat *buf /* OUT */);
 
int
msdos_file_ftruncate(
rtems_libio_t *iop, /* IN */
off_t length /* IN */
);
 
int
msdos_file_sync(rtems_libio_t *iop);
 
int
msdos_file_datasync(rtems_libio_t *iop);
int
msdos_file_ioctl(
rtems_libio_t *iop, /* IN */
unsigned32 command, /* IN */
void *buffer /* IN */
);
 
int
msdos_file_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
int
msdos_dir_open(
rtems_libio_t *iop, /* IN */
const char *pathname, /* IN */
unsigned32 flag, /* IN */
unsigned32 mode /* IN */
);
 
int
msdos_dir_close(rtems_libio_t *iop /* IN */);
 
ssize_t
msdos_dir_read(
rtems_libio_t *iop, /* IN */
void *buffer, /* IN */
unsigned32 count /* IN */
);
 
int
msdos_dir_lseek(
rtems_libio_t *iop, /* IN */
off_t offset, /* IN */
int whence /* IN */
);
 
int
msdos_dir_rmnod(rtems_filesystem_location_info_t *pathloc /* IN */);
 
int
msdos_dir_sync(rtems_libio_t *iop);
 
int
msdos_dir_stat(
rtems_filesystem_location_info_t *loc, /* IN */
struct stat *buf /* OUT */
);
 
int
msdos_creat_node(rtems_filesystem_location_info_t *parent_loc,
msdos_node_type_t type,
char *name,
mode_t mode);
 
/* Misc prototypes */
msdos_token_types_t msdos_get_token(const char *path,
char *token,
int *token_len);
 
int
msdos_find_name(rtems_filesystem_location_info_t *parent_loc,
char *name);
 
int
msdos_get_name_node(rtems_filesystem_location_info_t *parent_loc,
char *name,
fat_auxiliary_t *paux,
char *name_dir_entry);
 
int
msdos_dir_info_remove(rtems_filesystem_location_info_t *pathloc);
 
void
msdos_date_unix2dos(int unix_date,
unsigned short *time_val,
unsigned short *date);
 
unsigned int
msdos_date_dos2unix(unsigned short time_val, unsigned short date);
 
int
msdos_set_first_cluster_num(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd);
 
int
msdos_set_file_size(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd);
 
int
msdos_set_first_char4file_name(rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cl,
unsigned32 ofs,
unsigned char first_char);
 
int
msdos_set_dir_wrt_time_and_date(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd
);
 
int
msdos_dir_is_empty(rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
rtems_boolean *ret_val);
 
int
msdos_find_name_in_fat_file(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
char *name,
fat_auxiliary_t *paux,
char *name_dir_entry);
int
msdos_find_node_by_cluster_num_in_fat_file(
rtems_filesystem_mount_table_entry_t *mt_entry,
fat_file_fd_t *fat_fd,
unsigned32 cl4find,
fat_auxiliary_t *paux,
char *dir_entry
);
 
int
msdos_get_dotdot_dir_info_cluster_num_and_offset(
rtems_filesystem_mount_table_entry_t *mt_entry,
unsigned32 cln,
fat_auxiliary_t *paux,
char *dir_entry
);
 
#ifdef __cplusplus
}
#endif
 
#endif /* __DOSFS_MSDOS_H__ */
/src/dosfs/msdos_node_type.c
0,0 → 1,58
/*
* The following returns the type of node that the loc refers to.
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_node_type.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <rtems.h>
 
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_node_type --
* Determine type of the node that the pathloc refers to.
*
* PARAMETERS:
* pathloc - node description
*
* RETURNS:
* node type
*
*/
rtems_filesystem_node_types_t
msdos_node_type(rtems_filesystem_location_info_t *pathloc)
{
fat_file_fd_t *fat_fd;
 
/*
* we don't need to obtain the volume semaphore here because node_type_h
* call always follows evalpath_h call(hence link increment occured) and
* hence node_access memory can't be freed during processing node_type_h
* call
*/
fat_fd = pathloc->node_access;
return fat_fd->fat_file_type;
}
/src/dosfs/msdos_eval.c
0,0 → 1,435
/*
* MSDOS evaluation routines
*
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* @(#) msdos_eval.c,v 1.1 2002/02/28 20:43:50 joel Exp
*/
 
#if HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <assert.h>
 
#include <rtems/libio_.h>
 
#include "fat.h"
#include "fat_fat_operations.h"
#include "fat_file.h"
 
#include "msdos.h"
 
/* msdos_set_handlers --
* Set handlers for the node with specified type(i.e. handlers for file
* or directory).
*
* PARAMETERS:
* loc - node description
*
* RETURNS:
* None
*/
static void
msdos_set_handlers(rtems_filesystem_location_info_t *loc)
{
msdos_fs_info_t *fs_info = loc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = loc->node_access;
 
if (fat_fd->fat_file_type == FAT_DIRECTORY)
loc->handlers = fs_info->directory_handlers;
else
loc->handlers = fs_info->file_handlers;
}
 
/* msdos_eval_path --
*
* The following routine evaluate path for a node that wishes to be
* accessed. Structure 'pathloc' is returned with a pointer to the
* node to be accessed.
*
* PARAMETERS:
* pathname - path for evaluation
* flags - flags
* pathloc - node description (IN/OUT)
*
* RETURNS:
* RC_OK and filled pathloc on success, or -1 if error occured
* (errno set appropriately)
*
*/
int
msdos_eval_path(
const char *pathname,
int flags,
rtems_filesystem_location_info_t *pathloc
)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = NULL;
rtems_filesystem_location_info_t newloc;
int i = 0;
int len = 0;
msdos_token_types_t type = MSDOS_CURRENT_DIR;
char token[MSDOS_NAME_MAX + 1];
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
if (!pathloc->node_access)
{
errno = ENOENT;
rc = -1;
goto err;
}
 
fat_fd = pathloc->node_access;
 
rc = fat_file_reopen(fat_fd);
if (rc != RC_OK)
goto err;
while ((type != MSDOS_NO_MORE_PATH) && (type != MSDOS_INVALID_TOKEN))
{
type = msdos_get_token(&pathname[i], token, &len);
i += len;
fat_fd = pathloc->node_access;
switch (type)
{
case MSDOS_UP_DIR:
/*
* Only a directory can be decended into.
*/
if (fat_fd->fat_file_type != FAT_DIRECTORY)
{
errno = ENOTDIR;
rc = -1;
goto error;
}
 
/*
* Am I at the root of this mounted filesystem?
*/
if (pathloc->node_access ==
pathloc->mt_entry->mt_fs_root.node_access)
{
/*
* Am I at the root of all filesystems?
* XXX: MSDOS is not supposed to be base fs.
*/
if (pathloc->node_access ==
rtems_filesystem_root.node_access)
{
break; /* Throw out the .. in this case */
}
else
{
newloc = pathloc->mt_entry->mt_point_node;
*pathloc = newloc;
 
rc = fat_file_close(pathloc->mt_entry, fat_fd);
if (rc != RC_OK)
goto err;
rtems_semaphore_release(fs_info->vol_sema);
return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),
flags, pathloc);
}
}
else
{
rc = msdos_find_name(pathloc, token);
if (rc != RC_OK)
{
if (rc == MSDOS_NAME_NOT_FOUND_ERR)
{
errno = ENOENT;
rc = -1;
}
goto error;
}
}
break;
 
case MSDOS_NAME:
/*
* Only a directory can be decended into.
*/
if (fat_fd->fat_file_type != FAT_DIRECTORY)
{
errno = ENOTDIR;
rc = -1;
goto error;
}
 
/*
* Otherwise find the token name in the present location and
* set the node access to the point we have found.
*/
rc = msdos_find_name(pathloc, token);
if (rc != RC_OK)
{
if (rc == MSDOS_NAME_NOT_FOUND_ERR)
{
errno = ENOENT;
rc = -1;
}
goto error;
}
break;
 
case MSDOS_NO_MORE_PATH:
case MSDOS_CURRENT_DIR:
break;
 
case MSDOS_INVALID_TOKEN:
errno = ENAMETOOLONG;
rc = -1;
goto error;
break;
}
}
 
/*
* Always return the root node.
*
* If we are at a node that is a mount point. Set loc to the
* new fs root node and let let the mounted filesystem set the handlers.
*
* NOTE: The behavior of stat() on a mount point appears to be
* questionable.
* NOTE: MSDOS filesystem currently doesn't support mount functionality ->
* action not implemented
*/
fat_fd = pathloc->node_access;
msdos_set_handlers(pathloc);
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
 
error:
fat_file_close(pathloc->mt_entry, fat_fd);
 
err:
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
 
/* msdos_eval4make --
* The following routine evaluate path for a new node to be created.
* 'pathloc' is returned with a pointer to the parent of the new node.
* 'name' is returned with a pointer to the first character in the
* new node name. The parent node is verified to be a directory.
*
* PARAMETERS:
* path - path for evaluation
* pathloc - IN/OUT (start point for evaluation/parent directory for
* creation)
* name - new node name
*
* RETURNS:
* RC_OK, filled pathloc for parent directory and name of new node on
* success, or -1 if error occured (errno set appropriately)
*/
int
msdos_eval4make(
const char *path,
rtems_filesystem_location_info_t *pathloc,
const char **name
)
{
int rc = RC_OK;
rtems_status_code sc = RTEMS_SUCCESSFUL;
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
fat_file_fd_t *fat_fd = NULL;
rtems_filesystem_location_info_t newloc;
msdos_token_types_t type;
int i = 0;
int len;
char token[ MSDOS_NAME_MAX + 1 ];
rtems_boolean done = 0;
 
sc = rtems_semaphore_obtain(fs_info->vol_sema, RTEMS_WAIT,
MSDOS_VOLUME_SEMAPHORE_TIMEOUT);
if (sc != RTEMS_SUCCESSFUL)
set_errno_and_return_minus_one(EIO);
if (!pathloc->node_access)
{
errno = ENOENT;
rc = -1;
goto err;
}
 
fat_fd = pathloc->node_access;
 
rc = fat_file_reopen(fat_fd);
if (rc != RC_OK)
goto err;
 
while (!done)
{
type = msdos_get_token(&path[i], token, &len);
i += len;
fat_fd = pathloc->node_access;
 
switch (type)
{
case MSDOS_UP_DIR:
/*
* Only a directory can be decended into.
*/
if (fat_fd->fat_file_type != FAT_DIRECTORY)
{
errno = ENOTDIR;
rc = -1;
goto error;
}
 
/*
* Am I at the root of this mounted filesystem?
*/
if (pathloc->node_access ==
pathloc->mt_entry->mt_fs_root.node_access)
{
/*
* Am I at the root of all filesystems?
* XXX: MSDOS is not supposed to be base fs.
*/
if (pathloc->node_access ==
rtems_filesystem_root.node_access)
{
break; /* Throw out the .. in this case */
}
else
{
newloc = pathloc->mt_entry->mt_point_node;
*pathloc = newloc;
 
rc = fat_file_close(pathloc->mt_entry, fat_fd);
if (rc != RC_OK)
goto err;
 
rtems_semaphore_release(fs_info->vol_sema);
return (*pathloc->ops->evalformake_h)(&path[i-len],
pathloc, name);
}
}
else
{
rc = msdos_find_name(pathloc, token);
if (rc != RC_OK)
{
if (rc == MSDOS_NAME_NOT_FOUND_ERR)
{
errno = ENOENT;
rc = -1;
}
goto error;
}
}
break;
 
case MSDOS_NAME:
/*
* Only a directory can be decended into.
*/
if (fat_fd->fat_file_type != FAT_DIRECTORY)
{
errno = ENOTDIR;
rc = -1;
goto error;
}
 
/*
* Otherwise find the token name in the present location and
* set the node access to the point we have found.
*/
rc = msdos_find_name(pathloc, token);
if (rc)
{
if (rc != MSDOS_NAME_NOT_FOUND_ERR)
{
errno = ENOENT;
rc = -1;
goto error;
}
else
done = TRUE;
}
break;
 
case MSDOS_NO_MORE_PATH:
errno = EEXIST;
rc = -1;
goto error;
break;
case MSDOS_CURRENT_DIR:
break;
 
case MSDOS_INVALID_TOKEN:
errno = ENAMETOOLONG;
rc = -1;
goto error;
break;
 
}
}
 
*name = &path[i - len];
 
/*
* We have evaluated the path as far as we can.
* Verify there is not any invalid stuff at the end of the name.
*/
for( ; path[i] != '\0'; i++)
{
if (!msdos_is_separator(path[i]))
{
errno = ENOENT;
rc = -1;
goto error;
}
}
 
fat_fd = pathloc->node_access;
 
if (fat_fd->fat_file_type != FAT_DIRECTORY)
{
errno = ENOTDIR;
rc = -1;
goto error;
}
msdos_set_handlers(pathloc);
rtems_semaphore_release(fs_info->vol_sema);
return RC_OK;
 
error:
fat_file_close(pathloc->mt_entry, fat_fd);
 
err:
rtems_semaphore_release(fs_info->vol_sema);
return rc;
}
src/dosfs Property changes : Added: svn:ignore ## -0,0 +1,6 ## +Makefile +Makefile.in +config.h +config.h.in +stamp-h +stamp-h.in Index: src/imfs/miniimfs_init.c =================================================================== --- src/imfs/miniimfs_init.c (nonexistent) +++ src/imfs/miniimfs_init.c (revision 1765) @@ -0,0 +1,74 @@ +/* + * Mini-IMFS Initialization + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * miniimfs_init.c,v 1.7 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include /* for mkdir */ +#include +#include +#include + +#include + +#include "imfs.h" +#include + +#if defined(IMFS_DEBUG) +#include +#endif + +/* + * miniIMFS file system operations table + */ + +rtems_filesystem_operations_table miniIMFS_ops = { + IMFS_eval_path, + IMFS_evaluate_for_make, + NULL, /* XXX IMFS_link, */ + NULL, /* XXX IMFS_unlink, */ + IMFS_node_type, + IMFS_mknod, + NULL, /* XXX IMFS_chown, */ + NULL, /* XXX IMFS_freenodinfo, */ + NULL, /* XXX IMFS_mount, */ + miniIMFS_initialize, + NULL, /* XXX IMFS_unmount, */ + NULL, /* XXX IMFS_fsunmount, */ + NULL, /* XXX IMFS_utime, */ + NULL, /* XXX IMFS_evaluate_link, */ + NULL, /* XXX IMFS_symlink, */ + NULL /* XXX IMFS_readlink */ +}; + +/* + * miniIMFS_initialize + */ + +int miniIMFS_initialize( + rtems_filesystem_mount_table_entry_t *temp_mt_entry +) +{ + IMFS_initialize_support( + temp_mt_entry, + &miniIMFS_ops, + &rtems_filesystem_null_handlers, /* for linearfiles */ + &rtems_filesystem_null_handlers, /* for memfiles */ + &rtems_filesystem_null_handlers /* for directories */ + ); + return 0; +} + + + Index: src/imfs/Makefile.in =================================================================== --- src/imfs/Makefile.in (nonexistent) +++ src/imfs/Makefile.in (revision 1765) @@ -0,0 +1,521 @@ +# Makefile.in generated by automake 1.6.2 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ + +EXEEXT = @EXEEXT@ +OBJEXT = @OBJEXT@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +AMTAR = @AMTAR@ +AWK = @AWK@ +BARE_CPU_CFLAGS = @BARE_CPU_CFLAGS@ +BARE_CPU_MODEL = @BARE_CPU_MODEL@ + +CC = @CC@ $(GCCSPECS) +CPP = @CPP@ $(GCCSPECS) +DEPDIR = @DEPDIR@ +ENDIF = @ENDIF@ +GCCSED = @GCCSED@ +GCC_SPECS = @GCC_SPECS@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +MAINT = @MAINT@ +MAKE = @MAKE@ +MULTIBUILDTOP = @MULTIBUILDTOP@ +MULTISUBDIR = @MULTISUBDIR@ +PACKAGE = @PACKAGE@ +PROJECT_INCLUDE = @PROJECT_INCLUDE@ +PROJECT_ROOT = @PROJECT_ROOT@ +PROJECT_TOPdir = @PROJECT_TOPdir@ +RANLIB = @RANLIB@ +RTEMS_BSP = @RTEMS_BSP@ +RTEMS_CPU = @RTEMS_CPU@ +RTEMS_HOST = @RTEMS_HOST@ +RTEMS_ROOT = @RTEMS_ROOT@ +RTEMS_TOPdir = @RTEMS_TOPdir@ +STRIP = @STRIP@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ +multilib_basedir = @multilib_basedir@ +project_libdir = @project_libdir@ + +LIB = ${ARCH}/libimfs.a + +IMFS_C_FILES = imfs_chown.c imfs_config.c imfs_creat.c imfs_directory.c \ + imfs_eval.c imfs_free.c imfs_fsunmount.c imfs_gtkn.c imfs_init.c \ + imfs_initsupp.c imfs_link.c imfs_mknod.c imfs_mount.c imfs_fchmod.c \ + imfs_unlink.c imfs_unmount.c imfs_utime.c imfs_ntype.c imfs_stat.c \ + imfs_getchild.c memfile.c linearfile.c deviceio.c imfs_handlers_device.c \ + imfs_handlers_directory.c imfs_handlers_link.c imfs_handlers_memfile.c \ + imfs_debug.c imfs_rmnod.c imfs_symlink.c imfs_readlink.c imfs_fdatasync.c \ + imfs_fcntl.c ioman.c miniimfs_init.c imfs_load_tar.c + + +UNIX_C_FILES = imfs_unixstub.c + +EMBEDDED_C_FILES = $(IMFS_C_FILES) + +COMMON_C_FILES = + +@UNIX_TRUE@C_FILES = $(COMMON_C_FILES) $(UNIX_C_FILES) +@UNIX_FALSE@C_FILES = $(COMMON_C_FILES) $(EMBEDDED_C_FILES) +C_O_FILES = $(C_FILES:%.c=${ARCH}/%.$(OBJEXT)) + +include_HEADERS = imfs.h + +@MULTILIB_TRUE@MULTISRCTOP = +@MULTILIB_TRUE@MULTIDIRS = +@MULTILIB_TRUE@MULTIDO = true +@MULTILIB_TRUE@MULTICLEAN = true + +@RTEMS_USE_GCC_TRUE@CFLAGS_DEFAULT = -g -Wall +@RTEMS_USE_GCC_TRUE@GCCSPECS = $(GCC_SPECS) + +DEFS = @DEFS@ + +CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) \ + $(DEFINES) $(XCPPFLAGS) $(CPPFLAGS_GCC) + +CFLAGS = $(CFLAGS_DEFAULT) $(CPU_CFLAGS) $(XCFLAGS) +ASFLAGS = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS) + +# when debugging, optimize flag: typically empty +# some compilers do allow optimization with their "-g" +CFLAGS_DEBUG_OPTIMIZE_V = -g + +# profile flag; use gprof(1) +CFLAGS_PROFILE_V = -pg + + +# +# How to compile stuff into ${ARCH} subdirectory +# +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) + +CCLD = $(CC) + +CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS) + + +# Dependency files for use by gmake +# NOTE: we don't put them into $(ARCH) +# so that 'make clean' doesn't blow it away +DEPEND = Depends-${ARCH} + +CLEAN_DEPEND = $(DEPEND).tmp +CLOBBER_DEPEND = $(DEPEND) + +VARIANT = OPTIMIZE + +VARIANT_OPTIMIZE_V = OPTIMIZE +VARIANT_DEBUG_V = DEBUG +VARIANT_PROFILE_V = PROFILE +VARIANT_optimize_V = OPTIMIZE +VARIANT_debug_V = DEBUG +VARIANT_profile_V = PROFILE + +VARIANT_V = $(VARIANT_$(VARIANT)_V) + +ARCH_OPTIMIZE_V = o-optimize +ARCH_DEBUG_V = o-debug +ARCH_PROFILE_V = o-profile + +ARCH__V = $(ARCH_OPTIMIZE_V) +ARCH = $(ARCH_$(VARIANT_V)_V) + +LIBSUFFIX_OPTIMIZE_V = +LIBSUFFIX_DEBUG_V = _g +LIBSUFFIX_PROFILE_V = _p +LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) + +LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) +LIBSUFFIX_VA = $(LIB_VARIANT).a + +CFLAGS__V = $(CFLAGS_OPTIMIZE_V) + +@RTEMS_USE_GCC_TRUE@RTEMS_CFLAGS_OPTIMIZE_V = +@RTEMS_USE_GCC_TRUE@RTEMS_CFLAGS_DEBUG_V = -Wno-unused +@RTEMS_USE_GCC_TRUE@RTEMS_CFLAGS_PROFILE_V = + +RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) + +AM_CPPFLAGS = $(RTEMS_CPPFLAGS) -I../.. $(LIBC_DEFINES) + +AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) + +# AM_CFLAGS = $(RTEMS_BSP_CFLAGS) $(RTEMS_CFLAGS) +AM_CCASFLAGS = $(RTEMS_BSP_CFLAGS) $(RTEMS_CPPFLAGS) $(RTEMS_ASFLAGS) + +AR = @AR@ + +ARFLAGS = ruv + +TMPINSTALL_FILES = $(project_libdir)$(MULTISUBDIR) + +PREINSTALL_FILES = $(PROJECT_INCLUDE) \ + $(include_HEADERS:%=$(PROJECT_INCLUDE)/%) + + +OBJS = $(C_O_FILES) + +DOC_FILES = TODO CASES + +EXTRA_DIST = $(DOC_FILES) $(COMMON_C_FILES) $(EMBEDDED_C_FILES) \ + $(UNIX_C_FILES) + + +PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools +subdir = src/imfs +mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +HEADERS = $(include_HEADERS) + +DIST_COMMON = $(include_HEADERS) Makefile.am Makefile.in +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/../automake/multilib.am $(top_srcdir)/../automake/compile.am $(top_srcdir)/../automake/lib.am $(top_srcdir)/../automake/local.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/imfs/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +uninstall-info-am: +includeHEADERS_INSTALL = $(INSTALL_HEADER) +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(includedir) + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ + $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(includedir)/$$f"; \ + rm -f $(DESTDIR)$(includedir)/$$f; \ + done + +ETAGS = etags +ETAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(HEADERS) all-local + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(includedir) + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-local distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +uninstall-am: uninstall-includeHEADERS uninstall-info-am + +.PHONY: GTAGS all all-am all-local check check-am clean clean-generic \ + clean-local distclean distclean-generic distclean-local \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-includeHEADERS install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic tags \ + uninstall uninstall-am uninstall-includeHEADERS \ + uninstall-info-am + + +# Multilib support rules +.PHONY: all-multi install-multi mostlyclean-multi clean-multi distclean-multi \ + maintainer-clean-multi + +@MULTILIB_TRUE@all-recursive: all-multi +@MULTILIB_TRUE@install-recursive: install-multi + +@MULTILIB_TRUE@mostlyclean-recursive: mostlyclean-multi +@MULTILIB_TRUE@clean-recursive: clean-multi +@MULTILIB_TRUE@distclean-recursive: distclean-multi +@MULTILIB_TRUE@maintainer-clean-recursive: maintainer-clean-multi + +@MULTILIB_TRUE@all-multi: +@MULTILIB_TRUE@ $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do +@MULTILIB_TRUE@install-multi: +@MULTILIB_TRUE@ $(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do + +@MULTILIB_TRUE@mostlyclean-multi: +@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean +@MULTILIB_TRUE@clean-multi: +@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean +@MULTILIB_TRUE@distclean-multi: +@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean +@MULTILIB_TRUE@maintainer-clean-multi: +@MULTILIB_TRUE@ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean +@MULTILIB_FALSE@include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +@RTEMS_USE_GCC_FALSE@include $(CONFIG.CC) + +${ARCH}/%.$(OBJEXT): %.c + ${COMPILE} -o $@ -c $< + +${ARCH}/%.$(OBJEXT): %.S + ${CCASCOMPILE} -o $@ -c $< + +# Make foo.rel from foo.$(OBJEXT) +${ARCH}/%.rel: ${ARCH}/%.$(OBJEXT) + ${make-rel} + +# We deliberately don't have anything depend on the +# $(DEPEND) file; otherwise it will get rebuilt even +# on 'make clean' +# + +depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) + $(COMPILE) -M $^ | \ + sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ + -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp + mv $(DEPEND).tmp $(DEPEND) +depend: depend-am + +# pull in dependencies if they exist +ifeq (${DEPEND},$(wildcard ${DEPEND})) +include ${DEPEND} +@ENDIF@ + +define make-library +$(RM) $@ +$(AR) $(ARFLAGS) $@ $^ +$(RANLIB) $@ +endef + +$(project_libdir)$(MULTISUBDIR): + @$(mkinstalldirs) $@ + +.PRECIOUS: $(LIB) + +$(PROJECT_INCLUDE): + @$(mkinstalldirs) $@ + +$(PROJECT_INCLUDE)/%.h: %.h + $(INSTALL_DATA) $< $@ + +# +# Add local stuff here using += +# + +all-local: ${ARCH} $(LIB) + +$(LIB): ${OBJS} + $(make-library) + +debug: + @echo + @echo "\"make debug\" is obsolete, instead use:" + @echo " make VARIANT=DEBUG" + @echo + +.PHONY: debug + +profile: + @echo + @echo "\"make profile\" is obsolete, instead use:" + @echo " make VARIANT=PROFILE" + @echo + +.PHONY: profile + +preinstall-am: $(PREINSTALL_FILES) +preinstall: preinstall-am +.PHONY: preinstall preinstall-am + +depend-am: +depend: depend-am +.PHONY: depend depend-am + +${ARCH}: + mkdir ${ARCH} + +clean-local: + $(RM) -r o-optimize o-debug o-profile $(CLEANDIRS) + $(RM) Depends-o-optimize.tmp Depends-o-debug.tmp Depends-o-profile.tmp + +distclean-local: + $(RM) Depends-o-optimize Depends-o-debug Depends-o-profile +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: Index: src/imfs/imfs_getchild.c =================================================================== --- src/imfs/imfs_getchild.c (nonexistent) +++ src/imfs/imfs_getchild.c (revision 1765) @@ -0,0 +1,73 @@ +/* + * IMFS_find_match_in_dir() + * + * This routine returns the child name in the given directory. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_getchild.c,v 1.6 2002/04/08 18:28:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include "imfs.h" + +static char dotname[2] = "."; +static char dotdotname[3] = ".."; + +IMFS_jnode_t *IMFS_find_match_in_dir( + IMFS_jnode_t *directory, + char *name +) +{ + Chain_Node *the_node; + Chain_Control *the_chain; + IMFS_jnode_t *the_jnode; + + /* + * Check for fatal errors. A NULL directory show a problem in the + * the IMFS code. + */ + + assert( directory ); + if ( !name ) + return 0; + + assert( name ); + if ( !directory ) + return 0; + + /* + * Check for "." and ".." + */ + + if ( !strcmp( name, dotname ) ) + return directory; + + if ( !strcmp( name, dotdotname ) ) + return directory->Parent; + + the_chain = &directory->info.directory.Entries; + + for ( the_node = the_chain->first; + !_Chain_Is_tail( the_chain, the_node ); + the_node = the_node->next ) { + + the_jnode = (IMFS_jnode_t *) the_node; + + if ( !strcmp( name, the_jnode->name ) ) + return the_jnode; + } + + return 0; +} Index: src/imfs/imfs_handlers_directory.c =================================================================== --- src/imfs/imfs_handlers_directory.c (nonexistent) +++ src/imfs/imfs_handlers_directory.c (revision 1765) @@ -0,0 +1,42 @@ +/* + * Operations Table for Directories for the IMFS + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_handlers_directory.c,v 1.6 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "imfs.h" + +/* + * Set of operations handlers for operations on directories. + */ + +rtems_filesystem_file_handlers_r IMFS_directory_handlers = { + imfs_dir_open, + imfs_dir_close, + imfs_dir_read, + NULL, /* write */ + NULL, /* ioctl */ + imfs_dir_lseek, + imfs_dir_fstat, + IMFS_fchmod, + NULL, /* ftruncate */ + NULL, /* fpathconf */ + NULL, /* fsync */ + IMFS_fdatasync, + IMFS_fcntl, + imfs_dir_rmnod +}; + Index: src/imfs/imfs_load_tar.c =================================================================== --- src/imfs/imfs_load_tar.c (nonexistent) +++ src/imfs/imfs_load_tar.c (revision 1765) @@ -0,0 +1,260 @@ +/* + * imfs_load_tar.c,v 1.6 2002/01/08 12:05:36 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +/************************************************************************** + * This file implements the "mount" procedure for tar-based IMFS + * extensions. The TAR is not actually mounted under the IMFS. + * Directories from the TAR file are created as usual in the IMFS. + * File entries are created as IMFS_LINEAR_FILE nodes with their nods + * pointing to addresses in the TAR image. + *************************************************************************/ + +#include +#include +#include + +#include + +#include +#include +#include +#include + + +/************************************************************************** + * TAR file format: + * + * Offset Length Contents + * 0 100 bytes File name ('\0' terminated, 99 maxmum length) + * 100 8 bytes File mode (in octal ascii) + * 108 8 bytes User ID (in octal ascii) + * 116 8 bytes Group ID (in octal ascii) + * 124 12 bytes File size (s) (in octal ascii) + * 136 12 bytes Modify time (in octal ascii) + * 148 8 bytes Header checksum (in octal ascii) + * 156 1 bytes Link flag + * 157 100 bytes Linkname ('\0' terminated, 99 maxmum length) + * 257 8 bytes Magic ("ustar \0") + * 265 32 bytes User name ('\0' terminated, 31 maxmum length) + * 297 32 bytes Group name ('\0' terminated, 31 maxmum length) + * 329 8 bytes Major device ID (in octal ascii) + * 337 8 bytes Minor device ID (in octal ascii) + * 345 167 bytes Padding + * 512 (s+p)bytes File contents (s+p) := (((s) + 511) & ~511), + * round up to 512 bytes + * + * Checksum: + * int i, sum; + * char* header = tar_header_pointer; + * sum = 0; + * for(i = 0; i < 512; i++) + * sum += 0xFF & header[i]; + *************************************************************************/ + +#define LF_OLDNORMAL '\0' /* Normal disk file, Unix compatible */ +#define LF_NORMAL '0' /* Normal disk file */ +#define LF_LINK '1' /* Link to previously dumped file */ +#define LF_SYMLINK '2' /* Symbolic link */ +#define LF_CHR '3' /* Character special file */ +#define LF_BLK '4' /* Block special file */ +#define LF_DIR '5' /* Directory */ +#define LF_FIFO '6' /* FIFO special file */ +#define LF_CONFIG '7' /* Contiguous file */ + +#define MAX_NAME_FIELD_SIZE 99 + +#define MIN(a,b) ((a)>(b)?(b):(a)) + +static unsigned long octal2ulong(char *octascii, int len); +static int compute_tar_header_checksum(char *bufr); + +/************************************************************************** + * rtems_tarfs_load + * + * Here we create the mountpoint directory and load the tarfs at + * that node. Once the IMFS has been mounted, we work through the + * tar image and perform as follows: + * - For directories, simply call mkdir(). The IMFS creates nodes as + * needed. + * - For files, we make our own calls to IMFS eval_for_make and + * create_node. + *************************************************************************/ +int +rtems_tarfs_load(char *mountpoint, + unsigned char *tar_image, + unsigned long tar_size) +{ + rtems_filesystem_location_info_t root_loc; + rtems_filesystem_location_info_t loc; + char *hdr_ptr; + char filename[100]; + char full_filename[256]; + int hdr_chksum; + unsigned char linkflag; + unsigned long file_size; + unsigned long file_mode; + int offset; + unsigned long nblocks; + IMFS_jnode_t *node; + int status; + + + status = rtems_filesystem_evaluate_path(mountpoint, 0, &root_loc, 0); + if (status != 0) + return(-1); + + if (root_loc.ops != &IMFS_ops) + return(-1); + + /*********************************************************************** + * Create an IMFS node structure pointing to tar image memory. + **********************************************************************/ + offset = 0; + while (1) + { + if (offset + 512 > tar_size) + break; + + /****************************************************************** + * Read a header. + ******************************************************************/ + hdr_ptr = &tar_image[offset]; + offset += 512; + if (strncmp(&hdr_ptr[257], "ustar ", 7)) + break; + + strncpy(filename, hdr_ptr, MAX_NAME_FIELD_SIZE); + filename[MAX_NAME_FIELD_SIZE] = '\0'; + + linkflag = hdr_ptr[156]; + file_mode = octal2ulong(&hdr_ptr[100], 8); + file_size = octal2ulong(&hdr_ptr[124], 12); + hdr_chksum = (int)octal2ulong(&hdr_ptr[148], 8); + + if (compute_tar_header_checksum(hdr_ptr) != hdr_chksum) + break; + + /****************************************************************** + * Generate an IMFS node depending on the file type. + * - For directories, just create directories as usual. IMFS + * will take care of the rest. + * - For files, create a file node with special tarfs properties. + *****************************************************************/ + if (linkflag == LF_DIR) + { + strcpy(full_filename, mountpoint); + if (full_filename[strlen(full_filename)-1] != '/') + strcat(full_filename, "/"); + strcat(full_filename, filename); + mkdir(full_filename, S_IRWXU | S_IRWXG | S_IRWXO); + } + /****************************************************************** + * Create a LINEAR_FILE node if no user write permission. + *****************************************************************/ + else if ((linkflag == LF_NORMAL) && + ((file_mode & 0200) == 0000)) + { + const char *name; + + loc = root_loc; + if (IMFS_evaluate_for_make(filename, &loc, &name) == 0) + { + node = IMFS_create_node(&loc, + IMFS_LINEAR_FILE, (char *)name, + (S_IRUSR | S_IRGRP | S_IROTH) | S_IFREG, + NULL); + node->info.linearfile.size = file_size; + node->info.linearfile.direct = &tar_image[offset]; + } + + nblocks = (((file_size) + 511) & ~511) / 512; + offset += 512 * nblocks; + } + /****************************************************************** + * Create a regular MEMORY_FILE if write permission exists. + *****************************************************************/ + else if ((linkflag == LF_NORMAL) && + ((file_mode & 0200) == 0200)) + { + int fd; + int n, left, ptr; + + strcpy(full_filename, mountpoint); + if (full_filename[strlen(full_filename)-1] != '/') + strcat(full_filename, "/"); + strcat(full_filename, filename); + + fd = creat(full_filename, S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP); + if (fd != -1) + { + left = file_size; + ptr = offset; + while ((n = write(fd, &tar_image[ptr], left)) > 0) + { + left -= n; + ptr += n; + } + close(fd); + } + + nblocks = (((file_size) + 511) & ~511) / 512; + offset += 512 * nblocks; + } + } + + return(status); +} + +/************************************************************************** + * This converts octal ASCII number representations into an + * unsigned long. Only support 32-bit numbers for now. + *************************************************************************/ +static unsigned long +octal2ulong(char *octascii, int len) +{ + int i; + unsigned long num; + unsigned long mult; + + num = 0; + mult = 1; + for (i=len-1; i>=0; i--) + { + if (octascii[i] < '0') + continue; + if (octascii[i] > '9') + continue; + + num += mult*((unsigned long)(octascii[i] - '0')); + mult *= 8; + } + return(num); +} + + +/************************************************************************ + * Compute the TAR checksum and check with the value in + * the archive. The checksum is computed over the entire + * header, but the checksum field is substituted with blanks. + ************************************************************************/ +static int +compute_tar_header_checksum(char *bufr) +{ + int i, sum; + + + sum = 0; + for (i=0; i<512; i++) + { + if ((i >= 148) && (i < 156)) + sum += 0xff & ' '; + else + sum += 0xff & bufr[i]; + } + return(sum); +} Index: src/imfs/imfs_symlink.c =================================================================== --- src/imfs/imfs_symlink.c (nonexistent) +++ src/imfs/imfs_symlink.c (revision 1765) @@ -0,0 +1,64 @@ +/* + * IMFS_symlink + * + * The following rouine creates a new symbolic link node under parent + * with the name given in name. The node is set to point to the node at + * to_loc. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_symlink.c,v 1.6 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "imfs.h" +#include +#include + +int IMFS_symlink( + rtems_filesystem_location_info_t *parent_loc, + const char *link_name, + const char *node_name +) +{ + IMFS_types_union info; + IMFS_jnode_t *new_node; + char new_name[ IMFS_NAME_MAX + 1 ]; + int i; + + /* + * Remove any separators at the end of the string. + */ + + IMFS_get_token( node_name, new_name, &i ); + + info.sym_link.name = link_name; + + /* + * Create a new link node. + */ + + new_node = IMFS_create_node( + parent_loc, + IMFS_SYM_LINK, + new_name, + ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )), + &info + ); + + if ( !new_node ) + rtems_set_errno_and_return_minus_one( ENOMEM ); + + return 0; +} + + Index: src/imfs/imfs_eval.c =================================================================== --- src/imfs/imfs_eval.c (nonexistent) +++ src/imfs/imfs_eval.c (revision 1765) @@ -0,0 +1,660 @@ +/* + * Evaluation IMFS Node Support Routines + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_eval.c,v 1.16 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "imfs.h" +#include +#include + +#define RTEMS_LIBIO_PERMS_RX (RTEMS_LIBIO_PERMS_SEARCH | RTEMS_LIBIO_PERMS_READ) +#define RTEMS_LIBIO_PERMS_WX (RTEMS_LIBIO_PERMS_SEARCH | RTEMS_LIBIO_PERMS_WRITE) + +#define MAXSYMLINK 5 + +int IMFS_Set_handlers( + rtems_filesystem_location_info_t *loc +) +{ + IMFS_jnode_t *node = loc->node_access; + IMFS_fs_info_t *fs_info; + + fs_info = loc->mt_entry->fs_info; + switch( node->type ) { + case IMFS_DIRECTORY: + loc->handlers = fs_info->directory_handlers; + break; + case IMFS_DEVICE: + loc->handlers = &IMFS_device_handlers; + break; + case IMFS_SYM_LINK: + case IMFS_HARD_LINK: + loc->handlers = &IMFS_link_handlers; + break; + case IMFS_LINEAR_FILE: + loc->handlers = fs_info->linearfile_handlers; + break; + case IMFS_MEMORY_FILE: + loc->handlers = fs_info->memfile_handlers; + break; + } + + return 0; +} + +/* + * IMFS_evaluate_permission + * + * The following routine evaluates that we have permission + * to do flags on the node. + */ + +int IMFS_evaluate_permission( + rtems_filesystem_location_info_t *node, + int flags +) +{ + uid_t st_uid; + gid_t st_gid; + IMFS_jnode_t *jnode; + int flags_to_test; + + if ( !rtems_libio_is_valid_perms( flags ) ) { + assert( 0 ); + rtems_set_errno_and_return_minus_one( EIO ); + } + + jnode = node->node_access; + +#if defined(RTEMS_POSIX_API) + st_uid = geteuid(); + st_gid = getegid(); +#else + st_uid = jnode->st_uid; + st_gid = jnode->st_gid; +#endif + + /* + * Check if I am owner or a group member or someone else. + */ + + flags_to_test = flags; + + if ( st_uid == jnode->st_uid ) + flags_to_test <<= 6; + else if ( st_gid == jnode->st_gid ) + flags_to_test <<= 3; + else + /* must be other - do nothing */; + + /* + * If all of the flags are set we have permission + * to do this. + */ + if ( ( flags_to_test & jnode->st_mode) == flags_to_test ) + return 1; + + return 0; +} + +/* + * IMFS_evaluate_hard_link + * + * The following routine evaluates a hardlink to the actual node. + */ + +int IMFS_evaluate_hard_link( + rtems_filesystem_location_info_t *node, /* IN/OUT */ + int flags /* IN */ +) +{ + IMFS_jnode_t *jnode = node->node_access; + int result = 0; + + /* + * Check for things that should never happen. + */ + + if ( jnode->type != IMFS_HARD_LINK ) + rtems_fatal_error_occurred (0xABCD0000); + + /* + * Set the hard link value and the handlers. + */ + + node->node_access = jnode->info.hard_link.link_node; + + IMFS_Set_handlers( node ); + + /* + * Verify we have the correct permissions for this node. + */ + + if ( !IMFS_evaluate_permission( node, flags ) ) + rtems_set_errno_and_return_minus_one( EACCES ); + + return result; +} + + +/* + * IMFS_evaluate_sym_link + * + * The following routine evaluates a symbolic link to the actual node. + */ + +int IMFS_evaluate_sym_link( + rtems_filesystem_location_info_t *node, /* IN/OUT */ + int flags /* IN */ +) +{ + IMFS_jnode_t *jnode = node->node_access; + int result = 0; + int i; + + /* + * Check for things that should never happen. + */ + + if ( jnode->type != IMFS_SYM_LINK ) + rtems_fatal_error_occurred (0xABCD0000); + + if ( !jnode->Parent ) + rtems_fatal_error_occurred( 0xBAD00000 ); + + + /* + * Move the node_access to either the symbolic links parent or + * root depending on the symbolic links path. + */ + + node->node_access = jnode->Parent; + + rtems_filesystem_get_sym_start_loc( + jnode->info.sym_link.name, + &i, + node + ); + + /* + * Use eval path to evaluate the path of the symbolic link. + */ + + result = IMFS_eval_path( + &jnode->info.sym_link.name[i], + flags, + node + ); + + IMFS_Set_handlers( node ); + + /* + * Verify we have the correct permissions for this node. + */ + + if ( !IMFS_evaluate_permission( node, flags ) ) + rtems_set_errno_and_return_minus_one( EACCES ); + + return result; +} + +/* + * IMFS_evaluate_link + * + * The following routine returns the real node pointed to by a link. + */ + +int IMFS_evaluate_link( + rtems_filesystem_location_info_t *node, /* IN/OUT */ + int flags /* IN */ +) +{ + IMFS_jnode_t *jnode; + int result = 0; + + do { + jnode = node->node_access; + + /* + * Increment and check the link counter. + */ + + rtems_filesystem_link_counts ++; + if ( rtems_filesystem_link_counts > MAXSYMLINK ) { + rtems_filesystem_link_counts = 0; + rtems_set_errno_and_return_minus_one( ELOOP ); + } + + /* + * Follow the Link node. + */ + + if ( jnode->type == IMFS_HARD_LINK ) + result = IMFS_evaluate_hard_link( node, flags ); + + else if (jnode->type == IMFS_SYM_LINK ) + result = IMFS_evaluate_sym_link( node, flags ); + + } while ( ( result == 0 ) && ( ( jnode->type == IMFS_SYM_LINK ) || + ( jnode->type == IMFS_HARD_LINK ) ) ); + + /* + * Clear link counter. + */ + + rtems_filesystem_link_counts = 0; + + return result; +} + + +/* + * IMFS_evaluate_for_make + * + * The following routine evaluate path for a new node to be created. + * pathloc is returned with a pointer to the parent of the new node. + * name is returned with a pointer to the first character in the + * new node name. The parent node is verified to be a directory. + */ + +int IMFS_evaluate_for_make( + const char *path, /* IN */ + rtems_filesystem_location_info_t *pathloc, /* IN/OUT */ + const char **name /* OUT */ +) +{ + int i = 0; + int len; + IMFS_token_types type; + char token[ IMFS_NAME_MAX + 1 ]; + rtems_filesystem_location_info_t newloc; + IMFS_jnode_t *node; + int done = 0; + int result; + + /* + * This was filled in by the caller and is valid in the + * mount table. + */ + node = pathloc->node_access; + + /* + * Evaluate all tokens until we are done or an error occurs. + */ + + while( !done ) { + + type = IMFS_get_token( &path[i], token, &len ); + i += len; + + if ( !pathloc->node_access ) + rtems_set_errno_and_return_minus_one( ENOENT ); + + /* + * I cannot move out of this directory without execute permission. + */ + + if ( type != IMFS_NO_MORE_PATH ) + if ( node->type == IMFS_DIRECTORY ) + if ( !IMFS_evaluate_permission( pathloc, RTEMS_LIBIO_PERMS_SEARCH ) ) + rtems_set_errno_and_return_minus_one( EACCES ); + + node = pathloc->node_access; + + switch( type ) { + + case IMFS_UP_DIR: + /* + * Am I at the root of all filesystems? (chroot'ed?) + */ + + if ( pathloc->node_access == rtems_filesystem_root.node_access ) + break; /* Throw out the .. in this case */ + + + /* + * Am I at the root of this mounted filesystem? + */ + + if (pathloc->node_access == pathloc->mt_entry->mt_fs_root.node_access){ + + /* + * Am I at the root of all filesystems? + */ + + if ( pathloc->node_access == rtems_filesystem_root.node_access ) { + break; + + } else { + newloc = pathloc->mt_entry->mt_point_node; + *pathloc = newloc; + return (*pathloc->ops->evalformake_h)( &path[i-len], pathloc, name ); + } + } else { + + if ( !node->Parent ) + rtems_set_errno_and_return_minus_one( ENOENT ); + + node = node->Parent; + } + + pathloc->node_access = node; + break; + + case IMFS_NAME: + + if ( node->type == IMFS_HARD_LINK ) { + + result = IMFS_evaluate_link( pathloc, 0 ); + if ( result == -1 ) + return -1; + + } else if ( node->type == IMFS_SYM_LINK ) { + + result = IMFS_evaluate_link( pathloc, 0 ); + + if ( result == -1 ) + return -1; + } + + node = pathloc->node_access; + if ( !node ) + rtems_set_errno_and_return_minus_one( ENOTDIR ); + + /* + * Only a directory can be decended into. + */ + + if ( node->type != IMFS_DIRECTORY ) + rtems_set_errno_and_return_minus_one( ENOTDIR ); + + /* + * If we are at a node that is a mount point. Set loc to the + * new fs root node and let them finish evaluating the path. + */ + + if ( node->info.directory.mt_fs != NULL ) { + newloc = node->info.directory.mt_fs->mt_fs_root; + *pathloc = newloc; + return (*pathloc->ops->evalformake_h)( &path[i-len], pathloc, name ); + } + + /* + * Otherwise find the token name in the present location. + */ + + node = IMFS_find_match_in_dir( node, token ); + + /* + * If there is no node we have found the name of the node we + * wish to create. + */ + + if ( ! node ) + done = TRUE; + else + pathloc->node_access = node; + + break; + + case IMFS_NO_MORE_PATH: + rtems_set_errno_and_return_minus_one( EEXIST ); + break; + + case IMFS_INVALID_TOKEN: + rtems_set_errno_and_return_minus_one( ENAMETOOLONG ); + break; + + case IMFS_CURRENT_DIR: + break; + } + } + + *name = &path[ i - len ]; + + /* + * We have evaluated the path as far as we can. + * Verify there is not any invalid stuff at the end of the name. + */ + + for( ; path[i] != '\0'; i++) { + if ( !IMFS_is_separator( path[ i ] ) ) + rtems_set_errno_and_return_minus_one( ENOENT ); + } + + /* + * Verify we can execute and write to this directory. + */ + + result = IMFS_Set_handlers( pathloc ); + + /* + * The returned node must be a directory + */ + node = pathloc->node_access; + if ( node->type != IMFS_DIRECTORY ) + rtems_set_errno_and_return_minus_one( ENOTDIR ); + + /* + * We must have Write and execute permission on the returned node. + */ + + if ( !IMFS_evaluate_permission( pathloc, RTEMS_LIBIO_PERMS_WX ) ) + rtems_set_errno_and_return_minus_one( EACCES ); + + return result; +} + + +/* + * IMFS_eval_path + * + * The following routine evaluate path for a node that wishes to be + * accessed with mode. pathloc is returned with a pointer to the + * node to be accessed. + */ + +int IMFS_eval_path( + const char *pathname, /* IN */ + int flags, /* IN */ + rtems_filesystem_location_info_t *pathloc /* IN/OUT */ +) +{ + int i = 0; + int len; + IMFS_token_types type = IMFS_CURRENT_DIR; + char token[ IMFS_NAME_MAX + 1 ]; + rtems_filesystem_location_info_t newloc; + IMFS_jnode_t *node; + int result; + + if ( !rtems_libio_is_valid_perms( flags ) ) { + assert( 0 ); + rtems_set_errno_and_return_minus_one( EIO ); + } + + /* + * This was filled in by the caller and is valid in the + * mount table. + */ + + node = pathloc->node_access; + + /* + * Evaluate all tokens until we are done or an error occurs. + */ + + while( (type != IMFS_NO_MORE_PATH) && (type != IMFS_INVALID_TOKEN) ) { + + type = IMFS_get_token( &pathname[i], token, &len ); + i += len; + + if ( !pathloc->node_access ) + rtems_set_errno_and_return_minus_one( ENOENT ); + + /* + * I cannot move out of this directory without execute permission. + */ + if ( type != IMFS_NO_MORE_PATH ) + if ( node->type == IMFS_DIRECTORY ) + if ( !IMFS_evaluate_permission( pathloc, RTEMS_LIBIO_PERMS_SEARCH ) ) + rtems_set_errno_and_return_minus_one( EACCES ); + + node = pathloc->node_access; + + switch( type ) { + case IMFS_UP_DIR: + /* + * Am I at the root of all filesystems? (chroot'ed?) + */ + + if ( pathloc->node_access == rtems_filesystem_root.node_access ) + break; /* Throw out the .. in this case */ + + /* + * Am I at the root of this mounted filesystem? + */ + + if (pathloc->node_access == + pathloc->mt_entry->mt_fs_root.node_access) { + + /* + * Am I at the root of all filesystems? + */ + + if ( pathloc->node_access == rtems_filesystem_root.node_access ) { + break; /* Throw out the .. in this case */ + } else { + newloc = pathloc->mt_entry->mt_point_node; + *pathloc = newloc; + return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),flags,pathloc); + } + } else { + + if ( !node->Parent ) + rtems_set_errno_and_return_minus_one( ENOENT ); + + node = node->Parent; + pathloc->node_access = node; + + } + + pathloc->node_access = node; + break; + + case IMFS_NAME: + /* + * If we are at a link follow it. + */ + + if ( node->type == IMFS_HARD_LINK ) { + + IMFS_evaluate_hard_link( pathloc, 0 ); + + node = pathloc->node_access; + if ( !node ) + rtems_set_errno_and_return_minus_one( ENOTDIR ); + + } else if ( node->type == IMFS_SYM_LINK ) { + + result = IMFS_evaluate_sym_link( pathloc, 0 ); + + node = pathloc->node_access; + if ( result == -1 ) + return -1; + } + + /* + * Only a directory can be decended into. + */ + + if ( node->type != IMFS_DIRECTORY ) + rtems_set_errno_and_return_minus_one( ENOTDIR ); + + /* + * If we are at a node that is a mount point. Set loc to the + * new fs root node and let them finish evaluating the path. + */ + + if ( node->info.directory.mt_fs != NULL ) { + newloc = node->info.directory.mt_fs->mt_fs_root; + *pathloc = newloc; + return (*pathloc->ops->evalpath_h)( &pathname[i-len], flags, pathloc ); + } + + /* + * Otherwise find the token name in the present location. + */ + + node = IMFS_find_match_in_dir( node, token ); + if ( !node ) + rtems_set_errno_and_return_minus_one( ENOENT ); + + /* + * Set the node access to the point we have found. + */ + + pathloc->node_access = node; + break; + + case IMFS_NO_MORE_PATH: + case IMFS_CURRENT_DIR: + break; + + case IMFS_INVALID_TOKEN: + rtems_set_errno_and_return_minus_one( ENAMETOOLONG ); + break; + + } + } + + /* + * Always return the root node. + * + * If we are at a node that is a mount point. Set loc to the + * new fs root node and let let the mounted filesystem set the handlers. + * + * NOTE: The behavior of stat() on a mount point appears to be questionable. + */ + + if ( node->type == IMFS_DIRECTORY ) { + if ( node->info.directory.mt_fs != NULL ) { + newloc = node->info.directory.mt_fs->mt_fs_root; + *pathloc = newloc; + return (*pathloc->ops->evalpath_h)( &pathname[i-len], flags, pathloc ); + } else { + result = IMFS_Set_handlers( pathloc ); + } + } else { + result = IMFS_Set_handlers( pathloc ); + } + + /* + * Verify we have the correct permissions for this node. + */ + + if ( !IMFS_evaluate_permission( pathloc, flags ) ) + rtems_set_errno_and_return_minus_one( EACCES ); + + return result; +} Index: src/imfs/imfs_readlink.c =================================================================== --- src/imfs/imfs_readlink.c (nonexistent) +++ src/imfs/imfs_readlink.c (revision 1765) @@ -0,0 +1,44 @@ +/* + * IMFS_readlink + * + * The following rouine puts the symblic links destination name into + * buff. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_readlink.c,v 1.5 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "imfs.h" +#include +#include + +int IMFS_readlink( + rtems_filesystem_location_info_t *loc, + char *buf, /* OUT */ + size_t bufsize +) +{ + IMFS_jnode_t *node; + int i; + + node = loc->node_access; + + if ( node->type != IMFS_SYM_LINK ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + for( i=0; ((iinfo.sym_link.name[i] != '\0')); i++ ) + buf[i] = node->info.sym_link.name[i]; + + return i; +} Index: src/imfs/linearfile.c =================================================================== --- src/imfs/linearfile.c (nonexistent) +++ src/imfs/linearfile.c (revision 1765) @@ -0,0 +1,116 @@ +/* + * IMFS Linear File Handlers + * + * This file contains the set of handlers used to process operations on + * IMFS linear memory file nodes. Linear memory files are contiguous + * blocks of memory created from a TAR or other filesystem image. + * The blocks are nonwriteable and nonresizeable. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * linearfile.c,v 1.4 2002/04/08 18:28:59 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include +#include +#include "imfs.h" +#include +#include + +/* + * linearfile_read + * + * This routine processes the read() system call. + */ + +int linearfile_read( + rtems_libio_t *iop, + void *buffer, + unsigned32 count +) +{ + IMFS_jnode_t *the_jnode; + unsigned char *dest; + unsigned char *file_ptr; + int file_offset; + + + the_jnode = iop->file_info; + + /* + * Perform internal consistency checks + */ + + assert( the_jnode ); + if ( !the_jnode ) + rtems_set_errno_and_return_minus_one( EIO ); + + assert( the_jnode->type == IMFS_LINEAR_FILE ); + if ( the_jnode->type != IMFS_LINEAR_FILE ) + rtems_set_errno_and_return_minus_one( EIO ); + + /* + * Error checks on arguments + */ + + dest = (unsigned char *)buffer; + assert( dest ); + if ( !dest ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + /* + * Perform a simple memory copy. + */ + + if (count == 0) + return(0); + + the_jnode = iop->file_info; + file_ptr = (unsigned char *)the_jnode->info.linearfile.direct; + file_offset = (unsigned long)iop->offset; + + if (count > (the_jnode->info.linearfile.size - file_offset)) + count = the_jnode->info.linearfile.size - file_offset; + + memcpy(dest, &file_ptr[file_offset], count); + + return(count); +} + + +/* + * linearfile_lseek + * + * This routine processes the lseek() system call. + */ + +int linearfile_lseek( + rtems_libio_t *iop, + off_t offset, + int whence +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + if (iop->offset > the_jnode->info.linearfile.size) + iop->offset = the_jnode->info.linearfile.size; + + return iop->offset; +} + Index: src/imfs/imfs_link.c =================================================================== --- src/imfs/imfs_link.c (nonexistent) +++ src/imfs/imfs_link.c (revision 1765) @@ -0,0 +1,76 @@ +/* + * IMFS_link + * + * The following rouine creates a new link node under parent with the + * name given in name. The link node is set to point to the node at + * to_loc. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_link.c,v 1.7 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "imfs.h" +#include +#include + +int IMFS_link( + rtems_filesystem_location_info_t *to_loc, /* IN */ + rtems_filesystem_location_info_t *parent_loc, /* IN */ + const char *token /* IN */ +) +{ + IMFS_types_union info; + IMFS_jnode_t *new_node; + char new_name[ IMFS_NAME_MAX + 1 ]; + int i; + + /* + * Verify this node can be linked to. + */ + + info.hard_link.link_node = to_loc->node_access; + if ( info.hard_link.link_node->st_nlink >= LINK_MAX ) + rtems_set_errno_and_return_minus_one( EMLINK ); + + /* + * Remove any separators at the end of the string. + */ + + IMFS_get_token( token, new_name, &i ); + + /* + * Create a new link node. + */ + + new_node = IMFS_create_node( + parent_loc, + IMFS_HARD_LINK, + new_name, + ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )), + &info + ); + + if ( !new_node ) + rtems_set_errno_and_return_minus_one( ENOMEM ); + + /* + * Increment the link count of the node being pointed to. + */ + + info.hard_link.link_node->st_nlink++; + IMFS_update_ctime( info.hard_link.link_node ); + + return 0; +} + Index: src/imfs/imfs_creat.c =================================================================== --- src/imfs/imfs_creat.c (nonexistent) +++ src/imfs/imfs_creat.c (revision 1765) @@ -0,0 +1,137 @@ +/* + * IMFS_create_node() + * + * Routine to create a new in memory file system node. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_creat.c,v 1.8 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include "imfs.h" +#include + +IMFS_jnode_t *IMFS_create_node( + rtems_filesystem_location_info_t *parent_loc, + IMFS_jnode_types_t type, + char *name, + mode_t mode, + IMFS_types_union *info +) +{ + IMFS_jnode_t *node; + struct timeval tv; + IMFS_jnode_t *parent = NULL; + IMFS_fs_info_t *fs_info; + char *sym_name; + + if ( parent_loc != NULL ) + parent = parent_loc->node_access; + + /* + * Allocate an IMFS jnode + */ + + node = calloc( 1, sizeof( IMFS_jnode_t ) ); + if ( !node ) + return NULL; + + /* + * Fill in the basic information + */ + + node->st_nlink = 1; + node->type = type; + strncpy( node->name, name, IMFS_NAME_MAX ); + + /* + * Fill in the mode and permission information for the jnode structure. + */ + + node->st_mode = mode & ~rtems_filesystem_umask; + +#if defined(RTEMS_POSIX_API) + node->st_uid = geteuid(); + node->st_gid = getegid(); +#else + node->st_uid = 0; + node->st_gid = 0; +#endif + + /* + * Now set all the times. + */ + + gettimeofday( &tv, 0 ); + + node->stat_atime = (time_t) tv.tv_sec; + node->stat_mtime = (time_t) tv.tv_sec; + node->stat_ctime = (time_t) tv.tv_sec; + + /* + * Set the type specific information + */ + + switch (type) { + case IMFS_DIRECTORY: + Chain_Initialize_empty(&node->info.directory.Entries); + break; + + case IMFS_HARD_LINK: + node->info.hard_link.link_node = info->hard_link.link_node; + break; + + case IMFS_SYM_LINK: + sym_name = calloc( 1, strlen( info->sym_link.name ) + 1 ); + strcpy( sym_name, info->sym_link.name ); + node->info.sym_link.name = sym_name; + break; + + case IMFS_DEVICE: + node->info.device.major = info->device.major; + node->info.device.minor = info->device.minor; + break; + + case IMFS_LINEAR_FILE: + node->info.linearfile.size = 0; + node->info.linearfile.direct = 0; + + case IMFS_MEMORY_FILE: + node->info.file.size = 0; + node->info.file.indirect = 0; + node->info.file.doubly_indirect = 0; + node->info.file.triply_indirect = 0; + break; + + default: + assert(0); + break; + } + + /* + * If this node has a parent, then put it in that directory list. + */ + + if ( parent ) { + Chain_Append( &parent->info.directory.Entries, &node->Node ); + node->Parent = parent; + + fs_info = parent_loc->mt_entry->fs_info; + node->st_ino = ++fs_info->ino_count; + } + + + return node; +} Index: src/imfs/imfs_fsunmount.c =================================================================== --- src/imfs/imfs_fsunmount.c (nonexistent) +++ src/imfs/imfs_fsunmount.c (revision 1765) @@ -0,0 +1,100 @@ +/* + * IMFS Initialization + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_fsunmount.c,v 1.7 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include /* for mkdir */ +#include +#include +#include + +#include + +#include "imfs.h" +#include + +#if defined(IMFS_DEBUG) +#include +#endif + +/* + * IMFS_fsunmount + */ + +#define jnode_get_control( jnode ) \ + (&jnode->info.directory.Entries) + +#define jnode_has_no_children( jnode ) \ + Chain_Is_empty( jnode_get_control( jnode ) ) + +#define jnode_has_children( jnode ) \ + ( ! jnode_has_no_children( jnode ) ) + +#define jnode_get_first_child( jnode ) \ + ((IMFS_jnode_t *)( Chain_Head( jnode_get_control( jnode ) )->next)) + +int IMFS_fsunmount( + rtems_filesystem_mount_table_entry_t *temp_mt_entry +) +{ + IMFS_jnode_t *jnode; + IMFS_jnode_t *next; + rtems_filesystem_location_info_t loc; + int result = 0; + + /* + * Traverse tree that starts at the mt_fs_root and deallocate memory + * associated memory space + */ + + jnode = (IMFS_jnode_t *)temp_mt_entry->mt_fs_root.node_access; + loc = temp_mt_entry->mt_fs_root; + + /* + * Set this to null to indicate that it is being unmounted. + */ + + temp_mt_entry->mt_fs_root.node_access = NULL; + + do { + next = jnode->Parent; + loc.node_access = (void *)jnode; + IMFS_Set_handlers( &loc ); + + if ( jnode->type != IMFS_DIRECTORY ) { + result = IMFS_unlink( &loc ); + if (result != 0) + return -1; + jnode = next; + } else if ( jnode_has_no_children( jnode ) ) { + result = IMFS_unlink( &loc ); + if (result != 0) + return -1; + jnode = next; + } + if ( jnode != NULL ) { + if ( jnode->type == IMFS_DIRECTORY ) { + if ( jnode_has_children( jnode ) ) + jnode = jnode_get_first_child( jnode ); + } + } + } while (jnode != NULL); + + return 0; +} + + + + Index: src/imfs/imfs_ntype.c =================================================================== --- src/imfs/imfs_ntype.c (nonexistent) +++ src/imfs/imfs_ntype.c (revision 1765) @@ -0,0 +1,32 @@ +/* + * IMFS_node_type + * + * The following verifies that returns the type of node that the + * loc refers to. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_ntype.c,v 1.3 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "imfs.h" + +rtems_filesystem_node_types_t IMFS_node_type( + rtems_filesystem_location_info_t *pathloc /* IN */ +) +{ + IMFS_jnode_t *node; + + node = pathloc->node_access; + return node->type; +} Index: src/imfs/imfs_unlink.c =================================================================== --- src/imfs/imfs_unlink.c (nonexistent) +++ src/imfs/imfs_unlink.c (revision 1765) @@ -0,0 +1,78 @@ +/* + * IMFS_unlink + * + * Routine to remove a link node from the tree. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_unlink.c,v 1.10 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "imfs.h" +#include +#include + +int IMFS_unlink( + rtems_filesystem_location_info_t *loc /* IN */ +) +{ + IMFS_jnode_t *node; + rtems_filesystem_location_info_t the_link; + int result = 0; + + node = loc->node_access; + + /* + * Decrement the link counter of node pointed to and free the + * space. + */ + + /* + * If this is the last last pointer to the node + * free the node. + */ + + if ( node->type == IMFS_HARD_LINK ) { + + if ( !node->info.hard_link.link_node ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + the_link = *loc; + the_link.node_access = node->info.hard_link.link_node; + IMFS_Set_handlers( &the_link ); + + /* + * If removing the last hard link to a node, then we need + * to remove the node that is a link and the node itself. + */ + + node->info.hard_link.link_node->st_nlink --; + IMFS_update_ctime( node->info.hard_link.link_node ); + if ( node->info.hard_link.link_node->st_nlink < 1) { + result = (*the_link.handlers->rmnod_h)( &the_link ); + if ( result != 0 ) + return -1; + } + } + + /* + * Now actually free the node we were asked to free. + */ + + result = (*loc->handlers->rmnod_h)( loc ); + + return result; +} + Index: src/imfs/memfile.c =================================================================== --- src/imfs/memfile.c (nonexistent) +++ src/imfs/memfile.c (revision 1765) @@ -0,0 +1,1137 @@ +/* + * IMFS Device Node Handlers + * + * This file contains the set of handlers used to process operations on + * IMFS memory file nodes. The memory files are created in memory using + * malloc'ed memory. Thus any data stored in one of these files is lost + * at system shutdown unless special arrangements to copy the data to + * some type of non-volailte storage are made by the application. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * memfile.c,v 1.17 2002/04/08 18:28:59 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include +#include +#include "imfs.h" +#include +#include + +#define MEMFILE_STATIC + +/* + * Prototypes of private routines + */ + +MEMFILE_STATIC int IMFS_memfile_extend( + IMFS_jnode_t *the_jnode, + off_t new_length +); + +MEMFILE_STATIC int IMFS_memfile_addblock( + IMFS_jnode_t *the_jnode, + unsigned int block +); + +MEMFILE_STATIC int IMFS_memfile_remove_block( + IMFS_jnode_t *the_jnode, + unsigned int block +); + +MEMFILE_STATIC block_p *IMFS_memfile_get_block_pointer( + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +); + +MEMFILE_STATIC int IMFS_memfile_read( + IMFS_jnode_t *the_jnode, + off_t start, + unsigned char *destination, + unsigned int length +); + +MEMFILE_STATIC int IMFS_memfile_write( + IMFS_jnode_t *the_jnode, + off_t start, + const unsigned char *source, + unsigned int length +); + +void *memfile_alloc_block(void); + +void memfile_free_block( + void *memory +); + +/* + * memfile_open + * + * This routine processes the open() system call. Note that there is + * nothing special to be done at open() time. + */ + +int memfile_open( + rtems_libio_t *iop, + const char *pathname, + unsigned32 flag, + unsigned32 mode +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + if (iop->flags & LIBIO_FLAGS_APPEND) + iop->offset = the_jnode->info.file.size; + + iop->size = the_jnode->info.file.size; + return 0; +} + +/* + * memfile_close + * + * This routine processes the close() system call. Note that there is + * nothing to flush or memory to free at this point. + */ + +int memfile_close( + rtems_libio_t *iop +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + if (iop->flags & LIBIO_FLAGS_APPEND) + iop->offset = the_jnode->info.file.size; + + return 0; +} + +/* + * memfile_read + * + * This routine processes the read() system call. + */ + +int memfile_read( + rtems_libio_t *iop, + void *buffer, + unsigned32 count +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + return IMFS_memfile_read( the_jnode, iop->offset, buffer, count ); +} + +/* + * memfile_write + * + * This routine processes the write() system call. + */ + +int memfile_write( + rtems_libio_t *iop, + const void *buffer, + unsigned32 count +) +{ + IMFS_jnode_t *the_jnode; + int status; + + the_jnode = iop->file_info; + + status = IMFS_memfile_write( the_jnode, iop->offset, buffer, count ); + iop->size = the_jnode->info.file.size; + + return status; +} + +/* + * memfile_ioctl + * + * This routine processes the ioctl() system call. + * + * NOTE: No ioctl()'s are supported for in-memory files. + */ + +int memfile_ioctl( + rtems_libio_t *iop, + unsigned32 command, + void *buffer +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + return 0; +} + +/* + * memfile_lseek + * + * This routine processes the lseek() system call. + */ + +int memfile_lseek( + rtems_libio_t *iop, + off_t offset, + int whence +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + if (the_jnode->type == IMFS_LINEAR_FILE) { + if (iop->offset > the_jnode->info.linearfile.size) + iop->offset = the_jnode->info.linearfile.size; + } + else { /* Must be a block file (IMFS_MEMORY_FILE). */ + if (IMFS_memfile_extend( the_jnode, iop->offset )) + rtems_set_errno_and_return_minus_one( ENOSPC ); + + iop->size = the_jnode->info.file.size; + } + return iop->offset; +} + +/* + * memfile_stat + * + * This IMFS_stat() can be used. + */ + +/* + * memfile_ftruncate + * + * This routine processes the ftruncate() system call. + */ + +int memfile_ftruncate( + rtems_libio_t *iop, + off_t length +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + /* + * POSIX 1003.1b does not specify what happens if you truncate a file + * and the new length is greater than the current size. We treat this + * as an extend operation. + */ + + if ( length > the_jnode->info.file.size ) + return IMFS_memfile_extend( the_jnode, length ); + + /* + * The in-memory files do not currently reclaim memory until the file is + * deleted. So we leave the previously allocated blocks in place for + * future use and just set the length. + */ + + the_jnode->info.file.size = length; + iop->size = the_jnode->info.file.size; + + IMFS_update_atime( the_jnode ); + + return 0; +} + +/* + * IMFS_memfile_extend + * + * This routine insures that the in-memory file is of the length + * specified. If necessary, it will allocate memory blocks to + * extend the file. + */ + +MEMFILE_STATIC int IMFS_memfile_extend( + IMFS_jnode_t *the_jnode, + off_t new_length +) +{ + unsigned int block; + unsigned int new_blocks; + unsigned int old_blocks; + + /* + * Perform internal consistency checks + */ + + assert( the_jnode ); + if ( !the_jnode ) + rtems_set_errno_and_return_minus_one( EIO ); + + assert( the_jnode->type == IMFS_MEMORY_FILE ); + if ( the_jnode->type != IMFS_MEMORY_FILE ) + rtems_set_errno_and_return_minus_one( EIO ); + + if ( new_length >= IMFS_MEMFILE_MAXIMUM_SIZE ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + if ( new_length <= the_jnode->info.file.size ) + return 0; + + /* + * Calculate the number of range of blocks to allocate + */ + + new_blocks = new_length / IMFS_MEMFILE_BYTES_PER_BLOCK; + old_blocks = the_jnode->info.file.size / IMFS_MEMFILE_BYTES_PER_BLOCK; + + /* + * Now allocate each of those blocks. + */ + + for ( block=old_blocks ; block<=new_blocks ; block++ ) { + if ( IMFS_memfile_addblock( the_jnode, block ) ) { + for ( ; block>=old_blocks ; block-- ) { + IMFS_memfile_remove_block( the_jnode, block ); + } + rtems_set_errno_and_return_minus_one( ENOSPC ); + } + } + + /* + * Set the new length of the file. + */ + + the_jnode->info.file.size = new_length; + return 0; +} + +/* + * IMFS_memfile_addblock + * + * This routine adds a single block to the specified in-memory file. + */ + +MEMFILE_STATIC int IMFS_memfile_addblock( + IMFS_jnode_t *the_jnode, + unsigned int block +) +{ + block_p memory; + block_p *block_entry_ptr; + + assert( the_jnode ); + if ( !the_jnode ) + rtems_set_errno_and_return_minus_one( EIO ); + + assert( the_jnode->type == IMFS_MEMORY_FILE ); + if ( the_jnode->type != IMFS_MEMORY_FILE ) + rtems_set_errno_and_return_minus_one( EIO ); + + block_entry_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 1 ); + if ( *block_entry_ptr ) + return 0; + +#if 0 + printf( "%d %p", block, block_entry_ptr ); + fflush(stdout); +#endif + + memory = memfile_alloc_block(); + if ( !memory ) + return 1; + *block_entry_ptr = memory; + + return 0; +} + +/* + * IMFS_memfile_remove_block + * + * This routine removes the specified block from the in-memory file. + * + * NOTE: This is a support routine and is called only to remove + * the last block or set of blocks in a file. Removing a + * block from the middle of a file would be exceptionally + * dangerous and the results unpredictable. + */ + +MEMFILE_STATIC int IMFS_memfile_remove_block( + IMFS_jnode_t *the_jnode, + unsigned int block +) +{ + block_p *block_entry_ptr; + block_p ptr; + + block_entry_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); + ptr = *block_entry_ptr; + *block_entry_ptr = 0; + + memfile_free_block( ptr ); + + return 1; +} + +/* + * memfile_free_blocks_in_table + * + * This is a support routine for IMFS_memfile_remove. It frees all the + * blocks in one of the indirection tables. + */ + +void memfile_free_blocks_in_table( + block_p **block_table, + int entries +) +{ + int i; + block_p *b; + + /* + * Perform internal consistency checks + */ + + assert( block_table ); + if ( !block_table ) + return; + + /* + * Now go through all the slots in the table and free the memory. + */ + + b = *block_table; + + for ( i=0 ; itype == IMFS_MEMORY_FILE ); + if ( the_jnode->type != IMFS_MEMORY_FILE ) + rtems_set_errno_and_return_minus_one( EIO ); + + /* + * Eventually this could be set smarter at each call to + * memfile_free_blocks_in_table to greatly speed this up. + */ + + to_free = IMFS_MEMFILE_BLOCK_SLOTS; + + /* + * Now start freeing blocks in this order: + * + indirect + * + doubly indirect + * + triply indirect + */ + + info = &the_jnode->info.file; + + if ( info->indirect ) { + memfile_free_blocks_in_table( &info->indirect, to_free ); + } + + if ( info->doubly_indirect ) { + + for ( i=0 ; idoubly_indirect[i] ) { + memfile_free_blocks_in_table( + (block_p **)&info->doubly_indirect[i], to_free ); + } + } + memfile_free_blocks_in_table( &info->doubly_indirect, to_free ); + + } + + if ( info->triply_indirect ) { + for ( i=0 ; itriply_indirect[i]; + if ( !p ) /* ensure we have a valid pointer */ + break; + for ( j=0 ; jtriply_indirect[i], to_free ); + } + memfile_free_blocks_in_table( + (block_p **)&info->triply_indirect, to_free ); + } + + return 0; +} + +/* + * IMFS_memfile_read + * + * This routine read from memory file pointed to by the_jnode into + * the specified data buffer specified by destination. The file + * is NOT extended. An offset greater than the length of the file + * is considered an error. Read from an offset for more bytes than + * are between the offset and the end of the file will result in + * reading the data between offset and the end of the file (truncated + * read). + */ + +MEMFILE_STATIC int IMFS_memfile_read( + IMFS_jnode_t *the_jnode, + off_t start, + unsigned char *destination, + unsigned int length +) +{ + block_p *block_ptr; + unsigned int block; + unsigned int my_length; + unsigned int to_copy = 0; + unsigned int last_byte; + unsigned int copied; + unsigned int start_offset; + unsigned char *dest; + + dest = destination; + + /* + * Perform internal consistency checks + */ + + assert( the_jnode ); + if ( !the_jnode ) + rtems_set_errno_and_return_minus_one( EIO ); + + assert( the_jnode->type == IMFS_MEMORY_FILE || + the_jnode->type == IMFS_LINEAR_FILE ); + if ( the_jnode->type != IMFS_MEMORY_FILE && + the_jnode->type != IMFS_LINEAR_FILE ) + rtems_set_errno_and_return_minus_one( EIO ); + + /* + * Error checks on arguments + */ + + assert( dest ); + if ( !dest ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + /* + * If there is nothing to read, then quick exit. + */ + + my_length = length; + if ( !my_length ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + /* + * Linear files (as created from a tar file are easier to handle + * than block files). + */ + if (the_jnode->type == IMFS_LINEAR_FILE) { + unsigned char *file_ptr; + + file_ptr = (unsigned char *)the_jnode->info.linearfile.direct; + + if (my_length > (the_jnode->info.linearfile.size - start)) + my_length = the_jnode->info.linearfile.size - start; + + memcpy(dest, &file_ptr[start], my_length); + + IMFS_update_atime( the_jnode ); + + return my_length; + } + + /* + * If the last byte we are supposed to read is past the end of this + * in memory file, then shorten the length to read. + */ + + last_byte = start + length; + if ( last_byte > the_jnode->info.file.size ) + my_length = the_jnode->info.file.size - start; + + copied = 0; + + /* + * Three phases to the read: + * + possibly the last part of one block + * + all of zero of more blocks + * + possibly the first part of one block + */ + + /* + * Phase 1: possibly the last part of one block + */ + + start_offset = start % IMFS_MEMFILE_BYTES_PER_BLOCK; + block = start / IMFS_MEMFILE_BYTES_PER_BLOCK; + if ( start_offset ) { + to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK - start_offset; + if ( to_copy > my_length ) + to_copy = my_length; + block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); + assert( block_ptr ); + if ( !block_ptr ) + return copied; + memcpy( dest, &(*block_ptr)[ start_offset ], to_copy ); + dest += to_copy; + block++; + my_length -= to_copy; + copied += to_copy; + } + + /* + * Phase 2: all of zero of more blocks + */ + + to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK; + while ( my_length >= IMFS_MEMFILE_BYTES_PER_BLOCK ) { + block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); + assert( block_ptr ); + if ( !block_ptr ) + return copied; + memcpy( dest, &(*block_ptr)[ 0 ], to_copy ); + dest += to_copy; + block++; + my_length -= to_copy; + copied += to_copy; + } + + /* + * Phase 3: possibly the first part of one block + */ + + assert( my_length < IMFS_MEMFILE_BYTES_PER_BLOCK ); + + if ( my_length ) { + block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); + assert( block_ptr ); + if ( !block_ptr ) + return copied; + memcpy( dest, &(*block_ptr)[ 0 ], my_length ); + copied += my_length; + } + + IMFS_update_atime( the_jnode ); + + return copied; +} + +/* + * IMFS_memfile_write + * + * This routine writes the specified data buffer into the in memory + * file pointed to by the_jnode. The file is extended as needed. + */ + +MEMFILE_STATIC int IMFS_memfile_write( + IMFS_jnode_t *the_jnode, + off_t start, + const unsigned char *source, + unsigned int length +) +{ + block_p *block_ptr; + unsigned int block; + int status; + unsigned int my_length; + unsigned int to_copy = 0; + unsigned int last_byte; + unsigned int start_offset; + int copied; + const unsigned char *src; + + src = source; + + /* + * Perform internal consistency checks + */ + + assert( the_jnode ); + if ( !the_jnode ) + rtems_set_errno_and_return_minus_one( EIO ); + + assert( the_jnode->type == IMFS_MEMORY_FILE ); + if ( the_jnode->type != IMFS_MEMORY_FILE ) + rtems_set_errno_and_return_minus_one( EIO ); + + /* + * Error check arguments + */ + + assert( source ); + if ( !source ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + + /* + * If there is nothing to write, then quick exit. + */ + + my_length = length; + if ( !my_length ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + /* + * If the last byte we are supposed to write is past the end of this + * in memory file, then extend the length. + */ + + last_byte = start + length; + if ( last_byte > the_jnode->info.file.size ) { + status = IMFS_memfile_extend( the_jnode, last_byte ); + if ( status ) + rtems_set_errno_and_return_minus_one( ENOSPC ); + } + + copied = 0; + + /* + * Three phases to the write: + * + possibly the last part of one block + * + all of zero of more blocks + * + possibly the first part of one block + */ + + /* + * Phase 1: possibly the last part of one block + */ + + start_offset = start % IMFS_MEMFILE_BYTES_PER_BLOCK; + block = start / IMFS_MEMFILE_BYTES_PER_BLOCK; + if ( start_offset ) { + to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK - start_offset; + if ( to_copy > my_length ) + to_copy = my_length; + block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); + assert( block_ptr ); + if ( !block_ptr ) + return copied; +#if 0 +printf( "write %d at %d in %d: %*s\n", to_copy, start_offset, block, to_copy, src ); +#endif + memcpy( &(*block_ptr)[ start_offset ], src, to_copy ); + src += to_copy; + block++; + my_length -= to_copy; + copied += to_copy; + } + + /* + * Phase 2: all of zero of more blocks + */ + + to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK; + while ( my_length >= IMFS_MEMFILE_BYTES_PER_BLOCK ) { + block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); + assert( block_ptr ); + if ( !block_ptr ) + return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif + memcpy( &(*block_ptr)[ 0 ], src, to_copy ); + src += to_copy; + block++; + my_length -= to_copy; + copied += to_copy; + } + + /* + * Phase 3: possibly the first part of one block + */ + + assert( my_length < IMFS_MEMFILE_BYTES_PER_BLOCK ); + + to_copy = my_length; + if ( my_length ) { + block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); + assert( block_ptr ); + if ( !block_ptr ) + return copied; +#if 0 +printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); +#endif + memcpy( &(*block_ptr)[ 0 ], src, my_length ); + my_length = 0; + copied += to_copy; + } + + IMFS_atime_mtime_update( the_jnode ); + + return copied; +} + +/* + * IMFS_memfile_get_block_pointer + * + * This routine looks up the block pointer associated with the given block + * number. If that block has not been allocated and "malloc_it" is + * TRUE, then the block is allocated. Otherwise, it is an error. + */ + +#if 0 +block_p *IMFS_memfile_get_block_pointer_DEBUG( + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +); + +block_p *IMFS_memfile_get_block_pointer( + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +) +{ + block_p *p; + + p = IMFS_memfile_get_block_pointer_DEBUG( the_jnode, block, malloc_it ); + printf( "(%d -> %p) ", block, p ); + return p; +} + +block_p *IMFS_memfile_get_block_pointer_DEBUG( +#else +block_p *IMFS_memfile_get_block_pointer( +#endif + IMFS_jnode_t *the_jnode, + unsigned int block, + int malloc_it +) +{ + unsigned int my_block; + IMFS_memfile_t *info; + unsigned int singly; + unsigned int doubly; + unsigned int triply; + block_p *p; + block_p *p1; + block_p *p2; + + /* + * Perform internal consistency checks + */ + + assert( the_jnode ); + if ( !the_jnode ) + return NULL; + + assert( the_jnode->type == IMFS_MEMORY_FILE ); + if ( the_jnode->type != IMFS_MEMORY_FILE ) + return NULL; + + info = &the_jnode->info.file; + + my_block = block; + + /* + * Is the block number in the simple indirect portion? + */ + + if ( my_block <= LAST_INDIRECT ) { +#if 0 +printf( "(s %d) ", block ); +fflush(stdout); +#endif + p = info->indirect; + + if ( malloc_it ) { + + if ( !p ) { + p = memfile_alloc_block(); + if ( !p ) + return 0; + info->indirect = p; + } + return &info->indirect[ my_block ]; + } + + if ( !p ) + return 0; + + return &info->indirect[ my_block ]; + } + + /* + * Is the block number in the doubly indirect portion? + */ + + if ( my_block <= LAST_DOUBLY_INDIRECT ) { +#if 0 +printf( "(d %d) ", block ); +fflush(stdout); +#endif + + my_block -= FIRST_DOUBLY_INDIRECT; + + singly = my_block % IMFS_MEMFILE_BLOCK_SLOTS; + doubly = my_block / IMFS_MEMFILE_BLOCK_SLOTS; + + p = info->doubly_indirect; + if ( malloc_it ) { + + if ( !p ) { + p = memfile_alloc_block(); + if ( !p ) + return 0; + info->doubly_indirect = p; + } + + p1 = (block_p *)p[ doubly ]; + if ( !p1 ) { + p1 = memfile_alloc_block(); + if ( !p1 ) + return 0; + p[ doubly ] = (block_p) p1; + } + + return (block_p *)&p1[ singly ]; + } + + if ( !p ) + return 0; + + p = (block_p *)p[ doubly ]; + if ( !p ) + return 0; + +#if 0 +printf( "(d %d %d %d %d %p %p) ", block, my_block, doubly, + singly, p, &p[singly] ); +fflush(stdout); +#endif + return (block_p *)&p[ singly ]; + } + +#if 0 +printf( "(t %d) ", block ); +fflush(stdout); +#endif + /* + * Is the block number in the triply indirect portion? + */ + + if ( my_block <= LAST_TRIPLY_INDIRECT ) { + my_block -= FIRST_TRIPLY_INDIRECT; + + singly = my_block % IMFS_MEMFILE_BLOCK_SLOTS; + doubly = my_block / IMFS_MEMFILE_BLOCK_SLOTS; + triply = doubly / IMFS_MEMFILE_BLOCK_SLOTS; + doubly %= IMFS_MEMFILE_BLOCK_SLOTS; + + p = info->triply_indirect; + + if ( malloc_it ) { + if ( !p ) { + p = memfile_alloc_block(); + if ( !p ) + return 0; + info->triply_indirect = p; + } + + p1 = (block_p *) p[ triply ]; + if ( !p1 ) { + p1 = memfile_alloc_block(); + if ( !p1 ) + return 0; + p[ triply ] = (block_p) p1; + } + + p2 = (block_p *)p1[ doubly ]; + if ( !p2 ) { + p2 = memfile_alloc_block(); + if ( !p2 ) + return 0; + p1[ doubly ] = (block_p) p2; + } + return (block_p *)&p2[ singly ]; + } + + if ( !p ) + return 0; + +#if 0 +printf( "(t %d %d %d %d %d) ", block, my_block, triply, doubly, singly ); +fflush(stdout); +#endif + p1 = (block_p *) p[ triply ]; + if ( !p1 ) + return 0; + + p2 = (block_p *)p1[ doubly ]; + if ( !p ) + return 0; + + return (block_p *)&p2[ singly ]; + } + + /* + * This means the requested block number is out of range. + */ + + return 0; +} + +/* + * memfile_alloc_block + * + * Allocate a block for an in-memory file. + */ + +int memfile_blocks_allocated = 0; + +void *memfile_alloc_block(void) +{ + void *memory; + + memory = (void *)calloc(1, IMFS_MEMFILE_BYTES_PER_BLOCK); + if ( memory ) + memfile_blocks_allocated++; + + return memory; +} + +/* + * memfile_free_block + * + * Free a block from an in-memory file. + */ + +void memfile_free_block( + void *memory +) +{ +#if 0 +printf( "(d %p) ", memory ); +fflush(stdout); +#endif + free(memory); + memfile_blocks_allocated--; +} + + +/* + * memfile_rmnod + * + * This routine is available from the optable to remove a node + * from the IMFS file system. + */ + +int memfile_rmnod( + rtems_filesystem_location_info_t *pathloc /* IN */ +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = (IMFS_jnode_t *) pathloc->node_access; + + /* + * Take the node out of the parent's chain that contains this node + */ + + if ( the_jnode->Parent != NULL ) { + Chain_Extract( (Chain_Node *) the_jnode ); + the_jnode->Parent = NULL; + } + + /* + * Decrement the link counter and see if we can free the space. + */ + + the_jnode->st_nlink--; + IMFS_update_ctime( the_jnode ); + + /* + * The file cannot be open and the link must be less than 1 to free. + */ + + if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) { + + /* + * Is the rtems_filesystem_current is this node? + */ + + if ( rtems_filesystem_current.node_access == pathloc->node_access ) + rtems_filesystem_current.node_access = NULL; + + /* + * Free memory associated with a memory file. + */ + if (the_jnode->type != IMFS_LINEAR_FILE) + IMFS_memfile_remove( the_jnode ); + + free( the_jnode ); + } + + return 0; + +} + + Index: src/imfs/imfs_init.c =================================================================== --- src/imfs/imfs_init.c (nonexistent) +++ src/imfs/imfs_init.c (revision 1765) @@ -0,0 +1,71 @@ +/* + * IMFS Initialization + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_init.c,v 1.9 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include /* for mkdir */ +#include +#include +#include + +#include + +#include "imfs.h" +#include + +#if defined(IMFS_DEBUG) +#include +#endif + +/* + * IMFS file system operations table + */ + +rtems_filesystem_operations_table IMFS_ops = { + IMFS_eval_path, + IMFS_evaluate_for_make, + IMFS_link, + IMFS_unlink, + IMFS_node_type, + IMFS_mknod, + IMFS_chown, + IMFS_freenodinfo, + IMFS_mount, + IMFS_initialize, + IMFS_unmount, + IMFS_fsunmount, + IMFS_utime, + IMFS_evaluate_link, + IMFS_symlink, + IMFS_readlink +}; + +/* + * IMFS_initialize + */ + +int IMFS_initialize( + rtems_filesystem_mount_table_entry_t *temp_mt_entry +) +{ + IMFS_initialize_support( + temp_mt_entry, + &IMFS_ops, + &IMFS_linearfile_handlers, + &IMFS_memfile_handlers, + &IMFS_directory_handlers + ); + return 0; +} Index: src/imfs/imfs_gtkn.c =================================================================== --- src/imfs/imfs_gtkn.c (nonexistent) +++ src/imfs/imfs_gtkn.c (revision 1765) @@ -0,0 +1,90 @@ +/* + * IMFS_get_token + * + * Routine to get a token (name or separator) from the path + * the length of the token is returned in token_len. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_gtkn.c,v 1.8 2002/04/08 18:28:59 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "imfs.h" +#include + +IMFS_token_types IMFS_get_token( + const char *path, + char *token, + int *token_len +) +{ + register int i = 0; + IMFS_token_types type = IMFS_NAME; + register char c; + + /* + * Copy a name into token. (Remember NULL is a token.) + */ + c = path[i]; + while ( (!IMFS_is_separator(c)) && (i <= IMFS_NAME_MAX) ) { + + token[i] = c; + + if ( i == IMFS_NAME_MAX ) + return IMFS_INVALID_TOKEN; + + if ( !IMFS_is_valid_name_char(c) ) + type = IMFS_INVALID_TOKEN; + + c = path [++i]; + } + + /* + * Copy a seperator into token. + */ + + if ( i == 0 ) { + token[i] = c; + + if ( token[i] != '\0' ) { + i++; + type = IMFS_CURRENT_DIR; + } else { + type = IMFS_NO_MORE_PATH; + } + } else if (token[ i-1 ] != '\0') { + token[i] = '\0'; + } + + /* + * Set token_len to the number of characters copied. + */ + + *token_len = i; + + /* + * If we copied something that was not a seperator see if + * it was a special name. + */ + + if ( type == IMFS_NAME ) { + if ( strcmp( token, "..") == 0 ) + type = IMFS_UP_DIR; + else if ( strcmp( token, "." ) == 0 ) + type = IMFS_CURRENT_DIR; + } + + return type; +} Index: src/imfs/imfs_config.c =================================================================== --- src/imfs/imfs_config.c (nonexistent) +++ src/imfs/imfs_config.c (revision 1765) @@ -0,0 +1,37 @@ +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_config.c,v 1.3 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include "imfs.h" + +/* XXX this structure should use real constants */ + +rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS = { + 5, /* link_max */ + 6, /* max_canon */ + 7, /* max_input */ + IMFS_NAME_MAX, /* name_max */ + 255, /* path_max */ + 2, /* pipe_buf */ + 1, /* posix_async_io */ + 2, /* posix_chown_restrictions */ + 3, /* posix_no_trunc */ + 4, /* posix_prio_io */ + 5, /* posix_sync_io */ + 6 /* posix_vdisable */ +}; + + Index: src/imfs/imfs_unmount.c =================================================================== --- src/imfs/imfs_unmount.c (nonexistent) +++ src/imfs/imfs_unmount.c (revision 1765) @@ -0,0 +1,62 @@ +/* + * IMFS_unmount + * + * This routine will look at a mount table entry that we are going to + * add to the mount table. If the mount point + * rtems_filesystem_location_info_t struct refers to a node that is a + * directory that has a file system mounted on it, the node will be + * marked as a mount point by * setting its directory.mt_fs pointer + * to NULL. This indicates that a directory is no longer mounted on + * this node. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_unmount.c,v 1.5 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "imfs.h" +#include +#include + +int IMFS_unmount( + rtems_filesystem_mount_table_entry_t *mt_entry +) +{ + IMFS_jnode_t *node; + + node = mt_entry->mt_point_node.node_access; + + /* + * Is the node that we are mounting onto a directory node ? + */ + + if ( node->type != IMFS_DIRECTORY ) + rtems_set_errno_and_return_minus_one( ENOTDIR ); + + /* + * Did the node indicate that there was a directory mounted here? + */ + + if ( node->info.directory.mt_fs == NULL ) + rtems_set_errno_and_return_minus_one( EINVAL ); /* XXX */ + + /* + * Set the mt_fs pointer to indicate that there is no longer + * a file system mounted to this point. + */ + + node->info.directory.mt_fs = NULL; + + return 0; +} Index: src/imfs/imfs_fcntl.c =================================================================== --- src/imfs/imfs_fcntl.c (nonexistent) +++ src/imfs/imfs_fcntl.c (revision 1765) @@ -0,0 +1,28 @@ +/* + * IMFS_fcntl + * + * The following routine does a fcntl on an IMFS node. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_fcntl.c,v 1.3 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "imfs.h" + +int IMFS_fcntl( + int cmd, + rtems_libio_t *iop +) +{ + return 0; +} Index: src/imfs/deviceio.c =================================================================== --- src/imfs/deviceio.c (nonexistent) +++ src/imfs/deviceio.c (revision 1765) @@ -0,0 +1,260 @@ +/* + * IMFS Device Node Handlers + * + * This file contains the set of handlers used to map operations on + * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * deviceio.c,v 1.7 2001/07/06 21:48:16 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include /* assoc.h not included by rtems.h */ +#include + +#include "imfs.h" + +/* + * Convert RTEMS status to a UNIX errno + */ + +rtems_assoc_t errno_assoc[] = { + { "OK", RTEMS_SUCCESSFUL, 0 }, + { "BUSY", RTEMS_RESOURCE_IN_USE, EBUSY }, + { "INVALID NAME", RTEMS_INVALID_NAME, EINVAL }, + { "NOT IMPLEMENTED", RTEMS_NOT_IMPLEMENTED, ENOSYS }, + { "TIMEOUT", RTEMS_TIMEOUT, ETIMEDOUT }, + { "NO MEMORY", RTEMS_NO_MEMORY, ENOMEM }, + { "NO DEVICE", RTEMS_UNSATISFIED, ENODEV }, + { "INVALID NUMBER", RTEMS_INVALID_NUMBER, EBADF}, + { "NOT RESOURCE OWNER", RTEMS_NOT_OWNER_OF_RESOURCE, EPERM}, + { "IO ERROR", RTEMS_IO_ERROR, EIO}, + { 0, 0, 0 }, +}; + +static unsigned32 +rtems_deviceio_errno(rtems_status_code code) +{ + int rc; + + if ((rc = rtems_assoc_remote_by_local(errno_assoc, (unsigned32) code))) + { + errno = rc; + return -1; + } + return -1; +} + +/* + * device_open + * + * This handler maps an open() operation onto rtems_io_open(). + */ + +int device_open( + rtems_libio_t *iop, + const char *pathname, + unsigned32 flag, + unsigned32 mode +) +{ + rtems_libio_open_close_args_t args; + rtems_status_code status; + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + args.iop = iop; + args.flags = iop->flags; + args.mode = mode; + + status = rtems_io_open( + the_jnode->info.device.major, + the_jnode->info.device.minor, + (void *) &args + ); + if ( status ) { + rtems_deviceio_errno(status); + return RTEMS_UNSATISFIED; + } + + return 0; +} + +/* + * device_close + * + * This handler maps a close() operation onto rtems_io_close(). + */ + +int device_close( + rtems_libio_t *iop +) +{ + rtems_libio_open_close_args_t args; + rtems_status_code status; + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + args.iop = iop; + args.flags = 0; + args.mode = 0; + + status = rtems_io_close( + the_jnode->info.device.major, + the_jnode->info.device.minor, + (void *) &args + ); + if ( status ) { + rtems_deviceio_errno(status); + return RTEMS_UNSATISFIED; + } + return 0; +} + +/* + * device_read + * + * This handler maps a read() operation onto rtems_io_read(). + */ + +int device_read( + rtems_libio_t *iop, + void *buffer, + unsigned32 count +) +{ + rtems_libio_rw_args_t args; + rtems_status_code status; + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + args.iop = iop; + args.offset = iop->offset; + args.buffer = buffer; + args.count = count; + args.flags = iop->flags; + args.bytes_moved = 0; + + status = rtems_io_read( + the_jnode->info.device.major, + the_jnode->info.device.minor, + (void *) &args + ); + + if ( status ) + return rtems_deviceio_errno(status); + + return args.bytes_moved; +} + +/* + * device_write + * + * This handler maps a write() operation onto rtems_io_write(). + */ + +int device_write( + rtems_libio_t *iop, + const void *buffer, + unsigned32 count +) +{ + rtems_libio_rw_args_t args; + rtems_status_code status; + IMFS_jnode_t *the_jnode; + + the_jnode = iop->file_info; + + args.iop = iop; + args.offset = iop->offset; + args.buffer = (void *) buffer; + args.count = count; + args.flags = iop->flags; + args.bytes_moved = 0; + + status = rtems_io_write( + the_jnode->info.device.major, + the_jnode->info.device.minor, + (void *) &args + ); + + if ( status ) + return rtems_deviceio_errno(status); + + return args.bytes_moved; +} + +/* + * device_ioctl + * + * This handler maps an ioctl() operation onto rtems_io_ioctl(). + */ + +int device_ioctl( + rtems_libio_t *iop, + unsigned32 command, + void *buffer +) +{ + rtems_libio_ioctl_args_t args; + rtems_status_code status; + IMFS_jnode_t *the_jnode; + + args.iop = iop; + args.command = command; + args.buffer = buffer; + + the_jnode = iop->file_info; + + status = rtems_io_control( + the_jnode->info.device.major, + the_jnode->info.device.minor, + (void *) &args + ); + + if ( status ) + return rtems_deviceio_errno(status); + + return args.ioctl_return; +} + +/* + * device_lseek + * + * This handler eats all lseek() operations. + */ + +int device_lseek( + rtems_libio_t *iop, + off_t offset, + int whence +) +{ + return 0; +} + +/* + * device_stat + * + * The IMFS_stat() is used. + */ + +/* + * device_rmnod + * + * The IMFS_rmnod() is used. + */ Index: src/imfs/imfs_stat.c =================================================================== --- src/imfs/imfs_stat.c (nonexistent) +++ src/imfs/imfs_stat.c (revision 1765) @@ -0,0 +1,68 @@ +/* + * IMFS_stat + * + * This routine provides a stat for the IMFS file system. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_stat.c,v 1.9 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "imfs.h" +#include +#include + +int IMFS_stat( + rtems_filesystem_location_info_t *loc, + struct stat *buf +) +{ + IMFS_jnode_t *the_jnode; + IMFS_device_t *io; + + the_jnode = loc->node_access; + + + switch ( the_jnode->type ) { + + case IMFS_DEVICE: + io = &the_jnode->info.device; + buf->st_dev = rtems_filesystem_make_dev_t( io->major, io->minor ); + break; + + case IMFS_LINEAR_FILE: + case IMFS_MEMORY_FILE: + buf->st_size = the_jnode->info.file.size; + break; + + case IMFS_SYM_LINK: + buf->st_size = 0; + break; + + default: + rtems_set_errno_and_return_minus_one( ENOTSUP ); + break; + } + + buf->st_mode = the_jnode->st_mode; + buf->st_nlink = the_jnode->st_nlink; + buf->st_ino = the_jnode->st_ino; + buf->st_uid = the_jnode->st_uid; + buf->st_gid = the_jnode->st_gid; + + buf->st_atime = the_jnode->stat_atime; + buf->st_mtime = the_jnode->stat_mtime; + buf->st_ctime = the_jnode->stat_ctime; + + return 0; +} Index: src/imfs/imfs_handlers_link.c =================================================================== --- src/imfs/imfs_handlers_link.c (nonexistent) +++ src/imfs/imfs_handlers_link.c (revision 1765) @@ -0,0 +1,41 @@ +/* + * Link Operations Table for the IMFS + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_handlers_link.c,v 1.4 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "imfs.h" + +/* + * Handler table for IMFS device nodes + */ + +rtems_filesystem_file_handlers_r IMFS_link_handlers = { + NULL, /* open */ + NULL, /* close */ + NULL, /* read */ + NULL, /* write */ + NULL, /* ioctl */ + NULL, /* lseek */ + IMFS_stat, /* stat */ + NULL, /* fchmod */ + NULL, /* ftruncate */ + NULL, /* fpathconf */ + NULL, /* fsync */ + NULL, /* fdatasync */ + NULL, /* fcntl */ + IMFS_rmnod +}; Index: src/imfs/imfs_chown.c =================================================================== --- src/imfs/imfs_chown.c (nonexistent) +++ src/imfs/imfs_chown.c (revision 1765) @@ -0,0 +1,56 @@ +/* + * IMFS_chown + * + * This routine is the implementation of the chown() system + * call for the IMFS. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_chown.c,v 1.6 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include "imfs.h" + +int IMFS_chown( + rtems_filesystem_location_info_t *pathloc, /* IN */ + uid_t owner, /* IN */ + gid_t group /* IN */ +) +{ + IMFS_jnode_t *jnode; +#if defined(RTEMS_POSIX_API) + uid_t st_uid; +#endif + + jnode = (IMFS_jnode_t *) pathloc->node_access; + + /* + * Verify I am the owner of the node or the super user. + */ + +#if defined(RTEMS_POSIX_API) + st_uid = geteuid(); + + if ( ( st_uid != jnode->st_uid ) && ( st_uid != 0 ) ) + rtems_set_errno_and_return_minus_one( EPERM ); +#endif + + jnode->st_uid = owner; + jnode->st_gid = group; + + IMFS_update_ctime( jnode ); + + return 0; +} Index: src/imfs/imfs_free.c =================================================================== --- src/imfs/imfs_free.c (nonexistent) +++ src/imfs/imfs_free.c (revision 1765) @@ -0,0 +1,40 @@ +/* + * Free IMFS Node Support Routines + * + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_free.c,v 1.5 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include "imfs.h" + +/* + * IMFS_freenodinfo + * + * This routine is the IMFS free node handler for the file system + * operations table. + * + * The In Memory File System keeps its nodes in memory. This routine + * is for file sytems that do not. + */ + +int IMFS_freenodinfo( + rtems_filesystem_location_info_t *pathloc /* IN */ +) +{ + return 0; +} + Index: src/imfs/imfs_unixstub.c =================================================================== --- src/imfs/imfs_unixstub.c (nonexistent) +++ src/imfs/imfs_unixstub.c (revision 1765) @@ -0,0 +1,74 @@ +/* + * IMFS Stub for UNIX configuration + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_unixstub.c,v 1.4 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include /* for mkdir */ +#include +#include +#include + +#include + +#include "imfs.h" +#include + +#include + +/* + * IMFS file system operations table + */ + +rtems_filesystem_operations_table IMFS_ops = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + +/* + * IMFS file system operations table + */ + +rtems_filesystem_operations_table miniIMFS_ops = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; Index: src/imfs/imfs_utime.c =================================================================== --- src/imfs/imfs_utime.c (nonexistent) +++ src/imfs/imfs_utime.c (revision 1765) @@ -0,0 +1,41 @@ +/* + * IMFS_utime + * + * This routine is the implementation of the utime() system + * call for the IMFS. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_utime.c,v 1.5 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include +#include "imfs.h" + +int IMFS_utime( + rtems_filesystem_location_info_t *pathloc, /* IN */ + time_t actime, /* IN */ + time_t modtime /* IN */ +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = (IMFS_jnode_t *) pathloc->node_access; + + the_jnode->stat_atime = actime; + the_jnode->stat_mtime = modtime; + + return 0; +} Index: src/imfs/imfs.h =================================================================== --- src/imfs/imfs.h (nonexistent) +++ src/imfs/imfs.h (revision 1765) @@ -0,0 +1,546 @@ +/* + * Header file for the In-Memory File System + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs.h,v 1.15 2002/01/04 18:30:58 joel Exp + */ + +#ifndef __IMFS_h +#define __IMFS_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include +#include +#include + +/* + * File name macros + */ + +#define IMFS_is_valid_name_char( _ch ) ( 1 ) + +#define IMFS_is_separator( _ch ) \ + rtems_filesystem_is_separator( _ch ) + +/* + * Data types + */ + +struct IMFS_jnode_tt; +typedef struct IMFS_jnode_tt IMFS_jnode_t; + +typedef struct { + Chain_Control Entries; + rtems_filesystem_mount_table_entry_t *mt_fs; +} IMFS_directory_t; + +typedef struct { + rtems_device_major_number major; + rtems_device_minor_number minor; +} IMFS_device_t; + +typedef struct { + IMFS_jnode_t *link_node; +} IMFS_link_t; + +typedef struct { + const char *name; +} IMFS_sym_link_t; + +/* + * IMFS "memfile" information + * + * The data structure for the in-memory "memfiles" is based on classic UNIX. + * + * block_ptr is a pointer to a block of IMFS_MEMFILE_BYTES_PER_BLOCK in + * length which could be data or a table of pointers to blocks. + * + * Setting IMFS_MEMFILE_BYTES_PER_BLOCK to different values has a significant + * impact on the maximum file size supported as well as the amount of + * memory wasted due to internal file fragmentation. The following + * is a list of maximum file sizes based on various settings + * + * max_filesize with blocks of 16 is 1,328 + * max_filesize with blocks of 32 is 18,656 + * max_filesize with blocks of 64 is 279,488 + * max_filesize with blocks of 128 is 4,329,344 + * max_filesize with blocks of 256 is 68,173,568 + * max_filesize with blocks of 512 is 1,082,195,456 + */ + +#define IMFS_MEMFILE_BYTES_PER_BLOCK 128 +#define IMFS_MEMFILE_BLOCK_SLOTS \ + (IMFS_MEMFILE_BYTES_PER_BLOCK / sizeof(void *)) + +typedef unsigned char * block_p; +typedef block_p *block_ptr; + +typedef struct { + off_t size; /* size of file in bytes */ + block_ptr indirect; /* array of 128 data blocks pointers */ + block_ptr doubly_indirect; /* 128 indirect blocks */ + block_ptr triply_indirect; /* 128 doubly indirect blocks */ +} IMFS_memfile_t; + +typedef struct { + off_t size; /* size of file in bytes */ + block_p direct; /* pointer to file image */ +} IMFS_linearfile_t; + +/* + * Important block numbers for "memfiles" + */ + +#define FIRST_INDIRECT (0) +#define LAST_INDIRECT (IMFS_MEMFILE_BLOCK_SLOTS - 1) + +#define FIRST_DOUBLY_INDIRECT (LAST_INDIRECT + 1) +#define LAST_DOUBLY_INDIRECT \ + (LAST_INDIRECT + \ + (IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) + +#define FIRST_TRIPLY_INDIRECT (LAST_DOUBLY_INDIRECT + 1) +#define LAST_TRIPLY_INDIRECT \ + (LAST_DOUBLY_INDIRECT +\ + (IMFS_MEMFILE_BLOCK_SLOTS * \ + IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) + +#define IMFS_MEMFILE_MAXIMUM_SIZE \ + (LAST_TRIPLY_INDIRECT * IMFS_MEMFILE_BYTES_PER_BLOCK) + +/* + * What types of IMFS file systems entities there can be. + */ + +#define IMFS_jnode_types_t rtems_filesystem_node_types_t +#define IMFS_DIRECTORY RTEMS_FILESYSTEM_DIRECTORY +#define IMFS_DEVICE RTEMS_FILESYSTEM_DEVICE +#define IMFS_HARD_LINK RTEMS_FILESYSTEM_HARD_LINK +#define IMFS_SYM_LINK RTEMS_FILESYSTEM_SYM_LINK +#define IMFS_MEMORY_FILE RTEMS_FILESYSTEM_MEMORY_FILE +#define IMFS_LINEAR_FILE (IMFS_MEMORY_FILE + 1) + +#define IMFS_NUMBER_OF_TYPES (IMFS_LINEAR_FILE + 1) + +typedef union { + IMFS_directory_t directory; + IMFS_device_t device; + IMFS_link_t hard_link; + IMFS_sym_link_t sym_link; + IMFS_memfile_t file; + IMFS_linearfile_t linearfile; +} IMFS_types_union; + +/* + * Maximum length of a "basename" of an IMFS file/node. + */ + +#define IMFS_NAME_MAX 32 + +/* + * The control structure for an IMFS jnode. + */ + +struct IMFS_jnode_tt { + Chain_Node Node; /* for chaining them together */ + IMFS_jnode_t *Parent; /* Parent node */ + char name[IMFS_NAME_MAX+1]; /* "basename" */ + mode_t st_mode; /* File mode */ + nlink_t st_nlink; /* Link count */ + ino_t st_ino; /* inode */ + + uid_t st_uid; /* User ID of owner */ + gid_t st_gid; /* Group ID of owner */ + + time_t stat_atime; /* Time of last access */ + time_t stat_mtime; /* Time of last modification */ + time_t stat_ctime; /* Time of last status change */ + IMFS_jnode_types_t type; /* Type of this entry */ + IMFS_types_union info; +}; + +#define IMFS_update_atime( _jnode ) \ + do { \ + struct timeval tv; \ + gettimeofday( &tv, 0 ); \ + _jnode->stat_atime = (time_t) tv.tv_sec; \ + } while (0) + +#define IMFS_update_mtime( _jnode ) \ + do { \ + struct timeval tv; \ + gettimeofday( &tv, 0 ); \ + _jnode->stat_mtime = (time_t) tv.tv_sec; \ + } while (0) + +#define IMFS_update_ctime( _jnode ) \ + do { \ + struct timeval tv; \ + gettimeofday( &tv, 0 ); \ + _jnode->stat_ctime = (time_t) tv.tv_sec; \ + } while (0) + +#define IMFS_atime_mtime_update( _jnode ) \ + do { \ + struct timeval tv; \ + gettimeofday( &tv, 0 ); \ + _jnode->stat_mtime = (time_t) tv.tv_sec; \ + _jnode->stat_atime = (time_t) tv.tv_sec; \ + } while (0) + +typedef struct { + ino_t ino_count; + rtems_filesystem_file_handlers_r *linearfile_handlers; + rtems_filesystem_file_handlers_r *memfile_handlers; + rtems_filesystem_file_handlers_r *directory_handlers; +} IMFS_fs_info_t; + +#if UNUSED +/* FIXME: Unused, we might want to remove it */ +#define increment_and_check_linkcounts( _fs_info ) \ + ((IMFS_fs_info_t * )_fs_info)->link_counts++; \ + if ( ((IMFS_fs_info_t * )_fs_info)->link_counts > MAXSYMLINKS ) \ + rtems_set_errno_and_return_minus_one( ELOOP ) +#endif + +#define decrement_linkcounts( _fs_info ) \ + ((IMFS_fs_info_t * )_fs_info)->link_counts--; + +/* + * Type defination for tokens returned from IMFS_get_token + */ + +typedef enum { + IMFS_NO_MORE_PATH, + IMFS_CURRENT_DIR, + IMFS_UP_DIR, + IMFS_NAME, + IMFS_INVALID_TOKEN +} IMFS_token_types; + +/* + * Shared Data + */ + +extern rtems_filesystem_file_handlers_r IMFS_directory_handlers; +extern rtems_filesystem_file_handlers_r IMFS_device_handlers; +extern rtems_filesystem_file_handlers_r IMFS_link_handlers; +extern rtems_filesystem_file_handlers_r IMFS_linearfile_handlers; +extern rtems_filesystem_file_handlers_r IMFS_memfile_handlers; +extern rtems_filesystem_operations_table IMFS_ops; +extern rtems_filesystem_operations_table miniIMFS_ops; +extern rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS; + +/* + * Routines + */ + +int IMFS_initialize( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +int miniIMFS_initialize( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +int IMFS_initialize_support( + rtems_filesystem_mount_table_entry_t *mt_entry, + rtems_filesystem_operations_table *op_table, + rtems_filesystem_file_handlers_r *linearfile_handlers, + rtems_filesystem_file_handlers_r *memfile_handlers, + rtems_filesystem_file_handlers_r *directory_handlers +); + +int IMFS_fsunmount( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +int rtems_tarfs_load( + char *mountpoint, + unsigned char *addr, + unsigned long length +); + +/* + * Returns the number of characters copied from path to token. + */ +IMFS_token_types IMFS_get_token( + const char *path, + char *token, + int *token_len +); + +void IMFS_dump( void ); + +void IMFS_initialize_jnode( + IMFS_jnode_t *the_jnode, + IMFS_jnode_types_t type, + IMFS_jnode_t *the_parent, + char *name, + mode_t mode +); + +IMFS_jnode_t *IMFS_find_match_in_dir( + IMFS_jnode_t *directory, /* IN */ + char *name /* IN */ +); + +rtems_filesystem_node_types_t IMFS_node_type( + rtems_filesystem_location_info_t *pathloc /* IN */ +); + +int IMFS_stat( + rtems_filesystem_location_info_t *loc, /* IN */ + struct stat *buf /* OUT */ +); + +int IMFS_Set_handlers( + rtems_filesystem_location_info_t *loc +); + +int IMFS_evaluate_link( + rtems_filesystem_location_info_t *node, /* IN/OUT */ + int flags /* IN */ +); + +int IMFS_eval_path( + const char *pathname, /* IN */ + int flags, /* IN */ + rtems_filesystem_location_info_t *pathloc /* IN/OUT */ +); + + +int IMFS_link( + rtems_filesystem_location_info_t *to_loc, /* IN */ + rtems_filesystem_location_info_t *parent_loc, /* IN */ + const char *token /* IN */ +); + +int IMFS_unlink( + rtems_filesystem_location_info_t *pathloc /* IN */ +); + +int IMFS_chown( + rtems_filesystem_location_info_t *pathloc, /* IN */ + uid_t owner, /* IN */ + gid_t group /* IN */ +); + +int IMFS_freenodinfo( + rtems_filesystem_location_info_t *pathloc /* IN */ +); + +int IMFS_mknod( + const char *path, /* IN */ + mode_t mode, /* IN */ + dev_t dev, /* IN */ + rtems_filesystem_location_info_t *pathloc /* IN/OUT */ +); + +IMFS_jnode_t *IMFS_create_node( + rtems_filesystem_location_info_t *parent_loc, /* IN */ + IMFS_jnode_types_t type, /* IN */ + char *name, /* IN */ + mode_t mode, /* IN */ + IMFS_types_union *info /* IN */ +); + +int IMFS_evaluate_for_make( + const char *path, /* IN */ + rtems_filesystem_location_info_t *pathloc, /* IN/OUT */ + const char **name /* OUT */ +); + +int IMFS_mount( + rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ +); + +int IMFS_unmount( + rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ +); + +int IMFS_freenod( + rtems_filesystem_location_info_t *node /* IN/OUT */ +); + +int IMFS_memfile_remove( + IMFS_jnode_t *the_jnode /* IN/OUT */ +); + +int memfile_ftruncate( + rtems_libio_t *iop, /* IN */ + off_t length /* IN */ +); + +int imfs_dir_open( + rtems_libio_t *iop, /* IN */ + const char *pathname, /* IN */ + unsigned32 flag, /* IN */ + unsigned32 mode /* IN */ +); + +int imfs_dir_close( + rtems_libio_t *iop /* IN */ +); + +int imfs_dir_read( + rtems_libio_t *iop, /* IN */ + void *buffer, /* IN */ + unsigned32 count /* IN */ +); + +int imfs_dir_lseek( + rtems_libio_t *iop, /* IN */ + off_t offset, /* IN */ + int whence /* IN */ +); + +int imfs_dir_fstat( + rtems_filesystem_location_info_t *loc, /* IN */ + struct stat *buf /* OUT */ +); + +int imfs_dir_rmnod( + rtems_filesystem_location_info_t *pathloc /* IN */ +); + +int linearfile_read( + rtems_libio_t *iop, /* IN */ + void *buffer, /* IN */ + unsigned32 count /* IN */ +); + +int linearfile_lseek( + rtems_libio_t *iop, /* IN */ + off_t offset, /* IN */ + int whence /* IN */ +); + +int memfile_open( + rtems_libio_t *iop, /* IN */ + const char *pathname, /* IN */ + unsigned32 flag, /* IN */ + unsigned32 mode /* IN */ +); + +int memfile_close( + rtems_libio_t *iop /* IN */ +); + +int memfile_read( + rtems_libio_t *iop, /* IN */ + void *buffer, /* IN */ + unsigned32 count /* IN */ +); + +int memfile_write( + rtems_libio_t *iop, /* IN */ + const void *buffer, /* IN */ + unsigned32 count /* IN */ +); + +int memfile_ioctl( + rtems_libio_t *iop, /* IN */ + unsigned32 command, /* IN */ + void *buffer /* IN */ +); + +int memfile_lseek( + rtems_libio_t *iop, /* IN */ + off_t offset, /* IN */ + int whence /* IN */ +); + +int memfile_rmnod( + rtems_filesystem_location_info_t *pathloc /* IN */ +); + +int device_open( + rtems_libio_t *iop, /* IN */ + const char *pathname, /* IN */ + unsigned32 flag, /* IN */ + unsigned32 mode /* IN */ +); + +int device_close( + rtems_libio_t *iop /* IN */ +); + +int device_read( + rtems_libio_t *iop, /* IN */ + void *buffer, /* IN */ + unsigned32 count /* IN */ +); + +int device_write( + rtems_libio_t *iop, /* IN */ + const void *buffer, /* IN */ + unsigned32 count /* IN */ +); + +int device_ioctl( + rtems_libio_t *iop, /* IN */ + unsigned32 command, /* IN */ + void *buffer /* IN */ +); + +int device_lseek( + rtems_libio_t *iop, /* IN */ + off_t offset, /* IN */ + int whence /* IN */ +); + +int IMFS_utime( + rtems_filesystem_location_info_t *pathloc, /* IN */ + time_t actime, /* IN */ + time_t modtime /* IN */ +); + +int IMFS_fchmod( + rtems_filesystem_location_info_t *loc, + mode_t mode +); + +int IMFS_symlink( + rtems_filesystem_location_info_t *parent_loc, /* IN */ + const char *link_name, + const char *node_name +); + +int IMFS_readlink( + rtems_filesystem_location_info_t *loc, /* IN */ + char *buf, /* OUT */ + size_t bufsize +); + +int IMFS_fdatasync( + rtems_libio_t *iop +); + +int IMFS_fcntl( + int cmd, + rtems_libio_t *iop +); + +int IMFS_rmnod( + rtems_filesystem_location_info_t *pathloc /* IN */ +); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ Index: src/imfs/ioman.c =================================================================== --- src/imfs/ioman.c (nonexistent) +++ src/imfs/ioman.c (revision 1765) @@ -0,0 +1,110 @@ +/* + * This file emulates the old Classic RTEMS IO manager directives + * which register and lookup names using the in-memory filesystem. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * ioman.c,v 1.11 2002/04/08 18:28:59 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include "imfs.h" + +#if defined(__linux__) +#define S_IFCHR __S_IFCHR +#endif + +/* + * rtems_io_register_name + * + * This assumes that all registered devices are character devices. + */ + +rtems_status_code rtems_io_register_name( + char *device_name, + rtems_device_major_number major, + rtems_device_minor_number minor +) +{ +#if !defined(RTEMS_UNIX) + int status; + dev_t dev; + + dev = rtems_filesystem_make_dev_t( major, minor ); + status = mknod( device_name, 0777 | S_IFCHR, dev ); + + /* this is the only error returned by the old version */ + if ( status ) + return RTEMS_TOO_MANY; + +#endif + return RTEMS_SUCCESSFUL; +} + +/* + * rtems_io_lookup_name + * + * This version is not reentrant. + * + * XXX - This is dependent upon IMFS and should not be. + * Suggest adding a filesystem routine to fill in the device_info. + */ + +rtems_status_code rtems_io_lookup_name( + const char *name, + rtems_driver_name_t **device_info +) +{ +#if !defined(RTEMS_UNIX) + IMFS_jnode_t *the_jnode; + rtems_filesystem_location_info_t loc; + static rtems_driver_name_t device; + int result; + rtems_filesystem_node_types_t node_type; + + result = rtems_filesystem_evaluate_path( name, 0x00, &loc, TRUE ); + the_jnode = loc.node_access; + + if ( !loc.ops->node_type_h ) { + rtems_filesystem_freenode( &loc ); + rtems_set_errno_and_return_minus_one( ENOTSUP ); + } + + node_type = (*loc.ops->node_type_h)( &loc ); + + if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) { + *device_info = 0; + rtems_filesystem_freenode( &loc ); + return RTEMS_UNSATISFIED; + } + + device.device_name = (char *) name; + device.device_name_length = strlen( name ); + device.major = the_jnode->info.device.major; + device.minor = the_jnode->info.device.minor; + *device_info = &device; + + rtems_filesystem_freenode( &loc ); + +#endif + return RTEMS_SUCCESSFUL; +} Index: src/imfs/imfs_debug.c =================================================================== --- src/imfs/imfs_debug.c (nonexistent) +++ src/imfs/imfs_debug.c (revision 1765) @@ -0,0 +1,176 @@ +/* + * IMFS debug support routines + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_debug.c,v 1.8 2001/04/20 13:27:24 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include /* for close */ + +#include +#include + +#include "imfs.h" +#include + +/* + * IMFS_types + * + * Printable names for each of the IMFS file system types. + */ + +char *IMFS_types[ IMFS_NUMBER_OF_TYPES ] = { + "directory", + "device", + "link", + "memory file", + "linear file" +}; + +/* + * IMFS_print_jnode + * + * This routine prints the contents of the specified jnode. + */ + +void IMFS_print_jnode( + IMFS_jnode_t *the_jnode +) +{ + assert( the_jnode ); + + printf( "%s", the_jnode->name ); + switch( the_jnode->type ) { + case IMFS_DIRECTORY: + printf( "/" ); + break; + + case IMFS_DEVICE: + printf( " (device %d, %d)", + the_jnode->info.device.major, the_jnode->info.device.minor ); + break; + + case IMFS_LINEAR_FILE: + printf( " (file %d %p)", + (int)the_jnode->info.linearfile.size, + the_jnode->info.linearfile.direct + ); + break; + + case IMFS_MEMORY_FILE: + /* Useful when debugging .. varies between targets */ +#if 0 + printf( " (file %d %p %p %p)", + (int)the_jnode->info.file.size, + the_jnode->info.file.indirect, + the_jnode->info.file.doubly_indirect, + the_jnode->info.file.triply_indirect + ); +#else + printf( " (file %d)", (int)the_jnode->info.file.size ); +#endif + break; + + case IMFS_HARD_LINK: + printf( " links not printed\n" ); + assert(0); + break; + + case IMFS_SYM_LINK: + printf( " links not printed\n" ); + assert(0); + break; + + default: + printf( " bad type %d\n", the_jnode->type ); + assert(0); + break; + } + puts(""); +} + +/* + * IMFS_dump_directory + * + * This routine prints the contents of a directory in the IMFS. If a + * directory is encountered, then this routine will recurse to process + * the subdirectory. + */ + +void IMFS_dump_directory( + IMFS_jnode_t *the_directory, + int level +) +{ + Chain_Node *the_node; + Chain_Control *the_chain; + IMFS_jnode_t *the_jnode; + int i; + + assert( the_directory ); + + assert( level >= 0 ); + + assert( the_directory->type == IMFS_DIRECTORY ); + + the_chain = &the_directory->info.directory.Entries; + + for ( the_node = the_chain->first; + !_Chain_Is_tail( the_chain, the_node ); + the_node = the_node->next ) { + + the_jnode = (IMFS_jnode_t *) the_node; + + for ( i=0 ; i<=level ; i++ ) + printf( "...." ); + IMFS_print_jnode( the_jnode ); + if ( the_jnode->type == IMFS_DIRECTORY ) + IMFS_dump_directory( the_jnode, level + 1 ); + } +} + +/* + * IMFS_dump + * + * This routine dumps the entire IMFS that is mounted at the root + * directory. + * + * NOTE: Assuming the "/" directory is bad. + * Not checking that the starting directory is in an IMFS is bad. + */ + +void IMFS_dump( void ) +{ + printf( "*************** Dump of Entire IMFS ***************\n" ); + printf( "/\n" ); + IMFS_dump_directory( rtems_filesystem_root.node_access, 0 ); + printf( "*************** End of Dump ***************\n" ); +} + +/* + * IMFS_memfile_maximum_size() + * + * This routine returns the size of the largest file which can be created + * using the IMFS memory file type. + * + */ + +int IMFS_memfile_maximum_size( void ) +{ + return IMFS_MEMFILE_MAXIMUM_SIZE; +} Index: src/imfs/imfs_handlers_memfile.c =================================================================== --- src/imfs/imfs_handlers_memfile.c (nonexistent) +++ src/imfs/imfs_handlers_memfile.c (revision 1765) @@ -0,0 +1,58 @@ +/* + * Memfile Operations Tables for the IMFS + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_handlers_memfile.c,v 1.8 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "imfs.h" + +/* + * Set of operations handlers for operations on memfile entities. + */ + +rtems_filesystem_file_handlers_r IMFS_linearfile_handlers = { + memfile_open, + memfile_close, + memfile_read, + NULL, /* write */ + memfile_ioctl, + memfile_lseek, + IMFS_stat, + IMFS_fchmod, + NULL, /* ftruncate */ + NULL, /* fpathconf */ + IMFS_fdatasync, /* fsync */ + IMFS_fdatasync, + IMFS_fcntl, + memfile_rmnod +}; + +rtems_filesystem_file_handlers_r IMFS_memfile_handlers = { + memfile_open, + memfile_close, + memfile_read, + memfile_write, + memfile_ioctl, + memfile_lseek, + IMFS_stat, + IMFS_fchmod, + memfile_ftruncate, + NULL, /* fpathconf */ + IMFS_fdatasync, /* fsync */ + IMFS_fdatasync, + IMFS_fcntl, + memfile_rmnod +}; Index: src/imfs/imfs_fchmod.c =================================================================== --- src/imfs/imfs_fchmod.c (nonexistent) +++ src/imfs/imfs_fchmod.c (revision 1765) @@ -0,0 +1,78 @@ +/* + * IMFS file change mode routine. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_fchmod.c,v 1.7 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include "imfs.h" + +int IMFS_fchmod( + rtems_filesystem_location_info_t *loc, + mode_t mode +) +{ + IMFS_jnode_t *jnode; +#if defined(RTEMS_POSIX_API) + uid_t st_uid; +#endif + + jnode = loc->node_access; + + /* + * Verify I am the owner of the node or the super user. + */ +#if defined(RTEMS_POSIX_API) + st_uid = geteuid(); + + if ( ( st_uid != jnode->st_uid ) && ( st_uid != 0 ) ) + rtems_set_errno_and_return_minus_one( EPERM ); +#endif + + /* + * Change only the RWX permissions on the jnode to mode. + */ + if ( mode & (~ (S_IRWXU | S_IRWXG | S_IRWXO ) ) ) + rtems_set_errno_and_return_minus_one( EPERM ); + + /* + * If we make a linear-file writeable, construct a block file + * from it first. + */ + if ( (jnode->type == IMFS_LINEAR_FILE) && + (mode & (S_IWUSR | S_IWGRP | S_IWOTH)) ) + { + unsigned32 count = jnode->info.linearfile.size; + const unsigned char *buffer = jnode->info.linearfile.direct; + + jnode->type = IMFS_MEMORY_FILE; + jnode->info.file.size = 0; + jnode->info.file.indirect = 0; + jnode->info.file.doubly_indirect = 0; + jnode->info.file.triply_indirect = 0; + if (IMFS_memfile_write(jnode, 0, buffer, count) == -1) + return(-1); + } + + jnode->st_mode &= ~(S_IRWXU | S_IRWXG | S_IRWXO); + jnode->st_mode |= mode; + + IMFS_update_ctime( jnode ); + + return 0; +} + Index: src/imfs/imfs_mount.c =================================================================== --- src/imfs/imfs_mount.c (nonexistent) +++ src/imfs/imfs_mount.c (revision 1765) @@ -0,0 +1,53 @@ +/* + * IMFS_mount + * + * This routine will look at a mount table entry that we are going to + * add to the mount table. If the mount point rtems_filesystem + * location_info_t struct refers to a node that is a directory, + * the node will be marked as a mount point by setting its directory.mt_fs + * pointer to point to the mount table entry that we are about to add + * to the mount table chain. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_mount.c,v 1.5 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "imfs.h" +#include +#include + +int IMFS_mount( + rtems_filesystem_mount_table_entry_t *mt_entry +) +{ + IMFS_jnode_t *node; + + node = mt_entry->mt_point_node.node_access; + + /* + * Is the node that we are mounting onto a directory node ? + */ + + if ( node->type != IMFS_DIRECTORY ) + rtems_set_errno_and_return_minus_one( ENOTDIR ); + + /* + * Set mt_fs pointer to point to the mount table entry for + * the mounted file system. + */ + + node->info.directory.mt_fs = mt_entry; + return 0; +} Index: src/imfs/imfs_directory.c =================================================================== --- src/imfs/imfs_directory.c (nonexistent) +++ src/imfs/imfs_directory.c (revision 1765) @@ -0,0 +1,353 @@ +/* + * IMFS Directory Access Routines + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_directory.c,v 1.13 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "imfs.h" +#include +#include + +/* + * imfs_dir_open + * + * This rountine will verify that the node being opened as a directory is + * in fact a directory node. If it is then the offset into the directory + * will be set to 0 to position to the first directory entry. + */ + +int imfs_dir_open( + rtems_libio_t *iop, + const char *pathname, + unsigned32 flag, + unsigned32 mode +) +{ + IMFS_jnode_t *the_jnode; + + /* Is the node a directory ? */ + the_jnode = (IMFS_jnode_t *) iop->file_info; + + if ( the_jnode->type != IMFS_DIRECTORY ) + return -1; /* It wasn't a directory --> return error */ + + iop->offset = 0; + return 0; +} + +/* + * imfs_dir_read + * + * This routine will read the next directory entry based on the directory + * offset. The offset should be equal to -n- time the size of an individual + * dirent structure. If n is not an integer multiple of the sizeof a + * dirent structure, an integer division will be performed to determine + * directory entry that will be returned in the buffer. Count should reflect + * -m- times the sizeof dirent bytes to be placed in the buffer. + * If there are not -m- dirent elements from the current directory position + * to the end of the exisiting file, the remaining entries will be placed in + * the buffer and the returned value will be equal to -m actual- times the + * size of a directory entry. + */ + +int imfs_dir_read( + rtems_libio_t *iop, + void *buffer, + unsigned32 count +) +{ + /* + * Read up to element iop->offset in the directory chain of the + * imfs_jnode_t struct for this file descriptor. + */ + Chain_Node *the_node; + Chain_Control *the_chain; + IMFS_jnode_t *the_jnode; + int bytes_transferred; + int current_entry; + int first_entry; + int last_entry; + struct dirent tmp_dirent; + + the_jnode = (IMFS_jnode_t *)iop->file_info; + the_chain = &the_jnode->info.directory.Entries; + + if ( Chain_Is_empty( the_chain ) ) + return 0; + + /* Move to the first of the desired directory entries */ + the_node = the_chain->first; + + bytes_transferred = 0; + first_entry = iop->offset; + /* protect against using sizes that are not exact multiples of the */ + /* -dirent- size. These could result in unexpected results */ + last_entry = first_entry + (count/sizeof(struct dirent)) * sizeof(struct dirent); + + /* The directory was not empty so try to move to the desired entry in chain*/ + for ( + current_entry = 0; + current_entry < last_entry; + current_entry = current_entry + sizeof(struct dirent) ){ + + if ( Chain_Is_tail( the_chain, the_node ) ){ + /* We hit the tail of the chain while trying to move to the first */ + /* entry in the read */ + return bytes_transferred; /* Indicate that there are no more */ + /* entries to return */ + } + + if( current_entry >= first_entry ) { + /* Move the entry to the return buffer */ + tmp_dirent.d_off = current_entry; + tmp_dirent.d_reclen = sizeof( struct dirent ); + the_jnode = (IMFS_jnode_t *) the_node; + tmp_dirent.d_ino = the_jnode->st_ino; + tmp_dirent.d_namlen = strlen( the_jnode->name ); + strcpy( tmp_dirent.d_name, the_jnode->name ); + memcpy( + buffer + bytes_transferred, + (void *)&tmp_dirent, + sizeof( struct dirent ) + ); + iop->offset = iop->offset + sizeof(struct dirent); + bytes_transferred = bytes_transferred + sizeof( struct dirent ); + } + + the_node = the_node->next; + } + + /* Success */ + return bytes_transferred; +} + + + +/* + * imfs_dir_close + * + * This routine will be called by the generic close routine to cleanup any + * resources that have been allocated for the management of the file + */ + +int imfs_dir_close( + rtems_libio_t *iop +) +{ + /* + * The generic close routine handles the deallocation of the file control + * and associated memory. At present the imfs_dir_close simply + * returns a successful completion status. + */ + + return 0; +} + + + +/* + * imfs_dir_lseek + * + * This routine will behave in one of three ways based on the state of + * argument whence. Based on the state of its value the offset argument will + * be interpreted using one of the following methods: + * + * SEEK_SET - offset is the absolute byte offset from the start of the + * logical start of the dirent sequence that represents the + * directory + * SEEK_CUR - offset is used as the relative byte offset from the current + * directory position index held in the iop structure + * SEEK_END - N/A --> This will cause an assert. + */ + +int imfs_dir_lseek( + rtems_libio_t *iop, + off_t offset, + int whence +) +{ + switch( whence ) { + case SEEK_SET: /* absolute move from the start of the file */ + case SEEK_CUR: /* relative move */ + iop->offset = (iop->offset/sizeof(struct dirent)) * + sizeof(struct dirent); + break; + + case SEEK_END: /* Movement past the end of the directory via lseek */ + /* is not a permitted operation */ + default: + rtems_set_errno_and_return_minus_one( EINVAL ); + break; + } + + return 0; +} + + + +/* + * imfs_dir_fstat + * + * This routine will obtain the following information concerning the current + * directory: + * st_dev 0ll + * st_ino 1 + * st_mode mode extracted from the jnode + * st_nlink number of links to this node + * st_uid uid extracted from the jnode + * st_gid gid extracted from the jnode + * st_rdev 0ll + * st_size the number of bytes in the directory + * This is calculated by taking the number of entries + * in the directory and multiplying by the size of a + * dirent structure + * st_blksize 0 + * st_blocks 0 + * stat_atime time of last access + * stat_mtime time of last modification + * stat_ctime time of the last change + * + * This information will be returned to the calling function in a -stat- struct + * + */ + +int imfs_dir_fstat( + rtems_filesystem_location_info_t *loc, + struct stat *buf +) +{ + Chain_Node *the_node; + Chain_Control *the_chain; + IMFS_jnode_t *the_jnode; + + + the_jnode = (IMFS_jnode_t *) loc->node_access; + + buf->st_dev = 0ll; + buf->st_ino = the_jnode->st_ino; + buf->st_mode = the_jnode->st_mode; + buf->st_nlink = the_jnode->st_nlink; + buf->st_uid = the_jnode->st_uid; + buf->st_gid = the_jnode->st_gid; + buf->st_rdev = 0ll; + buf->st_blksize = 0; + buf->st_blocks = 0; + buf->st_atime = the_jnode->stat_atime; + buf->st_mtime = the_jnode->stat_mtime; + buf->st_ctime = the_jnode->stat_ctime; + + buf->st_size = 0; + + the_chain = &the_jnode->info.directory.Entries; + + /* Run through the chain and count the number of directory entries */ + /* that are subordinate to this directory node */ + for ( the_node = the_chain->first ; + !_Chain_Is_tail( the_chain, the_node ) ; + the_node = the_node->next ) { + + buf->st_size = buf->st_size + sizeof( struct dirent ); + } + + return 0; +} + +/* + * IMFS_dir_rmnod + * + * This routine is available from the optable to remove a node + * from the IMFS file system. + */ + +int imfs_dir_rmnod( + rtems_filesystem_location_info_t *pathloc /* IN */ +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = (IMFS_jnode_t *) pathloc->node_access; + + /* + * You cannot remove a node that still has children + */ + + if ( ! Chain_Is_empty( &the_jnode->info.directory.Entries ) ) + rtems_set_errno_and_return_minus_one( ENOTEMPTY ); + + /* + * You cannot remove the file system root node. + */ + + if ( pathloc->mt_entry->mt_fs_root.node_access == pathloc->node_access ) + rtems_set_errno_and_return_minus_one( EBUSY ); + + /* + * You cannot remove a mountpoint. + */ + + if ( the_jnode->info.directory.mt_fs != NULL ) + rtems_set_errno_and_return_minus_one( EBUSY ); + + /* + * Take the node out of the parent's chain that contains this node + */ + + if ( the_jnode->Parent != NULL ) { + Chain_Extract( (Chain_Node *) the_jnode ); + the_jnode->Parent = NULL; + } + + /* + * Decrement the link counter and see if we can free the space. + */ + + the_jnode->st_nlink--; + IMFS_update_ctime( the_jnode ); + + /* + * The file cannot be open and the link must be less than 1 to free. + */ + + if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) { + + /* + * Is the rtems_filesystem_current is this node? + */ + + if ( rtems_filesystem_current.node_access == pathloc->node_access ) + rtems_filesystem_current.node_access = NULL; + + /* + * Free memory associated with a memory file. + */ + + free( the_jnode ); + } + + return 0; + +} + + Index: src/imfs/imfs_mknod.c =================================================================== --- src/imfs/imfs_mknod.c (nonexistent) +++ src/imfs/imfs_mknod.c (revision 1765) @@ -0,0 +1,78 @@ +/* + * IMFS_mknod + * + * Routine to create a node in the IMFS file system. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_mknod.c,v 1.7 2002/01/04 18:30:58 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include + +#include "imfs.h" +#include +#include + +int IMFS_mknod( + const char *token, /* IN */ + mode_t mode, /* IN */ + dev_t dev, /* IN */ + rtems_filesystem_location_info_t *pathloc /* IN/OUT */ +) +{ + IMFS_token_types type = 0; + IMFS_jnode_t *new_node; + int result; + char new_name[ IMFS_NAME_MAX + 1 ]; + IMFS_types_union info; + + IMFS_get_token( token, new_name, &result ); + + /* + * Figure out what type of IMFS node this is. + */ + + if ( S_ISDIR(mode) ) + type = IMFS_DIRECTORY; + else if ( S_ISREG(mode) ) + type = IMFS_MEMORY_FILE; + else if ( S_ISBLK(mode) || S_ISCHR(mode) ) { + type = IMFS_DEVICE; + rtems_filesystem_split_dev_t( dev, info.device.major, info.device.minor ); + } else { + rtems_set_errno_and_return_minus_one( EINVAL ); + } + + /* + * Allocate and fill in an IMFS jnode + */ + + new_node = IMFS_create_node( + pathloc, + type, + new_name, + mode, + &info + ); + + if ( !new_node ) + rtems_set_errno_and_return_minus_one( ENOMEM ); + + return 0; +} + Index: src/imfs/Makefile.am =================================================================== --- src/imfs/Makefile.am (nonexistent) +++ src/imfs/Makefile.am (revision 1765) @@ -0,0 +1,62 @@ +## +## Makefile.am,v 1.15 2002/07/22 13:44:42 ralf Exp +## + +LIB = ${ARCH}/libimfs.a + +IMFS_C_FILES = imfs_chown.c imfs_config.c imfs_creat.c imfs_directory.c \ + imfs_eval.c imfs_free.c imfs_fsunmount.c imfs_gtkn.c imfs_init.c \ + imfs_initsupp.c imfs_link.c imfs_mknod.c imfs_mount.c imfs_fchmod.c \ + imfs_unlink.c imfs_unmount.c imfs_utime.c imfs_ntype.c imfs_stat.c \ + imfs_getchild.c memfile.c linearfile.c deviceio.c imfs_handlers_device.c \ + imfs_handlers_directory.c imfs_handlers_link.c imfs_handlers_memfile.c \ + imfs_debug.c imfs_rmnod.c imfs_symlink.c imfs_readlink.c imfs_fdatasync.c \ + imfs_fcntl.c ioman.c miniimfs_init.c imfs_load_tar.c + +UNIX_C_FILES = imfs_unixstub.c + +EMBEDDED_C_FILES = $(IMFS_C_FILES) + +COMMON_C_FILES = + +if UNIX +C_FILES = $(COMMON_C_FILES) $(UNIX_C_FILES) +else +C_FILES = $(COMMON_C_FILES) $(EMBEDDED_C_FILES) +endif +C_O_FILES = $(C_FILES:%.c=${ARCH}/%.$(OBJEXT)) + +include_HEADERS = imfs.h + +include $(top_srcdir)/../automake/multilib.am +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/lib.am + +AM_CPPFLAGS += -I../.. $(LIBC_DEFINES) + +PREINSTALL_FILES = $(PROJECT_INCLUDE) \ + $(include_HEADERS:%=$(PROJECT_INCLUDE)/%) + +$(PROJECT_INCLUDE): + @$(mkinstalldirs) $@ + +$(PROJECT_INCLUDE)/%.h: %.h + $(INSTALL_DATA) $< $@ + +OBJS = $(C_O_FILES) + +# +# Add local stuff here using += +# + +all-local: ${ARCH} $(LIB) + +$(LIB): ${OBJS} + $(make-library) + +DOC_FILES = TODO CASES + +EXTRA_DIST = $(DOC_FILES) $(COMMON_C_FILES) $(EMBEDDED_C_FILES) \ + $(UNIX_C_FILES) + +include $(top_srcdir)/../automake/local.am Index: src/imfs/imfs_initsupp.c =================================================================== --- src/imfs/imfs_initsupp.c (nonexistent) +++ src/imfs/imfs_initsupp.c (revision 1765) @@ -0,0 +1,88 @@ +/* + * IMFS Initialization + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_initsupp.c,v 1.12 2001/05/25 13:47:47 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include /* for mkdir */ +#include +#include +#include + +#include + +#include "imfs.h" +#include + +#if defined(IMFS_DEBUG) +#include +#endif + +/* + * IMFS_initialize + */ + +int IMFS_initialize_support( + rtems_filesystem_mount_table_entry_t *temp_mt_entry, + rtems_filesystem_operations_table *op_table, + rtems_filesystem_file_handlers_r *linearfile_handlers, + rtems_filesystem_file_handlers_r *memfile_handlers, + rtems_filesystem_file_handlers_r *directory_handlers +) +{ + IMFS_fs_info_t *fs_info; + IMFS_jnode_t *jnode; + + /* + * Create the root node + * + * NOTE: UNIX root is 755 and owned by root/root (0/0). + */ + + temp_mt_entry->mt_fs_root.node_access = IMFS_create_node( + NULL, + IMFS_DIRECTORY, + "", + ( S_IFDIR | 0755 ), + NULL + ); + + temp_mt_entry->mt_fs_root.handlers = directory_handlers; + temp_mt_entry->mt_fs_root.ops = op_table; + temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS; + + /* + * Create custom file system data. + */ + fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) ); + if ( !fs_info ){ + free(temp_mt_entry->mt_fs_root.node_access); + return 1; + } + temp_mt_entry->fs_info = fs_info; + + /* + * Set st_ino for the root to 1. + */ + + fs_info->ino_count = 1; + fs_info->linearfile_handlers = linearfile_handlers; + fs_info->memfile_handlers = memfile_handlers; + fs_info->directory_handlers = directory_handlers; + + jnode = temp_mt_entry->mt_fs_root.node_access; + jnode->st_ino = fs_info->ino_count; + + return 0; +} Index: src/imfs/imfs_fdatasync.c =================================================================== --- src/imfs/imfs_fdatasync.c (nonexistent) +++ src/imfs/imfs_fdatasync.c (revision 1765) @@ -0,0 +1,29 @@ +/* + * IMFS_fdatasync + * + * The following routine does a sync on an IMFS node. The In Memory + * File System is always in sync, therefore this routine always returns + * pass. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_fdatasync.c,v 1.3 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "imfs.h" + +int IMFS_fdatasync( + rtems_libio_t *iop +) +{ + return 0; +} Index: src/imfs/imfs_rmnod.c =================================================================== --- src/imfs/imfs_rmnod.c (nonexistent) +++ src/imfs/imfs_rmnod.c (revision 1765) @@ -0,0 +1,82 @@ +/* + * IMFS Node Removal Handler + * + * This file contains the handler used to remove a node when a file type + * does not require special actions. + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_rmnod.c,v 1.10 2002/01/08 12:05:36 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include + +#include "imfs.h" + +/* + * IMFS_rmnod + */ + +int IMFS_rmnod( + rtems_filesystem_location_info_t *pathloc /* IN */ +) +{ + IMFS_jnode_t *the_jnode; + + the_jnode = (IMFS_jnode_t *) pathloc->node_access; + + /* + * Take the node out of the parent's chain that contains this node + */ + + if ( the_jnode->Parent != NULL ) { + Chain_Extract( (Chain_Node *) the_jnode ); + the_jnode->Parent = NULL; + } + + /* + * Decrement the link counter and see if we can free the space. + */ + + the_jnode->st_nlink--; + IMFS_update_ctime( the_jnode ); + + /* + * The file cannot be open and the link must be less than 1 to free. + */ + + if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) { + + /* + * Is rtems_filesystem_current this node? + */ + + if ( rtems_filesystem_current.node_access == pathloc->node_access ) + rtems_filesystem_current.node_access = NULL; + + /* + * Free memory associated with a memory file. + */ + + free( the_jnode ); + } + + return 0; + +} + + + Index: src/imfs/imfs_handlers_device.c =================================================================== --- src/imfs/imfs_handlers_device.c (nonexistent) +++ src/imfs/imfs_handlers_device.c (revision 1765) @@ -0,0 +1,41 @@ +/* + * Device Operations Table for the IMFS + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * imfs_handlers_device.c,v 1.6 2001/01/22 14:05:14 joel Exp + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "imfs.h" + +/* + * Handler table for IMFS device nodes + */ + +rtems_filesystem_file_handlers_r IMFS_device_handlers = { + device_open, + device_close, + device_read, + device_write, + device_ioctl, + device_lseek, + IMFS_stat, + IMFS_fchmod, + NULL, /* ftruncate */ + NULL, /* fpathconf */ + NULL, /* fsync */ + NULL, /* fdatasync */ + NULL, /* fcntl */ + IMFS_rmnod +}; Index: src/imfs =================================================================== --- src/imfs (nonexistent) +++ src/imfs (revision 1765)
src/imfs Property changes : Added: svn:ignore ## -0,0 +1,7 ## +Makefile +Makefile.in +config.h +config.h.in +stamp-h +stamp-h.in +stamp-h1.in Index: src/Makefile.in =================================================================== --- src/Makefile.in (nonexistent) +++ src/Makefile.in (revision 1765) @@ -0,0 +1,405 @@ +# Makefile.in generated by automake 1.6.2 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ + +EXEEXT = @EXEEXT@ +OBJEXT = @OBJEXT@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +AMTAR = @AMTAR@ +AWK = @AWK@ +BARE_CPU_CFLAGS = @BARE_CPU_CFLAGS@ +BARE_CPU_MODEL = @BARE_CPU_MODEL@ +CC = @CC@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +ENDIF = @ENDIF@ +GCCSED = @GCCSED@ +GCC_SPECS = @GCC_SPECS@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +MAINT = @MAINT@ +MAKE = @MAKE@ +MULTIBUILDTOP = @MULTIBUILDTOP@ +MULTISUBDIR = @MULTISUBDIR@ +PACKAGE = @PACKAGE@ +PROJECT_INCLUDE = @PROJECT_INCLUDE@ +PROJECT_ROOT = @PROJECT_ROOT@ +PROJECT_TOPdir = @PROJECT_TOPdir@ +RANLIB = @RANLIB@ +RTEMS_BSP = @RTEMS_BSP@ +RTEMS_CPU = @RTEMS_CPU@ +RTEMS_HOST = @RTEMS_HOST@ +RTEMS_ROOT = @RTEMS_ROOT@ +RTEMS_TOPdir = @RTEMS_TOPdir@ +STRIP = @STRIP@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ +multilib_basedir = @multilib_basedir@ +project_libdir = @project_libdir@ + +SUBDIRS = imfs dosfs + +PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools +subdir = src +mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = Makefile.am Makefile.in +DIST_SUBDIRS = $(SUBDIRS) +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/../automake/subdirs.am $(top_srcdir)/../automake/local.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +ETAGS = etags +ETAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-recursive + +distclean-am: clean-am distclean-generic distclean-local distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ + clean-generic clean-local clean-recursive distclean \ + distclean-generic distclean-local distclean-recursive \ + distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-data install-data-am \ + install-data-recursive install-exec install-exec-am \ + install-exec-recursive install-info install-info-am \ + install-info-recursive install-man install-recursive \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am installdirs-recursive maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive mostlyclean \ + mostlyclean-generic mostlyclean-recursive tags tags-recursive \ + uninstall uninstall-am uninstall-info-am \ + uninstall-info-recursive uninstall-recursive + + +depend-recursive \ +preinstall-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +preinstall: preinstall-recursive +.PHONY: preinstall-recursive + +depend: depend-recursive +.PHONY: depend-recursive + +debug: + @echo + @echo "\"make debug\" is obsolete, instead use:" + @echo " make VARIANT=DEBUG" + @echo + +.PHONY: debug + +profile: + @echo + @echo "\"make profile\" is obsolete, instead use:" + @echo " make VARIANT=PROFILE" + @echo + +.PHONY: profile + +preinstall-am: $(PREINSTALL_FILES) +preinstall: preinstall-am +.PHONY: preinstall preinstall-am + +depend-am: +depend: depend-am +.PHONY: depend depend-am + +${ARCH}: + mkdir ${ARCH} + +clean-local: + $(RM) -r o-optimize o-debug o-profile $(CLEANDIRS) + $(RM) Depends-o-optimize.tmp Depends-o-debug.tmp Depends-o-profile.tmp + +distclean-local: + $(RM) Depends-o-optimize Depends-o-debug Depends-o-profile +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: Index: src/Makefile.am =================================================================== --- src/Makefile.am (nonexistent) +++ src/Makefile.am (revision 1765) @@ -0,0 +1,9 @@ +## +## Makefile.am,v 1.5 2002/06/17 09:10:53 ralf Exp +## + + +SUBDIRS = imfs dosfs + +include $(top_srcdir)/../automake/subdirs.am +include $(top_srcdir)/../automake/local.am Index: src =================================================================== --- src (nonexistent) +++ src (revision 1765)
src Property changes : Added: svn:ignore ## -0,0 +1,2 ## +Makefile +Makefile.in Index: config.h.in =================================================================== --- config.h.in (nonexistent) +++ config.h.in (revision 1765) @@ -0,0 +1 @@ +/* config.h.in. Generated automatically from configure.ac by autoheader. */ Index: configure =================================================================== --- configure (nonexistent) +++ configure (revision 1765) @@ -0,0 +1,3974 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by Autoconf 2.52 for rtems-c-src-libfs ss-20020528. +# +# Report bugs to . +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Name of the executable. +as_me=`echo "$0" |sed 's,.*[\\/],,'` + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +# NLS nuisances. +$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } +$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } +$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } +$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } +$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } +$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } +$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } +$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +cross_compiling=no +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +ac_unique_file="src/imfs/imfs.h" +ac_default_prefix=/opt/rtems + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Identity of this package. +PACKAGE_NAME='rtems-c-src-libfs' +PACKAGE_TARNAME='rtems-c-src-libfs' +PACKAGE_VERSION='ss-20020528' +PACKAGE_STRING='rtems-c-src-libfs ss-20020528' +PACKAGE_BUGREPORT='rtems-bugs@OARcorp.com' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: should be removed in autoconf 3.0. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_RTEMS_BSP_set=${RTEMS_BSP+set} +ac_env_RTEMS_BSP_value=$RTEMS_BSP +ac_cv_env_RTEMS_BSP_set=${RTEMS_BSP+set} +ac_cv_env_RTEMS_BSP_value=$RTEMS_BSP +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat < if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +EOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue + cd $ac_subdir + # A "../" for each directory in /$ac_subdir. + ac_dots=`echo $ac_subdir | + sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'` + + case $srcdir in + .) # No --srcdir option. We are building in place. + ac_sub_srcdir=$srcdir ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_sub_srcdir=$srcdir/$ac_subdir ;; + *) # Relative path. + ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;; + esac + + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_sub_srcdir/configure.gnu; then + echo + $SHELL $ac_sub_srcdir/configure.gnu --help=recursive + elif test -f $ac_sub_srcdir/configure; then + echo + $SHELL $ac_sub_srcdir/configure --help=recursive + elif test -f $ac_sub_srcdir/configure.ac || + test -f $ac_sub_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\EOF +rtems-c-src-libfs configure ss-20020528 +generated by GNU Autoconf 2.52 + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +EOF + exit 0 +fi +exec 5>config.log +cat >&5 </dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +PATH = $PATH + +_ASUNAME +} >&5 + +cat >&5 <\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + ac_sep=" " ;; + *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg" + ac_sep=" " ;; + esac + # Get rid of the leading space. +done + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + echo >&5 + echo "## ----------------- ##" >&5 + echo "## Cache variables. ##" >&5 + echo "## ----------------- ##" >&5 + echo >&5 + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} >&5 + sed "/^$/d" confdefs.h >conftest.log + if test -s conftest.log; then + echo >&5 + echo "## ------------ ##" >&5 + echo "## confdefs.h. ##" >&5 + echo "## ------------ ##" >&5 + echo >&5 + cat conftest.log >&5 + fi + (echo; echo) >&5 + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" >&5 + echo "$as_me: exit $exit_status" >&5 + rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:854: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + cat "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:865: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:873: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:889: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:893: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:899: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:901: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:903: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. It doesn't matter if + # we pass some twice (in addition to the command line arguments). + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val" + ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:922: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:924: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac +echo "#! $SHELL" >conftest.sh +echo "exit 0" >>conftest.sh +chmod +x conftest.sh +if { (echo "$as_me:944: PATH=\".;.\"; conftest.sh") >&5 + (PATH=".;."; conftest.sh) 2>&5 + ac_status=$? + echo "$as_me:947: \$? = $ac_status" >&5 + (exit $ac_status); }; then + ac_path_separator=';' +else + ac_path_separator=: +fi +PATH_SEPARATOR="$ac_path_separator" +rm -f conftest.sh + +for ac_prog in gmake make +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:960: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_MAKE+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$MAKE"; then + ac_cv_prog_MAKE="$MAKE" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_MAKE="$ac_prog" +echo "$as_me:975: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +MAKE=$ac_cv_prog_MAKE +if test -n "$MAKE"; then + echo "$as_me:983: result: $MAKE" >&5 +echo "${ECHO_T}$MAKE" >&6 +else + echo "$as_me:986: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$MAKE" && break +done + +ENDIF=endif + +RTEMS_TOPdir="../.."; + +test -n "$with_target_subdir" || with_target_subdir="." + +if test "$with_target_subdir" = "." ; then +# Native +PROJECT_TOPdir="${with_project_root}${RTEMS_TOPdir}/\$(MULTIBUILDTOP)\$(top_builddir)" +else +# Cross +dots=`echo $with_target_subdir|\ +sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'` +PROJECT_TOPdir="${dots}${with_project_root}${RTEMS_TOPdir}/\$(MULTIBUILDTOP)\$(top_builddir)" +fi + +PROJECT_ROOT="${with_project_root}${RTEMS_TOPdir}/\$(MULTIBUILDTOP)\$(top_builddir)" + +echo "$as_me:1011: checking for RTEMS Version" >&5 +echo $ECHO_N "checking for RTEMS Version... $ECHO_C" >&6 +if test -r "${srcdir}/${RTEMS_TOPdir}/cpukit/aclocal/version.m4"; then + : +else + { { echo "$as_me:1016: error: Unable to find ${RTEMS_TOPdir}/cpukit/aclocal/version.m4" >&5 +echo "$as_me: error: Unable to find ${RTEMS_TOPdir}/cpukit/aclocal/version.m4" >&2;} + { (exit 1); exit 1; }; } +fi + +echo "$as_me:1021: result: ss-20020528" >&5 +echo "${ECHO_T}ss-20020528" >&6 + +ac_aux_dir= +for ac_dir in ../.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:1041: error: cannot find install-sh or install.sh in ../.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in ../.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:1051: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:1055: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:1064: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:1068: error: $ac_config_sub $ac_cv_build_alias failed." >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:1073: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +echo "$as_me:1080: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:1089: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:1094: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +echo "$as_me:1101: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6 +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_target_alias=$target_alias +test "x$ac_cv_target_alias" = "x" && + ac_cv_target_alias=$ac_cv_host_alias +ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || + { { echo "$as_me:1110: error: $ac_config_sub $ac_cv_target_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:1115: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6 +target=$ac_cv_target +target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- +echo "$as_me:1128: checking rtems target cpu" >&5 +echo $ECHO_N "checking rtems target cpu... $ECHO_C" >&6 +case "${target}" in + # hpux unix port should go here + i[34567]86-*linux*) # unix "simulator" port + RTEMS_CPU=unix + ;; + i[34567]86-*freebsd*) # unix "simulator" port + RTEMS_CPU=unix + ;; + i[34567]86-pc-cygwin*) # Cygwin is just enough unix like :) + RTEMS_CPU=unix + ;; + no_cpu-*rtems*) + RTEMS_CPU=no_cpu + ;; + sparc-sun-solaris*) # unix "simulator" port + RTEMS_CPU=unix + ;; + *) + RTEMS_CPU=`echo $target | sed 's%^\([^-]*\)-\(.*\)$%\1%'` + ;; +esac + +echo "$as_me:1152: result: $RTEMS_CPU" >&5 +echo "${ECHO_T}$RTEMS_CPU" >&6 + +am__api_version="1.6" +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:1168: checking for a BSD compatible install" >&5 +echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_IFS=$IFS; IFS=$ac_path_separator + for ac_dir in $PATH; do + IFS=$ac_save_IFS + # Account for people who put trailing slashes in PATH elements. + case $ac_dir/ in + / | ./ | .// | /cC/* \ + | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \ + | /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if $as_executable_p "$ac_dir/$ac_prog"; then + if test $ac_prog = install && + grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:1217: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:1228: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:1252: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:1265: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:1271: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:1295: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +for ac_prog in mawk gawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:1303: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_AWK="$ac_prog" +echo "$as_me:1318: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:1326: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:1329: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:1336: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:1356: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:1360: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + # test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:1368: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# Define the identity of the package. + PACKAGE=rtems-c-src-libfs + VERSION=ss-20020528 + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +echo "$as_me:1401: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_STRIP="${ac_tool_prefix}strip" +echo "$as_me:1416: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + echo "$as_me:1424: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6 +else + echo "$as_me:1427: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +echo "$as_me:1436: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_STRIP="strip" +echo "$as_me:1451: found $ac_dir/$ac_word" >&5 +break +done + + test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + echo "$as_me:1460: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6 +else + echo "$as_me:1463: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + STRIP=$ac_ct_STRIP +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. + +echo "$as_me:1478: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6 + # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then + enableval="$enable_maintainer_mode" + USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi; + echo "$as_me:1487: result: $USE_MAINTAINER_MODE" >&5 +echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6 + +if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + +# Check whether --enable-multilib or --disable-multilib was given. +if test "${enable_multilib+set}" = set; then + enableval="$enable_multilib" + case "${enableval}" in + yes) multilib=yes ;; + no) multilib=no ;; + *) { { echo "$as_me:1506: error: bad value ${enableval} for multilib option" >&5 +echo "$as_me: error: bad value ${enableval} for multilib option" >&2;} + { (exit 1); exit 1; }; } ;; + esac +else + multilib=no +fi; + +if test x"${multilib}" = x"yes"; then + MULTILIB_TRUE= + MULTILIB_FALSE='#' +else + MULTILIB_TRUE='#' + MULTILIB_FALSE= +fi + +if test x"$multilib" = x"yes"; then + if test -n "$with_multisubdir"; then + MULTIBUILDTOP=`echo "/$with_multisubdir" | sed 's,/[^\\/]*,../,g'` +fi + + if test -n "$with_multisubdir"; then + MULTISUBDIR="/$with_multisubdir" +fi + + GCC_SPECS="-isystem \$(PROJECT_INCLUDE)" + + PROJECT_INCLUDE="\$(PROJECT_ROOT)/lib/include" + + project_libdir="\$(PROJECT_ROOT)/lib" + + RTEMS_ROOT="${PROJECT_ROOT}" + + includedir="\${exec_prefix}/lib/include" + libdir="${libdir}\$(MULTISUBDIR)" +else + +echo "$as_me:1543: checking for RTEMS_BSP" >&5 +echo $ECHO_N "checking for RTEMS_BSP... $ECHO_C" >&6 +if test "${rtems_cv_RTEMS_BSP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + test -n "${RTEMS_BSP}" && rtems_cv_RTEMS_BSP="$RTEMS_BSP"; + +fi +if test -z "$rtems_cv_RTEMS_BSP"; then + { { echo "$as_me:1552: error: Missing RTEMS_BSP" >&5 +echo "$as_me: error: Missing RTEMS_BSP" >&2;} + { (exit 1); exit 1; }; } +fi +RTEMS_BSP="$rtems_cv_RTEMS_BSP" +echo "$as_me:1557: result: ${RTEMS_BSP}" >&5 +echo "${ECHO_T}${RTEMS_BSP}" >&6 + +PROJECT_INCLUDE="\$(PROJECT_ROOT)/$RTEMS_BSP/lib/include" + +project_libdir="${PROJECT_ROOT}/$RTEMS_BSP/lib" + +RTEMS_ROOT="$PROJECT_ROOT/c/$RTEMS_BSP" + +GCC_SPECS="-isystem \$(PROJECT_INCLUDE)" + +# Check whether --enable-bare-cpu-cflags or --disable-bare-cpu-cflags was given. +if test "${enable_bare_cpu_cflags+set}" = set; then + enableval="$enable_bare_cpu_cflags" + case "${enableval}" in + no) BARE_CPU_CFLAGS="" ;; + *) BARE_CPU_CFLAGS="${enableval}" ;; +esac +else + BARE_CPU_CFLAGS="" +fi; + +# Check whether --enable-bare-cpu-model or --disable-bare-cpu-model was given. +if test "${enable_bare_cpu_model+set}" = set; then + enableval="$enable_bare_cpu_model" + case "${enableval}" in + no) BARE_CPU_MODEL="" ;; + *) BARE_CPU_MODEL="${enableval}" ;; +esac +else + BARE_CPU_MODEL="" +fi; + +if false; then + MULTILIB_TRUE= + MULTILIB_FALSE='#' +else + MULTILIB_TRUE='#' + MULTILIB_FALSE= +fi + +includedir="\${exec_prefix}/${RTEMS_BSP}/lib/include" +libdir="\${exec_prefix}/${RTEMS_BSP}/lib" + +echo "$as_me:1601: checking for make/custom/$RTEMS_BSP.cfg" >&5 +echo $ECHO_N "checking for make/custom/$RTEMS_BSP.cfg... $ECHO_C" >&6 +if test -r "$srcdir/$RTEMS_TOPdir/make/custom/$RTEMS_BSP.cfg"; then + echo "$as_me:1604: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + { { echo "$as_me:1607: error: no" >&5 +echo "$as_me: error: no" >&2;} + { (exit 1); exit 1; }; } +fi + +fi + +# Is this a supported CPU? +echo "$as_me:1615: checking if cpu $RTEMS_CPU is supported" >&5 +echo $ECHO_N "checking if cpu $RTEMS_CPU is supported... $ECHO_C" >&6 +if test -d "$srcdir/$RTEMS_TOPdir/cpukit/score/cpu/$RTEMS_CPU"; then + echo "$as_me:1618: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + { { echo "$as_me:1621: error: no" >&5 +echo "$as_me: error: no" >&2;} + { (exit 1); exit 1; }; } +fi + +RTEMS_HOST=$host_os +case "${target}" in + # hpux unix port should go here + i[34567]86-*linux*) # unix "simulator" port + RTEMS_HOST=Linux + ;; + i[34567]86-*freebsd*) # unix "simulator" port + RTEMS_HOST=FreeBSD + ;; + i[34567]86-pc-cygwin*) # Cygwin is just enough unix like :) + RTEMS_HOST=Cygwin + ;; + sparc-sun-solaris*) # unix "simulator" port + RTEMS_HOST=Solaris + ;; + *) + ;; +esac + +rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null + +ac_config_commands="$ac_config_commands depfiles" + +am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:1663: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + +echo "$as_me:1690: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + if test "x$build_alias" != "x$host_alias"; then + rtems_tool_prefix=${ac_tool_prefix} +fi + + # Extract the first word of "${rtems_tool_prefix}gcc", so it can be a program name with args. +set dummy ${rtems_tool_prefix}gcc; ac_word=$2 +echo "$as_me:1718: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="${rtems_tool_prefix}gcc" +echo "$as_me:1733: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1741: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1744: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +test -z "$CC" && \ + { { echo "$as_me:1749: error: no acceptable cc found in \$PATH" >&5 +echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:1760: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="${ac_tool_prefix}gcc" +echo "$as_me:1775: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1783: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1786: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:1795: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="gcc" +echo "$as_me:1810: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:1818: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1821: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:1834: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="${ac_tool_prefix}cc" +echo "$as_me:1849: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1857: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1860: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:1869: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="cc" +echo "$as_me:1884: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:1892: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1895: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:1908: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue +fi +ac_cv_prog_CC="cc" +echo "$as_me:1928: found $ac_dir/$ac_word" >&5 +break +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" ${1+"$@"} + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1950: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1953: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:1964: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_CC="$ac_tool_prefix$ac_prog" +echo "$as_me:1979: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1987: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1990: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:2003: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_CC="$ac_prog" +echo "$as_me:2018: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:2026: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:2029: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + +test -z "$CC" && { { echo "$as_me:2041: error: no acceptable cc found in \$PATH" >&5 +echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:2046:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:2049: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:2052: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:2054: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:2057: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:2059: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:2062: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line 2066 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:2082: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:2085: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:2088: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. +for ac_file in `ls a.exe conftest.exe 2>/dev/null; + ls a.out conftest 2>/dev/null; + ls a.* conftest.* 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + a.out ) # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool --akim. + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:2111: error: C compiler cannot create executables" >&5 +echo "$as_me: error: C compiler cannot create executables" >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:2117: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:2122: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:2128: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2131: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:2138: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:2146: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:2153: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:2155: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:2158: checking for executable suffix" >&5 +echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 +if { (eval echo "$as_me:2160: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:2163: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:2179: error: cannot compute EXEEXT: cannot compile and link" >&5 +echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:2185: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:2191: checking for object suffix" >&5 +echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2197 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:2209: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2212: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +{ { echo "$as_me:2224: error: cannot compute OBJEXT: cannot compile" >&5 +echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:2231: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:2235: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2241 "configure" +#include "confdefs.h" + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2256: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2259: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2262: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2265: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:2277: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:2283: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line 2289 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2301: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2304: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2307: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2310: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:2320: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2347: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2350: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2353: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2356: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line 2368 "configure" +#include "confdefs.h" +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2381: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2384: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2387: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2390: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line 2400 "configure" +#include "confdefs.h" +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2412: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2415: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2418: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2421: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +echo "$as_me:2450: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:2512: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:2521: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line 2542 "configure" +#include "confdefs.h" +#include + Syntax error +_ACEOF +if { (eval echo "$as_me:2547: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2553: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line 2576 "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:2580: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2586: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:2623: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line 2633 "configure" +#include "confdefs.h" +#include + Syntax error +_ACEOF +if { (eval echo "$as_me:2638: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2644: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line 2667 "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:2671: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:2677: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:2705: error: C preprocessor \"$CPP\" fails sanity check" >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +if test x"$GCC" = x"yes"; then + RTEMS_USE_GCC_TRUE= + RTEMS_USE_GCC_FALSE='#' +else + RTEMS_USE_GCC_TRUE='#' + RTEMS_USE_GCC_FALSE= +fi + +echo "$as_me:2724: checking whether $CC accepts -specs" >&5 +echo $ECHO_N "checking whether $CC accepts -specs... $ECHO_C" >&6 +if test "${rtems_cv_gcc_specs+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +rtems_cv_gcc_specs=no +if test x"$GCC" = x"yes"; then + touch confspec + echo 'void f(){}' >conftest.c + if test -z "`${CC} -specs confspec -c conftest.c 2>&1`";then + rtems_cv_gcc_specs=yes + fi +fi +rm -f confspec conftest* + +fi +echo "$as_me:2741: result: $rtems_cv_gcc_specs" >&5 +echo "${ECHO_T}$rtems_cv_gcc_specs" >&6 + +echo "$as_me:2744: checking whether $CC accepts --pipe" >&5 +echo $ECHO_N "checking whether $CC accepts --pipe... $ECHO_C" >&6 +if test "${rtems_cv_gcc_pipe+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +rtems_cv_gcc_pipe=no +if test x"$GCC" = x"yes"; then + echo 'void f(){}' >conftest.c + if test -z "`${CC} --pipe -c conftest.c 2>&1`";then + rtems_cv_gcc_pipe=yes + fi + rm -f conftest* +fi + +fi +echo "$as_me:2760: result: $rtems_cv_gcc_pipe" >&5 +echo "${ECHO_T}$rtems_cv_gcc_pipe" >&6 + +test "$rtems_cv_gcc_pipe" = "yes" && CC="$CC --pipe" + +if test "$GCC" = yes; then + +CPPFLAGS="$CPPFLAGS -ansi -fasm" + +CFLAGS="-g -Wall" +fi + +#case $build_os in +#*cygwin*) GCCSED="| sed 's%\\\\%/%g'" ;; +#*) ;; +#esac + + if test "x$build_alias" != "x$host_alias"; then + rtems_tool_prefix=${ac_tool_prefix} +fi + + # Extract the first word of "${rtems_tool_prefix}ar", so it can be a program name with args. +set dummy ${rtems_tool_prefix}ar; ac_word=$2 +echo "$as_me:2783: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_AR="${rtems_tool_prefix}ar" +echo "$as_me:2798: found $ac_dir/$ac_word" >&5 +break +done + + test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="no" +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + echo "$as_me:2807: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 +else + echo "$as_me:2810: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + if test "x$build_alias" != "x$host_alias"; then + rtems_tool_prefix=${ac_tool_prefix} +fi + + # Extract the first word of "${rtems_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${rtems_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:2820: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_RANLIB="${rtems_tool_prefix}ranlib" +echo "$as_me:2835: found $ac_dir/$ac_word" >&5 +break +done + + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:2844: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:2847: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:2854: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" +echo "$as_me:2869: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:2877: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:2880: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:2889: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else + ac_save_IFS=$IFS; IFS=$ac_path_separator +ac_dummy="$PATH" +for ac_dir in $ac_dummy; do + IFS=$ac_save_IFS + test -z "$ac_dir" && ac_dir=. + $as_executable_p "$ac_dir/$ac_word" || continue +ac_cv_prog_ac_ct_RANLIB="ranlib" +echo "$as_me:2904: found $ac_dir/$ac_word" >&5 +break +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:2913: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:2916: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +if test x"$RTEMS_CPU" = x"unix"; then + UNIX_TRUE= + UNIX_FALSE='#' +else + UNIX_TRUE='#' + UNIX_FALSE= +fi + +# Add the stamp file to the list of files AC keeps track of, +# along with our hook. +ac_config_headers="$ac_config_headers config.h" + +# Explicitly list all Makefiles here +ac_config_files="$ac_config_files Makefile src/Makefile src/imfs/Makefile src/dosfs/Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overriden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if cmp -s $cache_file confcache; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + { { echo "$as_me:3017: error: conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${MULTILIB_TRUE}" && test -z "${MULTILIB_FALSE}"; then + { { echo "$as_me:3024: error: conditional \"MULTILIB\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"MULTILIB\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${MULTILIB_TRUE}" && test -z "${MULTILIB_FALSE}"; then + { { echo "$as_me:3031: error: conditional \"MULTILIB\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"MULTILIB\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:3038: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${RTEMS_USE_GCC_TRUE}" && test -z "${RTEMS_USE_GCC_FALSE}"; then + { { echo "$as_me:3045: error: conditional \"RTEMS_USE_GCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"RTEMS_USE_GCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${UNIX_TRUE}" && test -z "${UNIX_FALSE}"; then + { { echo "$as_me:3052: error: conditional \"UNIX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"UNIX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:3062: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +SHELL=\${CONFIG_SHELL-$SHELL} +ac_cs_invocation="\$0 \$@" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Name of the executable. +as_me=`echo "$0" |sed 's,.*[\\/],,'` + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +as_executable_p="test -f" + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + +# NLS nuisances. +$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; } +$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; } +$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; } +$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; } +$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; } +$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; } +$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; } +$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; } + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; } + +exec 6>&1 + +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\EOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." +EOF + +cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + shift + set dummy "$ac_option" "$ac_optarg" ${1+"$@"} + shift + ;; + -*);; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_need_defaults=false;; + esac + + case $1 in + # Handling of the options. +EOF +cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:3238: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + shift + CONFIG_FILES="$CONFIG_FILES $1" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + shift + CONFIG_HEADERS="$CONFIG_HEADERS $1" + ac_need_defaults=false;; + + # This is an error. + -*) { { echo "$as_me:3257: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +exec 5>>config.log +cat >&5 << _ACEOF + +## ----------------------- ## +## Running config.status. ## +## ----------------------- ## + +This file was extended by $as_me (rtems-c-src-libfs ss-20020528) 2.52, executed with + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + > $ac_cs_invocation +on `(hostname || uname -n) 2>/dev/null | sed 1q` + +_ACEOF +EOF + +cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "src/imfs/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/imfs/Makefile" ;; + "src/dosfs/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/dosfs/Makefile" ;; + "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:3307: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. +: ${TMPDIR=/tmp} +{ + tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=$TMPDIR/cs$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in $TMPDIR" >&2 + { (exit 1); exit 1; } +} + +EOF + +cat >>$CONFIG_STATUS <\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@DEFS@,$DEFS,;t t +s,@LIBS@,$LIBS,;t t +s,@MAKE@,$MAKE,;t t +s,@ENDIF@,$ENDIF,;t t +s,@RTEMS_TOPdir@,$RTEMS_TOPdir,;t t +s,@PROJECT_TOPdir@,$PROJECT_TOPdir,;t t +s,@PROJECT_ROOT@,$PROJECT_ROOT,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@target@,$target,;t t +s,@target_cpu@,$target_cpu,;t t +s,@target_vendor@,$target_vendor,;t t +s,@target_os@,$target_os,;t t +s,@RTEMS_CPU@,$RTEMS_CPU,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@AMTAR@,$AMTAR,;t t +s,@install_sh@,$install_sh,;t t +s,@STRIP@,$STRIP,;t t +s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t +s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t +s,@MAINT@,$MAINT,;t t +s,@MULTILIB_TRUE@,$MULTILIB_TRUE,;t t +s,@MULTILIB_FALSE@,$MULTILIB_FALSE,;t t +s,@MULTIBUILDTOP@,$MULTIBUILDTOP,;t t +s,@MULTISUBDIR@,$MULTISUBDIR,;t t +s,@GCC_SPECS@,$GCC_SPECS,;t t +s,@PROJECT_INCLUDE@,$PROJECT_INCLUDE,;t t +s,@project_libdir@,$project_libdir,;t t +s,@RTEMS_ROOT@,$RTEMS_ROOT,;t t +s,@RTEMS_BSP@,$RTEMS_BSP,;t t +s,@BARE_CPU_MODEL@,$BARE_CPU_MODEL,;t t +s,@BARE_CPU_CFLAGS@,$BARE_CPU_CFLAGS,;t t +s,@RTEMS_HOST@,$RTEMS_HOST,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@CPP@,$CPP,;t t +s,@RTEMS_USE_GCC_TRUE@,$RTEMS_USE_GCC_TRUE,;t t +s,@RTEMS_USE_GCC_FALSE@,$RTEMS_USE_GCC_FALSE,;t t +s,@GCCSED@,$GCCSED,;t t +s,@AR@,$AR,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@UNIX_TRUE@,$UNIX_TRUE,;t t +s,@UNIX_FALSE@,$UNIX_FALSE,;t t +CEOF + +EOF + + cat >>$CONFIG_STATUS <<\EOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +EOF +cat >>$CONFIG_STATUS <<\EOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + { case "$ac_dir" in + [\\/]* | ?:[\\/]* ) as_incr_dir=;; + *) as_incr_dir=.;; +esac +as_dummy="$ac_dir" +for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do + case $as_mkdir_dir in + # Skip DOS drivespec + ?:) as_incr_dir=$as_mkdir_dir ;; + *) + as_incr_dir=$as_incr_dir/$as_mkdir_dir + test -d "$as_incr_dir" || mkdir "$as_incr_dir" + ;; + esac +done; } + + ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'` + else + ac_dir_suffix= ac_dots= + fi + + case $srcdir in + .) ac_srcdir=. + if test -z "$ac_dots"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_dots$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_dots$srcdir ;; + esac + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_dots$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:3576: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated automatically by config.status. */ + configure_input="Generated automatically from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:3594: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:3607: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +EOF +cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +EOF +cat >>$CONFIG_STATUS <<\EOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:3668: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:3679: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:3692: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +EOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\EOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\(\([^ (][^ (]*\)([^)]*)\)[ ]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +EOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\EOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +EOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # egrep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\EOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated automatically by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated automatically by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated automatically by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if cmp -s $ac_file $tmp/config.h 2>/dev/null; then + { echo "$as_me:3809: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + { case "$ac_dir" in + [\\/]* | ?:[\\/]* ) as_incr_dir=;; + *) as_incr_dir=.;; +esac +as_dummy="$ac_dir" +for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do + case $as_mkdir_dir in + # Skip DOS drivespec + ?:) as_incr_dir=$as_mkdir_dir ;; + *) + as_incr_dir=$as_incr_dir/$as_mkdir_dir + test -d "$as_incr_dir" || mkdir "$as_incr_dir" + ;; + esac +done; } + + fi + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi + # Run the commands associated with the file. + case $ac_file in + config.h ) # update the timestamp +echo 'timestamp for config.h' >"./stamp-h1" + ;; + esac +done +EOF +cat >>$CONFIG_STATUS <<\EOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + + case $ac_dest in + depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + else + continue + fi + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { case $dirpart/$fdir in + [\\/]* | ?:[\\/]* ) as_incr_dir=;; + *) as_incr_dir=.;; +esac +as_dummy=$dirpart/$fdir +for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do + case $as_mkdir_dir in + # Skip DOS drivespec + ?:) as_incr_dir=$as_mkdir_dir ;; + *) + as_incr_dir=$as_incr_dir/$as_mkdir_dir + test -d "$as_incr_dir" || mkdir "$as_incr_dir" + ;; + esac +done; } + + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +EOF + +cat >>$CONFIG_STATUS <<\EOF + +{ (exit 0); exit 0; } +EOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + exec 5>/dev/null + $SHELL $CONFIG_STATUS || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi +
configure Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: Makefile.in =================================================================== --- Makefile.in (nonexistent) +++ Makefile.in (revision 1765) @@ -0,0 +1,509 @@ +# Makefile.in generated by automake 1.6.2 from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ + +EXEEXT = @EXEEXT@ +OBJEXT = @OBJEXT@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +AMTAR = @AMTAR@ +AWK = @AWK@ +BARE_CPU_CFLAGS = @BARE_CPU_CFLAGS@ +BARE_CPU_MODEL = @BARE_CPU_MODEL@ +CC = @CC@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +ENDIF = @ENDIF@ +GCCSED = @GCCSED@ +GCC_SPECS = @GCC_SPECS@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +MAINT = @MAINT@ +MAKE = @MAKE@ +MULTIBUILDTOP = @MULTIBUILDTOP@ +MULTISUBDIR = @MULTISUBDIR@ +PACKAGE = @PACKAGE@ +PROJECT_INCLUDE = @PROJECT_INCLUDE@ +PROJECT_ROOT = @PROJECT_ROOT@ +PROJECT_TOPdir = @PROJECT_TOPdir@ +RANLIB = @RANLIB@ +RTEMS_BSP = @RTEMS_BSP@ +RTEMS_CPU = @RTEMS_CPU@ +RTEMS_HOST = @RTEMS_HOST@ +RTEMS_ROOT = @RTEMS_ROOT@ +RTEMS_TOPdir = @RTEMS_TOPdir@ +STRIP = @STRIP@ +VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ +multilib_basedir = @multilib_basedir@ +project_libdir = @project_libdir@ + +ACLOCAL_AMFLAGS = -I ../aclocal + +SUBDIRS = src + +EXTRA_DIST = README + +PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = README ../../COPYING ../../ChangeLog ../../INSTALL \ + ../../README ../../acinclude.m4 ../../config.guess \ + ../../config.sub ../../configure ../../configure.ac \ + ../../depcomp ../../install-sh ../../missing \ + ../../mkinstalldirs ChangeLog Makefile.am Makefile.in \ + aclocal.m4 config.h.in configure configure.ac +DIST_SUBDIRS = $(SUBDIRS) +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: + +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/../automake/subdirs.am $(top_srcdir)/../automake/local.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe) + +$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.ac ../aclocal/bsp-alias.m4 ../aclocal/canonical-host.m4 ../aclocal/canonical-target-name.m4 ../aclocal/canonicalize-tools.m4 ../aclocal/check-bsp-cache.m4 ../aclocal/check-bsps.m4 ../aclocal/check-cpu.m4 ../aclocal/check-itron.m4 ../aclocal/check-multiprocessing.m4 ../aclocal/check-networking.m4 ../aclocal/check-newlib.m4 ../aclocal/check-posix.m4 ../aclocal/check-tool.m4 ../aclocal/enable-bare.m4 ../aclocal/enable-inlines.m4 ../aclocal/enable-itron.m4 ../aclocal/enable-multiprocessing.m4 ../aclocal/enable-networking.m4 ../aclocal/enable-posix.m4 ../aclocal/enable-rtemsbsp.m4 ../aclocal/env-rtemsbsp.m4 ../aclocal/env-rtemscpu.m4 ../aclocal/gcc-pipe.m4 ../aclocal/gcc-specs.m4 ../aclocal/multi.m4 ../aclocal/multilib.m4 ../aclocal/prog-cc.m4 ../aclocal/prog-ccas.m4 ../aclocal/rtems-cpu-subdirs.m4 ../aclocal/rtems-debug.m4 ../aclocal/rtems-top.m4 ../aclocal/sysv-ipc.m4 ../aclocal/tool-paths.m4 ../aclocal/version.m4 + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h + +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOHEADER) + touch $(srcdir)/config.h.in + +distclean-hdr: + -rm -f config.h stamp-h1 +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +ETAGS = etags +ETAGSFLAGS = + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$tags$$unique" \ + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = . +distdir = $(PACKAGE)-$(VERSION) + +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } + +GZIP_ENV = --best +distcleancheck_listfiles = find . -type f -print + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + $(mkinstalldirs) $(distdir)/../.. + @list='$(DISTFILES)'; for file in $$list; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkinstalldirs) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist dist-all: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + $(am__remove_distdir) + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \ + && cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + find $$dc_install_base -type f -print ; \ + exit 1; } >&2 ) \ + && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \ + && rm -f $(distdir).tar.gz \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @echo "$(distdir).tar.gz is ready for distribution" | \ + sed 'h;s/./=/g;p;x;p;x' +distcleancheck: distclean + if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile config.h +installdirs: installdirs-recursive +installdirs-am: + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) +distclean-am: clean-am distclean-generic distclean-hdr distclean-local \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf autom4te.cache +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ + clean-generic clean-local clean-recursive dist dist-all \ + dist-gzip distcheck distclean distclean-generic distclean-hdr \ + distclean-local distclean-recursive distclean-tags \ + distcleancheck distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-data install-data-am \ + install-data-recursive install-exec install-exec-am \ + install-exec-recursive install-info install-info-am \ + install-info-recursive install-man install-recursive \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am installdirs-recursive maintainer-clean \ + maintainer-clean-generic maintainer-clean-recursive mostlyclean \ + mostlyclean-generic mostlyclean-recursive tags tags-recursive \ + uninstall uninstall-am uninstall-info-am \ + uninstall-info-recursive uninstall-recursive + + +depend-recursive \ +preinstall-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +preinstall: preinstall-recursive +.PHONY: preinstall-recursive + +depend: depend-recursive +.PHONY: depend-recursive + +debug: + @echo + @echo "\"make debug\" is obsolete, instead use:" + @echo " make VARIANT=DEBUG" + @echo + +.PHONY: debug + +profile: + @echo + @echo "\"make profile\" is obsolete, instead use:" + @echo " make VARIANT=PROFILE" + @echo + +.PHONY: profile + +preinstall-am: $(PREINSTALL_FILES) +preinstall: preinstall-am +.PHONY: preinstall preinstall-am + +depend-am: +depend: depend-am +.PHONY: depend depend-am + +${ARCH}: + mkdir ${ARCH} + +clean-local: + $(RM) -r o-optimize o-debug o-profile $(CLEANDIRS) + $(RM) Depends-o-optimize.tmp Depends-o-debug.tmp Depends-o-profile.tmp + +distclean-local: + $(RM) Depends-o-optimize Depends-o-debug Depends-o-profile +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: Index: configure.ac =================================================================== --- configure.ac (nonexistent) +++ configure.ac (revision 1765) @@ -0,0 +1,35 @@ +## Process this file with autoconf to produce a configure script. +## +## configure.ac,v 1.9 2002/07/31 05:27:07 ralf Exp + +AC_PREREQ(2.52) +AC_INIT([rtems-c-src-libfs],[_RTEMS_VERSION],[rtems-bugs@OARcorp.com]) +AC_CONFIG_SRCDIR([src/imfs/imfs.h]) + +RTEMS_TOP(../..) +AC_CONFIG_AUX_DIR(../..) + +RTEMS_CANONICAL_TARGET_CPU + +AM_INIT_AUTOMAKE([no-define foreign 1.6]) +AM_MAINTAINER_MODE + +RTEMS_ENV_RTEMSCPU + +RTEMS_CHECK_CPU +RTEMS_CANONICAL_HOST + +RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm]) +RTEMS_CANONICALIZE_TOOLS +AC_PROG_RANLIB + +AM_CONDITIONAL(UNIX,test x"$RTEMS_CPU" = x"unix") +AM_CONFIG_HEADER(config.h) + +# Explicitly list all Makefiles here +AC_CONFIG_FILES([Makefile +src/Makefile +src/imfs/Makefile +src/dosfs/Makefile +]) +AC_OUTPUT Index: ChangeLog =================================================================== --- ChangeLog (nonexistent) +++ ChangeLog (revision 1765) @@ -0,0 +1,366 @@ +2002-07-31 Ralf Corsepius + + * wrapup/Makefile.am: Remove. + * wrapup/.cvsignore: Remove. + * Makefile.am: Remove wrapup SUBDIR. + * configure.ac: Remove wrapup/Makefile. + +2002-07-05 Ralf Corsepius + + * configure.ac: RTEMS_TOP(../..). + +2002-07-01 Ralf Corsepius + + * configure.ac: Remove RTEMS_PROJECT_ROOT. + +2002-06-27 Ralf Corsepius + + * configure.ac: Use AC_CONFIG_AUX_DIR(../..). + Add AC_PROG_RANLIB. + +2002-06-26 Ralf Corsepius + + * wrapup/Makefile.am: Don't preinstall libfs.a. + +2002-06-17 Ralf Corsepius + + * src/dosfs/Makefile.am: Include $(top_srcdir)/../automake/*.am. + * src/Makefile.am: Include $(top_srcdir)/../automake/*.am. + * src/imfs/Makefile.am: Include $(top_srcdir)/../automake/*.am. + * Makefile.am: Include $(top_srcdir)/../automake/*.am. + Use ../aclocal. + * wrapup/Makefile.am: Include $(top_srcdir)/../automake/*.am. + +2002-05-18 Ralf Corsepius + + Move from c/src/libfs to c/src/exec/libfs + * configure.ac: Reflect move. + * Makefile.am: Ditto. + * src/Makefile.am: Ditto. + * src/dosfs/Makefile.am: Ditto. + * src/imfs/Makefile.am: Ditto. + * wrapup/Makefile.am: Ditto. + +2002-04-06 Ralf Corsepius + + * src/imfs/imfs_getchild.c: include . + * src/imfs/imfs_gtkn.c: Include . + * src/imfs/ioman.c: Include . + * src/imfs/linearfile.c: Include . + * src/imfs/memfile.c: Include . + +2001-04-04 Joel Sherrill + + * src/dosfs/Makefile.am: Per PR129 do not install as many files + to the $(includedir). + +2002-04-04 Ralf Corsepius + + * src/dosfs/fat.h: Include . + Remove DBG1 and DBG2 (unused). + +2002-04-04 Ralf Corsepius + + * Per PR169. + * src/dosfs/config.h.in, src/dosfs/stamp-h2.in: Removed from CVS. + + +2002-03-27 Ralf Corsepius + + * src/dosfs/fat_file.c: Remove bsp.h. + fat_file_write(.. const char*buf ..). + * src/dosfs/fat_file.h: fat_file_write(.. const char*buf ..). + +2002-03-27 Ralf Corsepius + + * configure.ac: + AC_INIT(package,_RTEMS_VERSION,_RTEMS_BUGS). + AM_INIT_AUTOMAKE([no-define foreign 1.6]). + * src/dosfs/Makefile.am: Remove AUTOMAKE_OPTIONS. + * src/Makefile.am: Remove AUTOMAKE_OPTIONS. + * src/imfs/Makefile.am: Remove AUTOMAKE_OPTIONS. + * Makefile.am: Remove AUTOMAKE_OPTIONS. + * wrapup/Makefile.am: Remove AUTOMAKE_OPTIONS. + +2002-03-16 Ralf Corsepius + + Addressing PR 140. + * src/dosfs/config.h.in: Removed. + * src/dosfs/stamp-h2.in: Removed. + * .cvsignore: Add config.h*, stamp-h*. + * configure.ac: Remove AC_SRC_DIR(.../dosfs.h). + Remove AM_CONFIG_HEADER(src/dosfs/config.h). + Remove AM_CONFIG_HEADER(src/imfs/config.h). + Add AM_CONFIG_HEADER(config.h). + * src/dosfs/Makefile.am: INCLUDES = -I../.. . + * src/imfs/Makefile.am: INCLUDES = -I../.. . + +2002-03-14 Ralf Corsepius + + Reported and tracked as PR130. + * src/dosfs/Makefile.am: Reworked, Disable dosfs for UNIX. + * wrapup/Makefile.am: Disable dosfs for UNIX. + +2001-03-01 Joel Sherrill + + * src/imfs/.cvsignore: Added stamp-h1.in + +2002-02-28 Victor V. Vengerov + + * DOS filesystem including FAT12, FAT16, and FAT32 support submitted. + * src/dosfs, src/dosfs/Makefile.am, src/dosfs/stamp-h2.in, + src/dosfs/config.h.in, src/dosfs/dosfs.h, src/dosfs/fat.c, + src/dosfs/fat.h, src/dosfs/fat_fat_operations.c, + src/dosfs/fat_fat_operations.h, src/dosfs/fat_file.c, + src/dosfs/fat_file.h, src/dosfs/msdos.h, src/dosfs/msdos_create.c, + src/dosfs/msdos_dir.c, src/dosfs/msdos_eval.c, src/dosfs/msdos_file.c, + src/dosfs/msdos_free.c, src/dosfs/msdos_fsunmount.c, + src/dosfs/msdos_handlers_dir.c, src/dosfs/msdos_handlers_file.c, + src/dosfs/msdos_init.c, src/dosfs/msdos_initsupp.c, + src/dosfs/msdos_misc.c, src/dosfs/msdos_mknod.c, + src/dosfs/msdos_node_type.c, src/dosfs/.cvsignore: New files. + * configure.ac, src/Makefile.am, wrapup/Makefile.am: Modified to + reflect addition. + +2002-01-07 Ralf Corsepius + + * src/imfs/imfs_load_tar.c: Add include . + Add include . Add include . + * src/imfs/imfs_rmnod.c: Add include . + +2002-01-04 Ralf Corsepius + + * src/imfs/imfs_eval.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/memfile.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_readlink.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_unlink.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_link.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_chown.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/ioman.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_mount.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_directory.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_stat.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_fchmod.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_symlink.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_mknod.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/linearfile.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs_unmount.c: Include . + Apply rtems_set_errno_and_return_minus_one. + * src/imfs/imfs.h: Apply rtems_set_errno_and_return_minus_one. + Comment out increment_and_check_linkcounts. + +2001-11-27 Ralf Corsepius + + * wrapup/Makefile.am: Remove HAS_IMFS. + +2001-11-26 Ralf Corsepius + + * src/imfs/Makefile.am: Cleanup. + +2001-11-07 Jennifer Averett + + Reported by Ibragimov Ilya and tracked as PR49. + * src/imfs/imfs_directory.c: Do not calculate the offset twice. + +2001-10-26 Victor V. Vengerov + + * src/imfs/imfs_load_tar.c: Minor modification so this will + compile with gcc-2.95.3 with the arguments "-m5200 -O4". + +2001-10-16 Chris Johns + + * imfs/imfs_load_tar.c: Changed the code around to remove an + internal compiler error on the Coldfire target. + +2001-10-11 Ralf Corsepius + + * .cvsignore: Add autom4te.cache for autoconf > 2.52. + * configure.in: Remove. + * configure.ac: New file, generated from configure.in by autoupdate. + +2001-10-10 Joel Sherrill + + * src/imfs/imfs_getchild.c: Correct length of static string + as reported by Ibragimov Ilya . + +2001-09-28 Ralf Corsepius + + * src/imfs/Makefile.am: Use 'PREINSTALL_FILES ='. + +2001-09-22 Ralf Corsepius + + * src/imfs/Makefile.am: Revamp INCLUDES handling to make automake-1.5 + happy. + +2001-08-09 Fernando-Ruiz Casas + + * src/imfs/imfs_eval.c: The CD_UP problem in imfs_eval has been + touched. The order of the questions is the key. + +2001-07-06 Thomas Doerfler + + * src/imfs/deviceio.c: Make sure errno gets set to reflect + the status from the driver. + +2001-05-25 Joel Sherrill + + * src/imfs/imfs_initsupp.c: Create the root node with the + desired permissions. Nodes should be created with the right + permissions because chmod() is not supported by the miniIMFS + so changing after creation is not possible. + +2001-04-27 Ralf Corsepius + + * configure.in: Add [-ansi -fasm] to RTEMS_PROG_CC_FOR_TARGET. + +2001-04-24 Joel Sherrill + + * src/imfs/memfile.c (memfile_open): Did not set iop->size + and thus the value was incorrect. Before this field was cleared, + this resulted in the value from the last time that IOP was used + being still in place. Discovered by Andrew Bythell + . + +2001-04-20 Joel Sherrill + + * src/imfs/imfs_debug.c (IMFS_print_jnode): Modified to print + only information that does not vary based on target or memory + configuration. The old prints are still there in case they + are needed in the future to debug. Printing target dependent + addresses makes the test output vary by target unnecessarily. + +2001-03-23 Joel Sherrill + + * src/imfs/memfile.c: Reapply fix from bug report from + Jose Sturniolo where NULL pointer + was dereferenced when freeing a triply indirect file. + The fix was applied to the 4.5 release branch and not + the development branch. + +2001-02-03 Ralf Corsepius + + * src/imfs/Makefile.am: Apply include_*HEADERS instead of H_FILES. + +2001-01-16 Ralf Corsepius + + * configure.in: Add src/imfs/config.h + * src/imfs/Makefile.am: Add INCLUDES += -I. to pickup config.h + * src/imfs/.cvsignore: Add config.h and stamp-h + * src/imfs/*.c: Add config.h support. + +2001-01-12 Jake Janovetz + + * src/imfs/imfs.h, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, + src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c, + src/imfs/imfs_handlers_memfile.c, src/imfs/imfs_init.c, + src/imfs/imfs_initsupp.c, src/imfs/imfs_stat.c, src/imfs/memfile.c, + src/imfs/miniimfs_init.c: Final developmental update to "tarfs". + When rtems_tarfs_load() is called, it checks the permissions + on each file. If there is write permission, it just creates a + standard file using "creat()" and therefore, uses the IMFS MEMORY_FILE. + If there is no write permission, it creates a LINEAR_FILE node + with the appropriate properties. If the permission is ever changed + to writeable, IMFS_fchmod converts it to a regular memory file. + +2000-12-12 Jake Janovetz + + * src/imfs/linearfile.c, src/imfs/imfs_load_tar.c: New files. + * src/imfs/Makefile.am, src/imfs/imfs.h, + src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, + src/imfs/imfs_eval.c, src/imfs/imfs_handlers_memfile.c, + src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, + src/imfs/imfs_stat.c, src/imfs/miniimfs_init.c: Added "tarfs". + This is not really a tar filesystem. It is a way to load a tar + image into the IMFS but actually leave bulky file contents in the + original tar image. It essentially adds the linear file type and + associated support and a loader routine. + +2000-11-28 Joel Sherrill + + * src/imfs/memfile.c: Bug report from Sturniolo Jose + where NULL pointer was dereferenced. + +2000-11-17 Jennifer Averret + + * src/imfs/imfs_eval.c: Always return imaginary node at mount points. + +2000-11-09 Ralf Corsepius + + * Makefile.am: Use ... instead of RTEMS_TOPdir in ACLOCAL_AMFLAGS. + +2000-11-02 Ralf Corsepius + + * Makefile.am: Switch to ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal. + +2000-11-01 Joel Sherrill + + * src/imfs/Makefile.am, src/imfs/deviceio.c, src/imfs/imfs_chown.c, + src/imfs/imfs_config.c, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, + src/imfs/imfs_directory.c, src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c, + src/imfs/imfs_free.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_gtkn.c, + src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_link.c, + src/imfs/imfs_mknod.c, src/imfs/imfs_mount.c, src/imfs/imfs_readlink.c, + src/imfs/imfs_rmnod.c, src/imfs/imfs_stat.c, src/imfs/imfs_symlink.c, + src/imfs/imfs_unixstub.c, src/imfs/imfs_unlink.c, + src/imfs/imfs_unmount.c, src/imfs/imfs_utime.c, src/imfs/ioman.c, + src/imfs/memfile.c, src/imfs/miniimfs_init.c: + assoc.h, error.h, libio_.h, libio.h, and libcsupport.h moved + from libc to lib/include/rtems and now must be referenced as + . Now we do not have to reach up and over to + libc to pick them up. + +2000-10-24 Joel Sherrill + + * src/imfs/imfs_config.c: New file containing IMFS configuration + information split from libc/base_fs.c. + * src/imfs/ioman.c: New file. Moved from lib/libc. Missed previously. + * src/imfs/Makefile.am: Added imfs_config.c and ioman.c. + +2000-10-24 Ralf Corsepius + + * Makefile.am, configure.in: Introduce GNU canonicalization to libfs/. + The approach is currently a bit of a hack as GNU canonicalization + does not support the per-BSP build some of the other directories + require. As more of the tree is converted, this will become less + of an issue. + +2000-10-19 Joel Sherrill + + * .cvsignore, src/.cvsignore, src/imfs/.cvsignore, wrapup/.cvsignore: + New files. + +2000-10-18 Chris Johns + + * libfs created. + * src, src/imfs, wrapup: New directories. + * ChangeLog, Makefile.am, README, configure.in, src/Makefile.am, + wrapup/Makefile.am: New files. + * src/imfs/deviceio.c, src/imfs/imfs_getchild.c, + src/imfs/imfs_readlink.c, src/imfs/imfs.h, src/imfs/imfs_gtkn.c, + src/imfs/imfs_rmnod.c, src/imfs/imfs_chown.c, + src/imfs/imfs_handlers_device.c, src/imfs/imfs_stat.c, + src/imfs/imfs_creat.c, src/imfs/imfs_handlers_directory.c, + src/imfs/imfs_symlink.c, src/imfs/imfs_debug.c, + src/imfs/imfs_handlers_link.c, src/imfs/imfs_unixstub.c, + src/imfs/imfs_directory.c, src/imfs/imfs_handlers_memfile.c, + src/imfs/imfs_unlink.c, src/imfs/imfs_eval.c, src/imfs/imfs_init.c, + src/imfs/imfs_unmount.c, src/imfs/imfs_fchmod.c, + src/imfs/imfs_initsupp.c, src/imfs/imfs_utime.c, src/imfs/imfs_fcntl.c, + src/imfs/imfs_link.c, src/imfs/memfile.c, src/imfs/imfs_fdatasync.c, + src/imfs/imfs_mknod.c, src/imfs/miniimfs_init.c, src/imfs/imfs_free.c, + src/imfs/imfs_mount.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_ntype.c: + New files. Moved from libc. Index: Makefile.am =================================================================== --- Makefile.am (nonexistent) +++ Makefile.am (revision 1765) @@ -0,0 +1,12 @@ +## +## Makefile.am,v 1.8 2002/07/31 05:27:07 ralf Exp +## + +ACLOCAL_AMFLAGS = -I ../aclocal + +SUBDIRS = src + +EXTRA_DIST = README + +include $(top_srcdir)/../automake/subdirs.am +include $(top_srcdir)/../automake/local.am Index: README =================================================================== --- README (nonexistent) +++ README (revision 1765) @@ -0,0 +1,13 @@ +# +# README,v 1.1 2000/10/18 18:10:55 joel Exp +# + +This directory contains for the "file system" library. All supported +file systems live under this tree. + +Currently the only supported file systems in this library are the IMFS +and miniIMFS. The TFTP client filesystem is part of the libnetworking +library. + +--Chris Johns and Joel Sherrill +18 October 2000 Index: aclocal.m4 =================================================================== --- aclocal.m4 (nonexistent) +++ aclocal.m4 (revision 1765) @@ -0,0 +1,1309 @@ +# aclocal.m4 generated automatically by aclocal 1.6.2 -*- Autoconf -*- + +# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +dnl rtems-top.m4,v 1.5 2002/07/31 14:40:48 ralf Exp + +dnl +dnl RTEMS_TOP($1) +dnl +dnl $1 .. relative path from this configure.in to the toplevel configure.in +dnl +AC_DEFUN(RTEMS_TOP, +[dnl +AC_REQUIRE([RTEMS_VERSIONING]) +AC_CHECK_PROGS(MAKE, gmake make) +AC_BEFORE([$0], [AC_CONFIG_AUX_DIR])dnl +AC_BEFORE([$0], [AM_INIT_AUTOMAKE])dnl + +AC_PREFIX_DEFAULT([/opt/rtems]) + +ENDIF=endif +AC_SUBST(ENDIF) + +RTEMS_TOPdir="$1"; +AC_SUBST(RTEMS_TOPdir) + +test -n "$with_target_subdir" || with_target_subdir="." + +if test "$with_target_subdir" = "." ; then +# Native +PROJECT_TOPdir="${with_project_root}${RTEMS_TOPdir}/\$(MULTIBUILDTOP)\$(top_builddir)" +else +# Cross +dots=`echo $with_target_subdir|\ +sed -e 's%^\./%%' -e 's%[[^/]]$%&/%' -e 's%[[^/]]*/%../%g'` +PROJECT_TOPdir="${dots}${with_project_root}${RTEMS_TOPdir}/\$(MULTIBUILDTOP)\$(top_builddir)" +fi +AC_SUBST(PROJECT_TOPdir) + +PROJECT_ROOT="${with_project_root}${RTEMS_TOPdir}/\$(MULTIBUILDTOP)\$(top_builddir)" +AC_SUBST(PROJECT_ROOT) + +AC_MSG_CHECKING([for RTEMS Version]) +AS_IF([test -r "${srcdir}/${RTEMS_TOPdir}/cpukit/aclocal/version.m4"], +[], +[AC_MSG_ERROR([Unable to find ${RTEMS_TOPdir}/cpukit/aclocal/version.m4])]) +AC_MSG_RESULT([_RTEMS_VERSION]) +])dnl + +AC_DEFUN([RTEMS_VERSIONING], +m4_define([_RTEMS_VERSION],[ss-20020528])) + +# Do all the work for Automake. -*- Autoconf -*- + +# This macro actually does too much some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 8 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +AC_PREREQ([2.52]) + +# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow +# the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], [AC_PACKAGE_TARNAME])dnl + AC_SUBST([VERSION], [AC_PACKAGE_VERSION])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG(AMTAR, tar) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl + +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_][CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_][CC], + defn([AC_PROG_][CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_][CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_][CXX], + defn([AC_PROG_][CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + +# Copyright 2002 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.6"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.6.2])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright 2001, 2002 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 2 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# +# Check to make sure that the build environment is sane. +# + +# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 3 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# -*- Autoconf -*- + + +# Copyright 1997, 1999, 2000, 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 3 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# AM_AUX_DIR_EXPAND + +# Copyright 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +# Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50]) + +AC_DEFUN([AM_AUX_DIR_EXPAND], [ +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. + +# Copyright 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# AM_PROG_INSTALL_STRIP + +# Copyright 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# serial 4 -*- Autoconf -*- + +# Copyright 1999, 2000, 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null +AC_SUBST([DEPDIR]) +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +#serial 2 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Copyright 2001 Free Software Foundation, Inc. -*- Autoconf -*- + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 2 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST(am__include) +AC_SUBST(am__quote) +AC_MSG_RESULT($_am_result) +rm -f confinc confmf +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright 1997, 2000, 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 5 + +AC_PREREQ(2.52) + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([conditional \"$1\" was never defined. +Usually this means the macro was only invoked conditionally.]) +fi])]) + +dnl +dnl canonical-target-name.m4,v 1.1 2002/06/17 08:52:47 ralf Exp +dnl + +dnl canonicalize target cpu +dnl NOTE: Most rtems targets do not fullfil autoconf's +dnl target naming conventions "processor-vendor-os" +dnl Therefore autoconf's AC_CANONICAL_TARGET will fail for them +dnl and we have to fix it for rtems ourselves + +AC_DEFUN(RTEMS_CANONICAL_TARGET_CPU, +[ +AC_CANONICAL_TARGET +AC_MSG_CHECKING(rtems target cpu) +case "${target}" in + # hpux unix port should go here + i[[34567]]86-*linux*) # unix "simulator" port + RTEMS_CPU=unix + ;; + i[[34567]]86-*freebsd*) # unix "simulator" port + RTEMS_CPU=unix + ;; + i[[34567]]86-pc-cygwin*) # Cygwin is just enough unix like :) + RTEMS_CPU=unix + ;; + no_cpu-*rtems*) + RTEMS_CPU=no_cpu + ;; + sparc-sun-solaris*) # unix "simulator" port + RTEMS_CPU=unix + ;; + *) + RTEMS_CPU=`echo $target | sed 's%^\([[^-]]*\)-\(.*\)$%\1%'` + ;; +esac +AC_SUBST(RTEMS_CPU) +AC_MSG_RESULT($RTEMS_CPU) +]) + +# Add --enable-maintainer-mode option to configure. +# From Jim Meyering + +# Copyright 1996, 1998, 2000, 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# serial 1 + +AC_DEFUN([AM_MAINTAINER_MODE], +[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode is disabled by default + AC_ARG_ENABLE(maintainer-mode, +[ --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + USE_MAINTAINER_MODE=$enableval, + USE_MAINTAINER_MODE=no) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST(MAINT)dnl +] +) + +dnl env-rtemscpu.m4,v 1.4 2002/08/06 07:31:26 ralf Exp + +AC_DEFUN(RTEMS_ENV_RTEMSCPU, +[AC_REQUIRE([RTEMS_ENABLE_MULTILIB]) + +if test x"$multilib" = x"yes"; then + AS_IF([test -n "$with_multisubdir"], + [MULTIBUILDTOP=`echo "/$with_multisubdir" | sed 's,/[[^\\/]]*,../,g'`]) + AC_SUBST(MULTIBUILDTOP) + + AS_IF([test -n "$with_multisubdir"], + [MULTISUBDIR="/$with_multisubdir"]) + AC_SUBST(MULTISUBDIR) + + GCC_SPECS="-isystem \$(PROJECT_INCLUDE)" + AC_SUBST(GCC_SPECS) + + PROJECT_INCLUDE="\$(PROJECT_ROOT)/lib/include" + AC_SUBST(PROJECT_INCLUDE) + + project_libdir="\$(PROJECT_ROOT)/lib" + AC_SUBST(project_libdir) + + RTEMS_ROOT="${PROJECT_ROOT}" + AC_SUBST(RTEMS_ROOT) + + includedir="\${exec_prefix}/lib/include" + libdir="${libdir}\$(MULTISUBDIR)" +else + RTEMS_ENV_RTEMSBSP + RTEMS_CHECK_CUSTOM_BSP(RTEMS_BSP) +fi +]) + +dnl This provides configure definitions used for multilib support + +dnl parts of these macros are derived from newlib-1.8.2's multilib support + +AC_DEFUN(RTEMS_ENABLE_MULTILIB, +[ +AC_ARG_ENABLE(multilib, +AC_HELP_STRING([--enable-multilib], +[build many library versions (default=no)]), +[case "${enableval}" in + yes) multilib=yes ;; + no) multilib=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;; + esac], [multilib=no])dnl + +AM_CONDITIONAL(MULTILIB,test x"${multilib}" = x"yes") +]) + +AC_DEFUN([RTEMS_ENABLE_MULTILIB_MASTER], +[ +AC_REQUIRE([RTEMS_ENABLE_MULTILIB]) + +dnl We may get other options which we don't document: +dnl --with-target-subdir, --with-multisrctop, --with-multisubdir + +if test "[$]{srcdir}" = "."; then + if test "[$]{with_target_subdir}" != "."; then + multilib_basedir="[$]{srcdir}/[$]{with_multisrctop}../ifelse([$2],,,[$2])" + else + multilib_basedir="[$]{srcdir}/[$]{with_multisrctop}ifelse([$2],,,[$2])" + fi +else + multilib_basedir="[$]{srcdir}/ifelse([$2],,,[$2])" +fi +AC_SUBST(multilib_basedir) + +if test "${multilib}" = "yes"; then + multilib_arg="--enable-multilib" +else + multilib_arg= +fi + +AC_OUTPUT_COMMANDS( +[case " $CONFIG_FILES " in + *" ]m4_if([$1],,Makefile,[$1])[ "*) + ac_file=]m4_if([$1],,Makefile,[$1])[ . ${multilib_basedir}/config-ml.in +esac], +[ + srcdir=${srcdir} + host=${host} + target=${target} + with_multisrctop="${with_multisrctop}" + with_target_subdir="${with_target_subdir}" + with_multisubdir="${with_multisubdir}" + ac_configure_args="${multilib_arg} ${ac_configure_args}" + CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + multilib_basedir=${multilib_basedir} + CC="${CC}"]) +]) + +dnl env-rtemsbsp.m4,v 1.3 2002/08/06 10:09:33 ralf Exp + +dnl Pass a single BSP via an environment variable +dnl used by per BSP configure scripts +AC_DEFUN(RTEMS_ENV_RTEMSBSP, +[dnl +AC_BEFORE([$0], [RTEMS_ENABLE_RTEMSBSP])dnl +AC_BEFORE([$0], [RTEMS_PROJECT_ROOT])dnl +AC_BEFORE([$0], [RTEMS_CHECK_CUSTOM_BSP])dnl + +AC_ARG_VAR([RTEMS_BSP],[RTEMS_BSP to build]) +AC_MSG_CHECKING([for RTEMS_BSP]) +AC_CACHE_VAL(rtems_cv_RTEMS_BSP, +[dnl + test -n "${RTEMS_BSP}" && rtems_cv_RTEMS_BSP="$RTEMS_BSP"; +])dnl +if test -z "$rtems_cv_RTEMS_BSP"; then + AC_MSG_ERROR([Missing RTEMS_BSP]) +fi +RTEMS_BSP="$rtems_cv_RTEMS_BSP" +AC_MSG_RESULT(${RTEMS_BSP}) +AC_SUBST(RTEMS_BSP) + +PROJECT_INCLUDE="\$(PROJECT_ROOT)/$RTEMS_BSP/lib/include" +AC_SUBST(PROJECT_INCLUDE) + +project_libdir="${PROJECT_ROOT}/$RTEMS_BSP/lib" +AC_SUBST(project_libdir) + +RTEMS_ROOT="$PROJECT_ROOT/c/$RTEMS_BSP" +AC_SUBST(RTEMS_ROOT) + +GCC_SPECS="-isystem \$(PROJECT_INCLUDE)" +AC_SUBST(GCC_SPECS) + +RTEMS_ENABLE_BARE +AC_SUBST(BARE_CPU_MODEL) +AC_SUBST(BARE_CPU_CFLAGS) + +AM_CONDITIONAL([MULTILIB],[false]) + +includedir="\${exec_prefix}/${RTEMS_BSP}/lib/include" +libdir="\${exec_prefix}/${RTEMS_BSP}/lib" +]) + +dnl enable-rtemsbsp.m4,v 1.1 2002/06/17 08:52:47 ralf Exp + +dnl Override the set of BSPs to be built. +dnl used by the toplevel configure script +dnl RTEMS_ENABLE_RTEMSBSP(rtems_bsp_list) +AC_DEFUN(RTEMS_ENABLE_RTEMSBSP, +[ +AC_BEFORE([$0], [RTEMS_ENV_RTEMSBSP])dnl +AC_ARG_ENABLE(rtemsbsp, +AC_HELP_STRING([--enable-rtemsbsp="bsp1 bsp2 .."], +[BSPs to include in build]), +[case "${enableval}" in + yes|no) AC_MSG_ERROR([missing argument to --enable-rtemsbsp=\"bsp1 bsp2\"]);; + *) $1=$enableval;; +esac],[$1=""]) +]) + +dnl check-bsps.m4,v 1.3 2002/07/17 22:28:20 ralf Exp + +AC_DEFUN(RTEMS_CHECK_CUSTOM_BSP, +[dnl +AC_REQUIRE([RTEMS_TOP]) + +AC_MSG_CHECKING([for make/custom/[$]$1.cfg]) +if test -r "$srcdir/$RTEMS_TOPdir/make/custom/[$]$1.cfg"; then + AC_MSG_RESULT([yes]) +else + AC_MSG_ERROR([no]) +fi +])dnl + +AC_DEFUN(RTEMS_ENABLE_BARE, +[ +AC_ARG_ENABLE(bare-cpu-cflags, +AC_HELP_STRING([--enable-bare-cpu-cflags],[specify a particular cpu cflag (bare bsp specific)]), +[case "${enableval}" in + no) BARE_CPU_CFLAGS="" ;; + *) BARE_CPU_CFLAGS="${enableval}" ;; +esac], +[BARE_CPU_CFLAGS=""]) + +AC_ARG_ENABLE(bare-cpu-model, +AC_HELP_STRING([--enable-bare-cpu-model],[specify a particular cpu model (bare bsp specific)]), +[case "${enableval}" in + no) BARE_CPU_MODEL="" ;; + *) BARE_CPU_MODEL="${enableval}" ;; +esac], +[BARE_CPU_MODEL=""]) +]) + + +dnl check-cpu.m4,v 1.3 2002/07/17 22:28:20 ralf Exp + +dnl check if RTEMS support a cpu +AC_DEFUN(RTEMS_CHECK_CPU, +[dnl +AC_REQUIRE([RTEMS_TOP]) +AC_REQUIRE([RTEMS_CANONICAL_TARGET_CPU]) + +# Is this a supported CPU? +AC_MSG_CHECKING([if cpu $RTEMS_CPU is supported]) +if test -d "$srcdir/$RTEMS_TOPdir/cpukit/score/cpu/$RTEMS_CPU"; then + AC_MSG_RESULT(yes) +else + AC_MSG_ERROR(no) +fi +])dnl + + +dnl canonical-host.m4,v 1.1 2002/06/17 08:52:47 ralf Exp + +AC_DEFUN(RTEMS_CANONICAL_HOST, +[dnl +AC_REQUIRE([AC_CANONICAL_HOST]) +RTEMS_HOST=$host_os +case "${target}" in + # hpux unix port should go here + i[[34567]]86-*linux*) # unix "simulator" port + RTEMS_HOST=Linux + ;; + i[[34567]]86-*freebsd*) # unix "simulator" port + RTEMS_HOST=FreeBSD + ;; + i[[34567]]86-pc-cygwin*) # Cygwin is just enough unix like :) + RTEMS_HOST=Cygwin + ;; + sparc-sun-solaris*) # unix "simulator" port + RTEMS_HOST=Solaris + ;; + *) + ;; +esac +AC_SUBST(RTEMS_HOST) +])dnl + +dnl +dnl prog-cc.m4,v 1.2 2002/07/01 09:20:43 ralf Exp +dnl +dnl Check for target gcc +dnl + +AC_DEFUN(RTEMS_PROG_CC, +[ +AC_BEFORE([$0], [AC_PROG_CPP])dnl +AC_BEFORE([$0], [AC_PROG_CC])dnl +AC_BEFORE([$0], [RTEMS_CANONICALIZE_TOOLS])dnl + +RTEMS_CHECK_TOOL(CC,gcc) +test -z "$CC" && \ + AC_MSG_ERROR([no acceptable cc found in \$PATH]) +AC_PROG_CC +AC_PROG_CPP + +AM_CONDITIONAL(RTEMS_USE_GCC,test x"$GCC" = x"yes") +]) + +AC_DEFUN(RTEMS_PROG_CC_FOR_TARGET, +[ +dnl check target cc +RTEMS_PROG_CC +dnl check if the compiler supports --specs +RTEMS_GCC_SPECS +dnl check if the target compiler may use --pipe +RTEMS_GCC_PIPE +test "$rtems_cv_gcc_pipe" = "yes" && CC="$CC --pipe" + +if test "$GCC" = yes; then +] +m4_if([$1],,[],[CPPFLAGS="$CPPFLAGS $1"]) +[ +CFLAGS="-g -Wall" +fi + +dnl FIXME: HACK for egcs/cygwin mixing '\\' and '/' in gcc -print-* +#case $build_os in +#*cygwin*) GCCSED="| sed 's%\\\\%/%g'" ;; +#*) ;; +#esac +AC_SUBST(GCCSED) +]) + +dnl +dnl canonicalize-tools.m4,v 1.3 2002/07/31 14:57:47 ralf Exp +dnl +dnl Set target tools +dnl + +AC_DEFUN(RTEMS_CANONICALIZE_TOOLS, +[AC_REQUIRE([RTEMS_PROG_CC])dnl + +dnl FIXME: What shall be done if these tools are not available? + RTEMS_CHECK_TOOL(AR,ar,no) + +dnl special treatment of ranlib + RTEMS_CHECK_TOOL(RANLIB,ranlib,:) +]) + +dnl check-tool.m4,v 1.1 2002/06/17 08:52:47 ralf Exp + +dnl RTEMS_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN(RTEMS_CHECK_TOOL, +[ + AS_IF([test "x$build_alias" != "x$host_alias"], + [rtems_tool_prefix=${ac_tool_prefix}]) + AC_CHECK_PROG($1, ${rtems_tool_prefix}$2, ${rtems_tool_prefix}$2, $3, $4) +]) + +dnl +dnl gcc-specs.m4,v 1.1 2002/06/17 08:52:47 ralf Exp +dnl +dnl Check whether the target compiler accepts -specs +dnl + +AC_DEFUN(RTEMS_GCC_SPECS, +[AC_REQUIRE([RTEMS_PROG_CC]) +AC_CACHE_CHECK(whether $CC accepts -specs,rtems_cv_gcc_specs, +[ +rtems_cv_gcc_specs=no +if test x"$GCC" = x"yes"; then + touch confspec + echo 'void f(){}' >conftest.c + if test -z "`${CC} -specs confspec -c conftest.c 2>&1`";then + rtems_cv_gcc_specs=yes + fi +fi +rm -f confspec conftest* +])]) + +dnl +dnl gcc-pipe.m4,v 1.1 2002/06/17 08:52:47 ralf Exp +dnl +dnl Check whether the target compiler accepts -pipe +dnl + +AC_DEFUN(RTEMS_GCC_PIPE, +[AC_REQUIRE([RTEMS_PROG_CC]) +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_CACHE_CHECK(whether $CC accepts --pipe,rtems_cv_gcc_pipe, +[ +rtems_cv_gcc_pipe=no +if test x"$GCC" = x"yes"; then + echo 'void f(){}' >conftest.c + if test -z "`${CC} --pipe -c conftest.c 2>&1`";then + rtems_cv_gcc_pipe=yes + fi + rm -f conftest* +fi +]) +]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*- + +# Copyright 1996, 1997, 2000, 2001 Free Software Foundation, Inc. + +# This program 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. + +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +AC_PREREQ([2.52]) + +# serial 6 + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. We must strip everything past the first ":", +# and everything past the last "/". + +# _AM_DIRNAME(PATH) +# ----------------- +# Like AS_DIRNAME, only do it during macro expansion +AC_DEFUN([_AM_DIRNAME], + [m4_if(regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, + m4_if(regexp([$1], [^//\([^/]\|$\)]), -1, + m4_if(regexp([$1], [^/.*]), -1, + [.], + patsubst([$1], [^\(/\).*], [\1])), + patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), + patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl +])# _AM_DIRNAME + + +# The stamp files are numbered to have different names. +# We could number them on a directory basis, but that's additional +# complications, let's have a unique counter. +m4_define([_AM_STAMP_Count], [0]) + + +# _AM_STAMP(HEADER) +# ----------------- +# The name of the stamp file for HEADER. +AC_DEFUN([_AM_STAMP], +[m4_define([_AM_STAMP_Count], m4_incr(_AM_STAMP_Count))dnl +AS_ESCAPE(_AM_DIRNAME(patsubst([$1], + [:.*])))/stamp-h[]_AM_STAMP_Count]) + + +# _AM_CONFIG_HEADER(HEADER[:SOURCES], COMMANDS, INIT-COMMANDS) +# ------------------------------------------------------------ +# We used to try to get a real timestamp in stamp-h. But the fear is that +# that will cause unnecessary cvs conflicts. +AC_DEFUN([_AM_CONFIG_HEADER], +[# Add the stamp file to the list of files AC keeps track of, +# along with our hook. +AC_CONFIG_HEADERS([$1], + [# update the timestamp +echo 'timestamp for $1' >"_AM_STAMP([$1])" +$2], + [$3]) +])# _AM_CONFIG_HEADER + + +# AM_CONFIG_HEADER(HEADER[:SOURCES]..., COMMANDS, INIT-COMMANDS) +# -------------------------------------------------------------- +AC_DEFUN([AM_CONFIG_HEADER], +[AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])]) +])# AM_CONFIG_HEADER + Index: . =================================================================== --- . (nonexistent) +++ . (revision 1765)
. Property changes : Added: svn:ignore ## -0,0 +1,16 ## +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +config.cache +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +missing +mkinstalldirs +config.h* +stamp-h*

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.