Remove vcfiled and vcfilesys.

Both these libraries/apps were related to the VPU accessing the
host file system over VCHI. This has never been used on the Pi,
and is creating build warnings with the latest versions of gcc.
Remove them from the source tree.
This commit is contained in:
Dave Stevenson
2020-07-27 17:57:22 +01:00
committed by Phil Elwell
parent 188d3bfe4a
commit fdc2102ccf
10 changed files with 3 additions and 4401 deletions

View File

@@ -8,8 +8,8 @@
add_definitions(-fno-strict-aliasing)
add_library(vchostif
${VMCS_TARGET}/vcfilesys.c ${VMCS_TARGET}/vcmisc.c
vc_vchi_gencmd.c vc_vchi_filesys.c vc_vchi_gpuserv.c
${VMCS_TARGET}/vcmisc.c
vc_vchi_gencmd.c vc_vchi_gpuserv.c
vc_vchi_tvservice.c vc_vchi_cecservice.c
vc_vchi_dispmanx.c vc_service_common.c)
# ${VMCS_TARGET}/vmcs_main.c

View File

@@ -1,169 +0,0 @@
/*
Copyright (c) 2012, Broadcom Europe Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vcfiled_check.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <syslog.h>
#include <sys/stat.h>
#include <fcntl.h>
int vcfiled_lock(const char *lockfile, VCFILED_LOGMSG_T logmsg)
{
int rc, fd;
char pidbuf[32];
char *lockdir = strdup(lockfile);
char *sep = strrchr(lockdir, '/');
int ret = -1;
if (!sep)
{
free(lockdir);
return -1;
}
*sep = '\0';
if (mkdir(lockdir, S_IRWXU | S_IRGRP|S_IXGRP) < 0)
{
if (errno != EEXIST)
{
logmsg(LOG_CRIT, "could not create %s:%s\n", lockdir,strerror(errno));
goto finish;
}
}
fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL, 0640);
if (fd<0)
{
if (errno != EEXIST)
{
logmsg(LOG_CRIT, "could not create lockfile %s:%s\n", lockfile, strerror(errno));
goto finish;
}
else
{
// it already exists - reopen it and try to lock it
fd = open(lockfile, O_RDWR);
if (fd<0)
{
logmsg(LOG_CRIT, "could not re-open lockfile %s:%s\n", lockfile, strerror(errno));
goto finish;
}
}
}
// at this point, we have opened the file, and can use discretionary locking,
// which should work even over NFS
struct flock flock;
memset(&flock, 0, sizeof(flock));
flock.l_type = F_WRLCK;
flock.l_whence = SEEK_SET;
flock.l_start = 0;
flock.l_len = 1;
if (fcntl(fd, F_SETLK, &flock) < 0)
{
// if we failed to lock, then it might mean we're already running, or
// something else bad.
if (errno == EACCES || errno == EAGAIN)
{
// already running
int pid = 0, rc = read(fd, pidbuf, sizeof(pidbuf));
if (rc)
pid = atoi(pidbuf);
logmsg(LOG_CRIT, "already running at pid %d\n", pid);
close(fd);
goto finish;
}
else
{
logmsg(LOG_CRIT, "could not lock %s:%s\n", lockfile, strerror(errno));
close(fd);
goto finish;
}
}
snprintf(pidbuf,sizeof(pidbuf),"%d", getpid());
rc = write(fd, pidbuf, strlen(pidbuf)+1);
if (rc<0)
{
logmsg(LOG_CRIT, "could not write pid:%s\n", strerror(errno));
goto finish;
}
/* do not close the file, as that will release the lock - it will
* will close automatically when the program exits.
*/
ret = 0;
finish:
free(lockdir);
/* coverity[leaked_handle] - fd left open on purpose */
return ret;
}
int vcfiled_is_running(const char *filename)
{
int ret;
int fd = open(filename, O_RDONLY);
if (fd < 0)
{
// file not there, so filed not running
ret = 0;
}
else
{
struct flock flock;
memset(&flock, 0, sizeof(flock));
flock.l_type = F_WRLCK;
flock.l_whence = SEEK_SET;
flock.l_start = 0;
flock.l_len = 1;
int rc = fcntl(fd, F_GETLK, &flock);
if (rc != 0)
{
/* could not access lock info */
printf("%s: Could not access lockfile %s: %s\n",
"vmcs_main", filename, strerror(errno));
ret = 0;
}
else if (flock.l_pid == 0)
{
/* file is unlocked, so filed not running */
ret = 0;
}
else
{
/* file is locked, so filed is running */
ret = 1;
}
}
/* coverity[leaked_handle] - fd left open on purpose */
return ret;
}

View File

@@ -1,48 +0,0 @@
/*
Copyright (c) 2012, Broadcom Europe Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef VCFILED_CHECK_H
#define VCFILED_CHECK_H
#ifdef ANDROID
#define VCFILED_LOCKDIR "/tmp/vcfiled/vcfiled.pid"
#define VCFILED_LOCKFILE "/tmp/vcfiled"
#endif
#ifndef VCFILED_LOCKFILE
#define VCFILED_LOCKDIR "/var/run/vcfiled"
#define VCFILED_LOCKFILE VCFILED_LOCKDIR "/vcfiled"
#endif
typedef void (*VCFILED_LOGMSG_T)(int level, const char *fmt, ...);
int vcfiled_lock(const char *filename, VCFILED_LOGMSG_T logmsg);
extern int vcfiled_is_running(const char *lockfile);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,119 +0,0 @@
/*
Copyright (c) 2012, Broadcom Europe Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// File service command enumeration.
#ifndef VC_FILESERVICE_DEFS_H
#define VC_FILESERVICE_DEFS_H
#define VC_FILESERV_VER 1
/* Definitions (not used by API) */
#define FS_MAX_DATA 8192 //4096
/* Protocol (not used by API) version 1.2 */
enum {
/* Over-the-wire file open flags */
VC_O_RDONLY = 0x01,
VC_O_WRONLY = 0x02,
VC_O_RDWR = 0x04,
VC_O_APPEND = 0x08,
VC_O_CREAT = 0x10,
VC_O_TRUNC = 0x20,
VC_O_EXCL = 0x40,
/* Request Commands (VC->Host->VC) */
/* These commands don't require a pathname */
VC_FILESYS_RESET = 64,
VC_FILESYS_CLOSE = 65,
VC_FILESYS_CLOSEDIR = 66,
VC_FILESYS_LSEEK = 67,
VC_FILESYS_READ = 68,
VC_FILESYS_READDIR = 69,
VC_FILESYS_SETEND = 70,
VC_FILESYS_WRITE = 71,
/* These commands require a pathname */
VC_FILESYS_FORMAT = 72,
VC_FILESYS_FREESPACE = 73,
VC_FILESYS_GET_ATTR = 74,
VC_FILESYS_MKDIR = 75,
VC_FILESYS_OPEN = 76,
VC_FILESYS_OPENDIR = 77,
VC_FILESYS_REMOVE = 78,
VC_FILESYS_RENAME = 79,
VC_FILESYS_SET_ATTR = 80,
VC_FILESYS_SCANDISK = 81,
VC_FILESYS_TOTALSPACE = 82,
VC_FILESYS_DISKWRITABLE=83,
VC_FILESYS_OPEN_DISK_RAW = 84,
VC_FILESYS_CLOSE_DISK_RAW = 85,
VC_FILESYS_NUMSECTORS = 86,
VC_FILESYS_READ_SECTORS = 87,
VC_FILESYS_WRITE_SECTORS = 88,
VC_FILESYS_MOUNT = 89,
VC_FILESYS_UMOUNT = 90,
VC_FILESYS_FSTYPE = 91,
VC_FILESYS_READ_DIRECT = 92,
VC_FILESYS_LSEEK64 = 93,
VC_FILESYS_FREESPACE64 = 94,
VC_FILESYS_TOTALSPACE64= 95,
VC_FILESYS_OPEN_DISK = 96,
VC_FILESYS_CLOSE_DISK = 97,
/* extra simple functions for mass storage testing */
VC_FILESYS_READ_SECTOR = 98, //1sect
VC_FILESYS_STREAM_SECTOR_BEGIN = 99,
VC_FILESYS_STREAM_SECTOR_END = 100,
VC_FILESYS_WRITE_SECTOR = 101,
VC_FILESYS_FSTAT = 102,
VC_FILESYS_DIRSIZE = 103,
VC_FILESYS_LIST_DIRS = 104,
VC_FILESYS_LIST_FILES = 105,
VC_FILESYS_NUM_DIRS = 106,
VC_FILESYS_NUM_FILES = 107,
VC_FILESYS_MAX_FILESIZE = 108,
VC_FILESYS_CHKDSK = 109,
};
/* Parameters for lseek */
#define VC_FILESYS_SEEK_SET 0 /* Set file pointer to "offset" */
#define VC_FILESYS_SEEK_CUR 1 /* Set file pointer to current plus "offset" */
#define VC_FILESYS_SEEK_END 2 /* Set file pointer to EOF plus "offset" */
/* Return values of vc_filesys_type */
#define VC_FILESYS_FS_UNKNOWN 0
#define VC_FILESYS_FS_FAT12 1
#define VC_FILESYS_FS_FAT16 2
#define VC_FILESYS_FS_FAT32 3
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,184 +0,0 @@
/*
Copyright (c) 2012, Broadcom Europe Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef VC_VCHI_VCFILESYS_H_
#define VC_VCHI_VCFILESYS_H_
#include "vchost_platform_config.h"
#include "vcfilesys_defs.h"
#include "vc_fileservice_defs.h"
#include "interface/vchi/vchi.h"
#ifndef _DIRENT_H // This should really be in a dirent.h header to avoid conflicts
typedef struct DIR_tag DIR;
#endif // ifndef _DIRENT_H
typedef struct {
int64_t st_size; /* total size, in bytes (off_t)*/
uint32_t st_modtime; /* time of last modification (time_t)*/
} FSTAT_T;
VCHPRE_ int VCHPOST_ vc_vchi_filesys_init (VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections );
// Stop it to prevent the functions from trying to use it.
VCHPRE_ void VCHPOST_ vc_filesys_stop(void);
// Return the service number (-1 if not running).
VCHPRE_ int VCHPOST_ vc_filesys_inum(void);
// Low level file system functions equivalent to close(), lseek(), open(), read() and write()
VCHPRE_ int VCHPOST_ vc_filesys_close(int fildes);
VCHPRE_ long VCHPOST_ vc_filesys_lseek(int fildes, long offset, int whence);
VCHPRE_ int64_t VCHPOST_ vc_filesys_lseek64(int fildes, int64_t offset, int whence);
VCHPRE_ int VCHPOST_ vc_filesys_open(const char *path, int vc_oflag);
VCHPRE_ int VCHPOST_ vc_filesys_read(int fildes, void *buf, unsigned int nbyte);
VCHPRE_ int VCHPOST_ vc_filesys_write(int fildes, const void *buf, unsigned int nbyte);
VCHPRE_ int VCHPOST_ vc_filesys_mount(const char *device, const char *mountpoint, const char *options);
VCHPRE_ int VCHPOST_ vc_filesys_umount(const char *mountpoint);
// Ends a directory listing iteration
VCHPRE_ int VCHPOST_ vc_filesys_closedir(void *dhandle);
// Formats the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_filesys_format(const char *path);
// Returns the amount of free space on the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_filesys_freespace(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_filesys_freespace64(const char *path);
// Gets the attributes of the named file
VCHPRE_ int VCHPOST_ vc_filesys_get_attr(const char *path, fattributes_t *attr);
// Get the file stat info struct for the specified file.
VCHPRE_ int VCHPOST_ vc_filesys_fstat(int filedes, FSTAT_T *buf);
// Creates a new directory
VCHPRE_ int VCHPOST_ vc_filesys_mkdir(const char *path);
// Starts a directory listing iteration
VCHPRE_ void * VCHPOST_ vc_filesys_opendir(const char *dirname);
// Directory listing iterator
VCHPRE_ struct dirent * VCHPOST_ vc_filesys_readdir_r(void *dhandle, struct dirent *result);
// Get the sum of the filesizes, and the number of files under the specified directory path.
VCHPRE_ int64_t VCHPOST_ vc_filesys_dirsize(const char *path, uint32_t *num_files, uint32_t *num_dirs);
// Deletes a file or (empty) directory
VCHPRE_ int VCHPOST_ vc_filesys_remove(const char *path);
// Renames a file, provided the new name is on the same file system as the old
VCHPRE_ int VCHPOST_ vc_filesys_rename(const char *oldfile, const char *newfile);
// Resets the co-processor side file system
VCHPRE_ int VCHPOST_ vc_filesys_reset(void);
// Sets the attributes of the named file
VCHPRE_ int VCHPOST_ vc_filesys_set_attr(const char *path, fattributes_t attr);
// Truncates a file at its current position
VCHPRE_ int VCHPOST_ vc_filesys_setend(int fildes);
// Returns the size of a file in bytes.
VCHPRE_ int VCHPOST_ vc_filesys_size(const char *path);
// Checks whether there are any messages in the incoming message fifo and responds to any such messages
VCHPRE_ int VCHPOST_ vc_filesys_poll_message_fifo(void);
// Return the event used to wait for reads.
VCHPRE_ void * VCHPOST_ vc_filesys_read_event(void);
// Sends a command for VC01 to reset the file system
VCHPRE_ void VCHPOST_ vc_filesys_sendreset(void);
// Return the error code of the last file system error
VCHPRE_ int VCHPOST_ vc_filesys_errno(void);
// Invalidates any cluster chains in the FAT that are not referenced in any directory structures
VCHPRE_ void VCHPOST_ vc_filesys_scandisk(const char *path);
// Checks whether or not a FAT filesystem is corrupt or not. If fix_errors is TRUE behaves exactly as vc_filesys_scandisk.
VCHPRE_ int VCHPOST_ vc_filesys_chkdsk(const char *path, int fix_errors);
// Return whether a disk is writeable or not.
VCHPRE_ int VCHPOST_ vc_filesys_diskwritable(const char *path);
// Return file system type of a disk.
VCHPRE_ int VCHPOST_ vc_filesys_fstype(const char *path);
// Returns the toatl amount of space on the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_filesys_totalspace(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_filesys_totalspace64(const char *path);
// Open disk for block level access
VCHPRE_ int VCHPOST_ vc_filesys_open_disk_raw(const char *path);
// Close disk from block level access mode
VCHPRE_ int VCHPOST_ vc_filesys_close_disk_raw(const char *path);
// Open disk for normal access
VCHPRE_ int VCHPOST_ vc_filesys_open_disk(const char *path);
// Close disk for normal access
VCHPRE_ int VCHPOST_ vc_filesys_close_disk(const char *path);
// Return number of sectors.
VCHPRE_ int VCHPOST_ vc_filesys_numsectors(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_filesys_numsectors64(const char *path);
// Read/Write sectors
VCHPRE_ int VCHPOST_ vc_filesys_read_sectors(const char *path, uint32_t sector_num, char *sectors, uint32_t num_sectors, uint32_t *sectors_read);
VCHPRE_ int VCHPOST_ vc_filesys_write_sectors(const char *path, uint32_t sector_num, char *sectors, uint32_t num_sectors, uint32_t *sectors_written);
// Begin reading sectors from VideoCore.
VCHPRE_ int VCHPOST_ vc_filesys_read_sectors_begin(const char *path, uint32_t sector, uint32_t count);
// Read the next sector.
VCHPRE_ int VCHPOST_ vc_filesys_read_sector(char *buf);
// End streaming sectors.
VCHPRE_ int VCHPOST_ vc_filesys_read_sectors_end(uint32_t *sectors_read);
// Begin writing sectors from VideoCore.
VCHPRE_ int VCHPOST_ vc_filesys_write_sectors_begin(const char *path, uint32_t sector, uint32_t count);
// Write the next sector.
VCHPRE_ int VCHPOST_ vc_filesys_write_sector(const char *buf);
// End streaming sectors.
VCHPRE_ int VCHPOST_ vc_filesys_write_sectors_end(uint32_t *sectors_written);
#endif //VCFILESYS_H_

View File

@@ -1,166 +0,0 @@
/*
Copyright (c) 2012, Broadcom Europe Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vchost_platform_config.h"
#include "vcfilesys_defs.h"
#include "vc_fileservice_defs.h"
#ifndef VCFILESYS_H_
#define VCFILESYS_H_
#ifndef FILESYS_DIR_DEFINED
#define FILESYS_DIR_DEFINED
typedef struct DIR_tag DIR;
#endif
// Initialises the file system for use
VCHPRE_ int VCHPOST_ vc_filesys_init (void);
// Stop it to prevent the functions from trying to use it.
VCHPRE_ void VCHPOST_ vc_filesys_stop(void);
// Return the service number (-1 if not running).
VCHPRE_ int VCHPOST_ vc_filesys_inum(void);
// Low level file system functions equivalent to close(), lseek(), open(), read() and write()
VCHPRE_ int VCHPOST_ vc_filesys_close(int fildes);
VCHPRE_ long VCHPOST_ vc_filesys_lseek(int fildes, long offset, int whence);
VCHPRE_ int64_t VCHPOST_ vc_filesys_lseek64(int fildes, int64_t offset, int whence);
VCHPRE_ int VCHPOST_ vc_filesys_open(const char *path, int vc_oflag);
VCHPRE_ int VCHPOST_ vc_filesys_read(int fildes, void *buf, unsigned int nbyte);
VCHPRE_ int VCHPOST_ vc_filesys_write(int fildes, const void *buf, unsigned int nbyte);
VCHPRE_ int VCHPOST_ vc_filesys_mount(const char *device, const char *mountpoint, const char *options);
VCHPRE_ int VCHPOST_ vc_filesys_umount(const char *mountpoint);
// Ends a directory listing iteration
VCHPRE_ int VCHPOST_ vc_filesys_closedir(void *dhandle);
// Formats the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_filesys_format(const char *path);
// Returns the amount of free space on the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_filesys_freespace(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_filesys_freespace64(const char *path);
// Gets the attributes of the named file
VCHPRE_ int VCHPOST_ vc_filesys_get_attr(const char *path, fattributes_t *attr);
// Creates a new directory
VCHPRE_ int VCHPOST_ vc_filesys_mkdir(const char *path);
// Starts a directory listing iteration
VCHPRE_ void * VCHPOST_ vc_filesys_opendir(const char *dirname);
// Directory listing iterator
VCHPRE_ struct dirent * VCHPOST_ vc_filesys_readdir_r(void *dhandle, struct dirent *result);
// Deletes a file or (empty) directory
VCHPRE_ int VCHPOST_ vc_filesys_remove(const char *path);
// Renames a file, provided the new name is on the same file system as the old
VCHPRE_ int VCHPOST_ vc_filesys_rename(const char *oldfile, const char *newfile);
// Resets the co-processor side file system
VCHPRE_ int VCHPOST_ vc_filesys_reset(void);
// Sets the attributes of the named file
VCHPRE_ int VCHPOST_ vc_filesys_set_attr(const char *path, fattributes_t attr);
// Truncates a file at its current position
VCHPRE_ int VCHPOST_ vc_filesys_setend(int fildes);
// Checks whether there are any messages in the incoming message fifo and responds to any such messages
VCHPRE_ int VCHPOST_ vc_filesys_poll_message_fifo(void);
// Return the event used to wait for reads.
VCHPRE_ void * VCHPOST_ vc_filesys_read_event(void);
// Sends a command for VC01 to reset the file system
VCHPRE_ void VCHPOST_ vc_filesys_sendreset(void);
// Return the error code of the last file system error
VCHPRE_ int VCHPOST_ vc_filesys_errno(void);
// Invalidates any cluster chains in the FAT that are not referenced in any directory structures
VCHPRE_ void VCHPOST_ vc_filesys_scandisk(const char *path);
// Checks whether or not a FAT filesystem is corrupt or not. If fix_errors is TRUE behaves exactly as vc_filesys_scandisk.
VCHPRE_ int VCHPOST_ vc_filesys_chkdsk(const char *path, int fix_errors);
// Return whether a disk is writeable or not.
VCHPRE_ int VCHPOST_ vc_filesys_diskwritable(const char *path);
// Return file system type of a disk.
VCHPRE_ int VCHPOST_ vc_filesys_fstype(const char *path);
// Returns the toatl amount of space on the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_filesys_totalspace(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_filesys_totalspace64(const char *path);
// Open disk for block level access
VCHPRE_ int VCHPOST_ vc_filesys_open_disk_raw(const char *path);
// Close disk from block level access mode
VCHPRE_ int VCHPOST_ vc_filesys_close_disk_raw(const char *path);
// Open disk for normal access
VCHPRE_ int VCHPOST_ vc_filesys_open_disk(const char *path);
// Close disk for normal access
VCHPRE_ int VCHPOST_ vc_filesys_close_disk(const char *path);
// Return number of sectors.
VCHPRE_ int VCHPOST_ vc_filesys_numsectors(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_filesys_numsectors64(const char *path);
// Begin reading sectors from VideoCore.
VCHPRE_ int VCHPOST_ vc_filesys_read_sectors_begin(const char *path, uint32_t sector, uint32_t count);
// Read the next sector.
VCHPRE_ int VCHPOST_ vc_filesys_read_sector(char *buf);
// End streaming sectors.
VCHPRE_ int VCHPOST_ vc_filesys_read_sectors_end(uint32_t *sectors_read);
// Begin writing sectors from VideoCore.
VCHPRE_ int VCHPOST_ vc_filesys_write_sectors_begin(const char *path, uint32_t sector, uint32_t count);
// Write the next sector.
VCHPRE_ int VCHPOST_ vc_filesys_write_sector(const char *buf);
// End streaming sectors.
VCHPRE_ int VCHPOST_ vc_filesys_write_sectors_end(uint32_t *sectors_written);
#endif //VCFILESYS_H_

View File

@@ -29,9 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define VCHOST_H
#include "vchost_platform_config.h"
#include "vcfilesys_defs.h"
#include "interface/vcos/vcos.h" //for VCHPRE_ abd VCHPOST_ macro's for func declaration
#include "interface/vmcs_host/vc_fileservice_defs.h" // for VC_O_XXX file definitions
#include "interface/vchi/vchi.h"
#define UNUSED_PARAMETER(x) ((void)(x))/* macro to suppress not use warning */
@@ -159,74 +157,6 @@ VCHPRE_ void VCHPOST_ vc_lock_obtain(void *lock);
VCHPRE_ void VCHPOST_ vc_lock_release(void *lock);
/*---------------------------------------------------------------------------*/
/* File system related functions */
/*---------------------------------------------------------------------------*/
// Initialises the host dependent file system functions for use
VCHPRE_ void VCHPOST_ vc_hostfs_init(void);
VCHPRE_ void VCHPOST_ vc_hostfs_exit(void);
// Low level file system functions equivalent to close(), lseek(), open(), read() and write()
VCHPRE_ int VCHPOST_ vc_hostfs_close(int fildes);
VCHPRE_ long VCHPOST_ vc_hostfs_lseek(int fildes, long offset, int whence);
VCHPRE_ int64_t VCHPOST_ vc_hostfs_lseek64(int fildes, int64_t offset, int whence);
VCHPRE_ int VCHPOST_ vc_hostfs_open(const char *path, int vc_oflag);
VCHPRE_ int VCHPOST_ vc_hostfs_read(int fildes, void *buf, unsigned int nbyte);
VCHPRE_ int VCHPOST_ vc_hostfs_write(int fildes, const void *buf, unsigned int nbyte);
// Ends a directory listing iteration
VCHPRE_ int VCHPOST_ vc_hostfs_closedir(void *dhandle);
// Formats the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_hostfs_format(const char *path);
// Returns the amount of free space on the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_hostfs_freespace(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_hostfs_freespace64(const char *path);
// Gets the attributes of the named file
VCHPRE_ int VCHPOST_ vc_hostfs_get_attr(const char *path, fattributes_t *attr);
// Creates a new directory
VCHPRE_ int VCHPOST_ vc_hostfs_mkdir(const char *path);
// Starts a directory listing iteration
VCHPRE_ void * VCHPOST_ vc_hostfs_opendir(const char *dirname);
// Directory listing iterator
VCHPRE_ struct dirent * VCHPOST_ vc_hostfs_readdir_r(void *dhandle, struct dirent *result);
// Deletes a file or (empty) directory
VCHPRE_ int VCHPOST_ vc_hostfs_remove(const char *path);
// Renames a file, provided the new name is on the same file system as the old
VCHPRE_ int VCHPOST_ vc_hostfs_rename(const char *oldfile, const char *newfile);
// Sets the attributes of the named file
VCHPRE_ int VCHPOST_ vc_hostfs_set_attr(const char *path, fattributes_t attr);
// Truncates a file at its current position
VCHPRE_ int VCHPOST_ vc_hostfs_setend(int fildes);
// Returns the total amount of space on the drive that contains the given path
VCHPRE_ int VCHPOST_ vc_hostfs_totalspace(const char *path);
VCHPRE_ int64_t VCHPOST_ vc_hostfs_totalspace64(const char *path);
// Return millisecond resolution system time, only used for differences
VCHPRE_ int VCHPOST_ vc_millitime(void);
// Invalidates any cluster chains in the FAT that are not referenced in any directory structures
VCHPRE_ void VCHPOST_ vc_hostfs_scandisk(const char *path);
// Checks whether or not a FAT filesystem is corrupt or not. If fix_errors is TRUE behaves exactly as vc_filesys_scandisk.
VCHPRE_ int VCHPOST_ vc_hostfs_chkdsk(const char *path, int fix_errors);
/*---------------------------------------------------------------------------*/
/* These functions only need to be implemented for the test system. */
/*---------------------------------------------------------------------------*/