diff options
| author | Albert ARIBAUD <albert.u.boot@aribaud.net> | 2013-05-11 00:06:03 +0200 | 
|---|---|---|
| committer | Albert ARIBAUD <albert.u.boot@aribaud.net> | 2013-05-11 00:06:03 +0200 | 
| commit | e825b100d209a9d3c79b2998452cafa94eec986a (patch) | |
| tree | e1654c4d745839eba8d37f67d15acde79382e23e /fs/sandbox/sandboxfs.c | |
| parent | b03b25caea1ff3a501161f5bc1ad5e5b5b124e0c (diff) | |
| parent | 66a62ce0dc48d2319938c72f34a562f519c5d5c2 (diff) | |
| download | olio-uboot-2014.01-e825b100d209a9d3c79b2998452cafa94eec986a.tar.xz olio-uboot-2014.01-e825b100d209a9d3c79b2998452cafa94eec986a.zip | |
Merge branch 'u-boot-pxa/master' into 'u-boot-arm/master'
Diffstat (limited to 'fs/sandbox/sandboxfs.c')
| -rw-r--r-- | fs/sandbox/sandboxfs.c | 33 | 
1 files changed, 33 insertions, 0 deletions
| diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c index 02d26ff85..89769e8ce 100644 --- a/fs/sandbox/sandboxfs.c +++ b/fs/sandbox/sandboxfs.c @@ -48,6 +48,26 @@ long sandbox_fs_read_at(const char *filename, unsigned long pos,  	return size;  } +long sandbox_fs_write_at(const char *filename, unsigned long pos, +			 void *buffer, unsigned long towrite) +{ +	ssize_t size; +	int fd, ret; + +	fd = os_open(filename, OS_O_RDWR | OS_O_CREAT); +	if (fd < 0) +		return fd; +	ret = os_lseek(fd, pos, OS_SEEK_SET); +	if (ret == -1) { +		os_close(fd); +		return ret; +	} +	size = os_write(fd, buffer, towrite); +	os_close(fd); + +	return size; +} +  int sandbox_fs_ls(const char *dirname)  {  	struct os_dirent_node *head, *node; @@ -81,3 +101,16 @@ int fs_read_sandbox(const char *filename, void *buf, int offset, int len)  	return len_read;  } + +int fs_write_sandbox(const char *filename, void *buf, int offset, int len) +{ +	int len_written; + +	len_written = sandbox_fs_write_at(filename, offset, buf, len); +	if (len_written == -1) { +		printf("** Unable to write file %s **\n", filename); +		return -1; +	} + +	return len_written; +} |