Exemplo n.º 1
0
/*
 * Open function for PFAT filesystems.
 */
static int PFAT_Open(struct Mount_Point *mountPoint, const char *path, int mode, struct File **pFile)
{
    int rc = 0;
    struct PFAT_Instance *instance = (struct PFAT_Instance*) mountPoint->fsData;
    directoryEntry *entry;
    struct PFAT_File *pfatFile = 0;
    struct File *file = 0;
    int i = 0;

    /* Reject attempts to create or write */
    if ((mode & (O_WRITE | O_CREATE)) != 0)
	return EACCESS;

    /* Look up the directory entry */
    entry = PFAT_Lookup(instance, path);
    if (entry == 0)
	return ENOTFOUND;

    /* Make sure the entry is not a directory. */
    if (entry->directory)
	return EACCESS;

    /* Get PFAT_File object */
    pfatFile = Get_PFAT_File(instance, entry);
    if (pfatFile == 0)
	goto done;

    /* Create the file object. */
    file = Allocate_File(&s_pfatFileOps, 0, entry->fileSize, pfatFile, mode, mountPoint);
    if (file == 0) {
	rc = ENOMEM;
	goto done;
    }

    /* Success! */
    *pFile = file;

    // Error: I have to fix this to let pfat work with the standard syscalls;
	if (g_currentThread->userContext != 0)
	{
			for(i = 0; i < GOSFS_NUM_DIR_ENTRY; i++)
			{ if(g_currentThread->userContext->fileList[i] == 0) break; }
			g_currentThread->userContext->fileList[i] = file;
			rc = i;
			Debug("gosfs open rc:%d\n", rc);
			g_currentThread->userContext->fileCount++;
	}
		

done:
    return rc;
}
Exemplo n.º 2
0
/*
 * Open function for PFAT filesystems.
 */
static int PFAT_Open(struct Mount_Point *mountPoint, const char *path, int mode, struct File **pFile)
{
    int rc = 0;
    struct PFAT_Instance *instance = (struct PFAT_Instance*) mountPoint->fsData;
    directoryEntry *entry;
    struct PFAT_File *pfatFile = 0;
    struct File *file = 0;

    /* Reject attempts to create or write */
    if ((mode & (O_WRITE | O_CREATE)) != 0)
	return EACCESS;

    /* Look up the directory entry */
    entry = PFAT_Lookup(instance, path);
    if (entry == 0)
	return ENOTFOUND;

    /* Make sure the entry is not a directory. */
    if (entry->directory)
	return EACCESS;

    /* Get PFAT_File object */
    pfatFile = Get_PFAT_File(instance, entry);
    if (pfatFile == 0)
	goto done;

    /* Create the file object. */
    file = Allocate_File(&s_pfatFileOps, 0, entry->fileSize, pfatFile, 0, 0);
    if (file == 0) {
	rc = ENOMEM;
	goto done;
    }

    /* Success! */
    *pFile = file;

done:
    return rc;
}