client/src/unifycr.c
int unifycr_fid_create_file(const char * path)
{
    int fid = unifycr_fid_alloc();
    if (fid < 0)  {
        /* was there an error? if so, return it */
        errno = ENOSPC;
        return fid;
    }

    /* mark this slot as in use and copy the filename */
    unifycr_filelist[fid].in_use = 1;
    /* TODO: check path length to see if it is < 128 bytes
     * and return appropriate error if it is greater
     */
    strcpy((void *)&unifycr_filelist[fid].filename, path);
    debug("Filename %s got unifycr fd %d\n",unifycr_filelist[fid].filename,fid);

    /* initialize meta data */
    unifycr_filemeta_t* meta = unifycr_get_meta_from_fid(fid);
    meta->size    = 0;
    meta->chunks  = 0;
    meta->is_dir  = 0;
		meta->real_size = 0;
    meta->storage = FILE_STORAGE_NULL;
    meta->flock_status = UNLOCKED;
    /* PTHREAD_PROCESS_SHARED allows Process-Shared Synchronization*/
    pthread_spin_init(&meta->fspinlock, PTHREAD_PROCESS_SHARED);

    return fid;
}
/* add a new file and initialize metadata
 * returns the new fid, or negative value on error */
add a new file and initialize metadata
returns the new fid, or negative value on error
add a new file and initialize metadata returns the new fid or negative value on error
int unifycr_fid_create_file(const char * path)
{
    int fid = unifycr_fid_alloc();
    if (fid < 0)  {
        errno = ENOSPC;
        return fid;
    }
    unifycr_filelist[fid].in_use = 1;
    strcpy((void *)&unifycr_filelist[fid].filename, path);
    debug("Filename %s got unifycr fd %d\n",unifycr_filelist[fid].filename,fid);
    unifycr_filemeta_t* meta = unifycr_get_meta_from_fid(fid);
    meta->size    = 0;
    meta->chunks  = 0;
    meta->is_dir  = 0;
		meta->real_size = 0;
    meta->storage = FILE_STORAGE_NULL;
    meta->flock_status = UNLOCKED;
    pthread_spin_init(&meta->fspinlock, PTHREAD_PROCESS_SHARED);
    return fid;
}
int unifycr_fid_create_file ( const char * path ) { int fid = unifycr_fid_alloc ( ) ; if ( fid < 0 ) { errno = ENOSPC ; return fid ; } unifycr_filelist [ fid ] . in_use = 1 ; strcpy ( ( void * ) & unifycr_filelist [ fid ] . filename , path ) ; debug ( " \n " , unifycr_filelist [ fid ] . filename , fid ) ; unifycr_filemeta_t * meta = unifycr_get_meta_from_fid ( fid ) ; meta -> size = 0 ; meta -> chunks = 0 ; meta -> is_dir = 0 ; meta -> real_size = 0 ; meta -> storage = FILE_STORAGE_NULL ; meta -> flock_status = UNLOCKED ; pthread_spin_init ( & meta -> fspinlock , PTHREAD_PROCESS_SHARED ) ; return fid ; }
add a new file and initialize metadata
 returns the new fid, or negative value on error
add a new file and initialize metadata returns the new fid or negative value on error
/* was there an error? if so, return it */ /* mark this slot as in use and copy the filename */ /* TODO: check path length to see if it is < 128 bytes
     * and return appropriate error if it is greater
     */ /* initialize meta data */ /* PTHREAD_PROCESS_SHARED allows Process-Shared Synchronization*/