Changeset 623 for trunk/libs/mini-libc


Ignore:
Timestamp:
Mar 6, 2019, 4:37:15 PM (5 years ago)
Author:
alain
Message:

Introduce three new types of vsegs (KCODE,KDATA,KDEV)
to map the kernel vsegs in the process VSL and GPT.
This now used by both the TSAR and the I86 architectures.

Location:
trunk/libs/mini-libc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/mini-libc/mman.h

    r597 r623  
    3838 * virtual space, as defined by the arguments.
    3939 *****************************************************************************************
    40  * @ addr    : requested address in virtual space / unused : should be NULL.
     40 * @ addr    : requested address in virtual space / unsupported : should be NULL.
    4141 * @ length  : requested number of bytes.
    4242 * @ prot    : access mode bit vector (PROT_EXEC / PROT_READ / PROT_WRITE)
    43  * @ flags   : bit_vector (MAP_FILE / MAP_ANON / MAPREMOTE / MAP_PRIVATE / MAP_SHARED)
     43 * @ flags   : bit_vector (MAP_FILE / MAP_ANON / MAP_REMOTE / MAP_PRIVATE / MAP_SHARED)
    4444 * @ fdid    : file descriptor index (if MAP_FILE).
    4545 * @ offset  : offset in file (if MAP_FILE).
  • trunk/libs/mini-libc/stdio.c

    r610 r623  
    3535////////////////////////////////////////////////////////////////////////////////////////
    3636
     37// This user space array registers all FILE descriptors open by a given process
    3738FILE open_file_array[MAX_OPEN_FILE_PER_PROCESS];  // array of open files structures
    3839
     
    340341    if( mode != NULL )
    341342    {
    342         printf("\n[ERROR] in %s : the mode argument must be NULL\n", __FUNCTION__ );
     343        printf("\n[%s] error : the mode argument must be NULL\n", __FUNCTION__ );
    343344        return NULL;
    344345    }
     
    351352    if( fd < 0 )
    352353    {
    353         printf("\n[ERROR] in %s : file %s not found\n", __FUNCTION__ , pathname );
     354        printf("\n[%s] error : file <%s> not found\n", __FUNCTION__ , pathname );
    354355        return NULL;
    355356    }
    356357    if( fd > MAX_OPEN_FILE_PER_PROCESS )
    357358    {
    358         printf("\n[ERROR] in %s : not enough space for file %s\n", __FUNCTION__ , pathname );
     359        printf("\n[%s] error : not enough space for file <%s>\n", __FUNCTION__ , pathname );
    359360        return NULL;
    360361    }
     
    365366
    366367    return &open_file_array[fd];
     368
    367369}  // end fopen()
    368370
     
    376378    int fd = stream->fd;
    377379
    378     // remove stream from open_file_array[]
     380    // remove stream from user open_file_array[]
    379381    open_file_array[fd].key = 0;
    380382   
    381     return close( fd );
     383    // close the kernel file descriptor
     384    if( close( fd ) )
     385    {
     386        printf("\n[%s] error : cannot close file %d\n", __FUNCTION__ , fd );
     387        return -1;
     388    }
     389
     390    return 0;
     391
    382392}  // end fclose()
    383393
     
    407417        // get file descriptor from file pointer
    408418        fd = stream->fd;
    409        
     419
     420        // set terminating NUL
    410421        string[count] = 0;
    411422
     423printf("\n[%s] fd = %d for string :\n", __FUNCTION__, fd, string );
     424
    412425        return write( fd , &string , count );
    413426    }
  • trunk/libs/mini-libc/stdio.h

    r610 r623  
    4040 ********************************************************************************************/
    4141
    42 typedef struct file_s
     42typedef struct stream_s
    4343{
    44     int fd;
    45     int key;
     44    int fd;          // index in both kernel fd_array[], and user open_file_array[]
     45    int key;         // entry valid in open_file_array[] when (key == VALID_OPEN_FILE)
    4646}
    4747FILE;
Note: See TracChangeset for help on using the changeset viewer.