Allow writing to currently executing files
This commit is contained in:
parent
abdb21f2a0
commit
de0b5f0d86
@ -21,6 +21,7 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#define max(a, b) \
|
#define max(a, b) \
|
||||||
({ \
|
({ \
|
||||||
@ -740,6 +741,10 @@ void write_block(uint32_t block_no, uint8_t *data) {
|
|||||||
*p = '/';
|
*p = '/';
|
||||||
|
|
||||||
int fd = open(fn, O_WRONLY | O_CREAT, 0777);
|
int fd = open(fn, O_WRONLY | O_CREAT, 0777);
|
||||||
|
if (fd < 0 && errno == ETXTBSY) {
|
||||||
|
unlink(fn);
|
||||||
|
fd = open(fn, O_WRONLY | O_CREAT, 0777);
|
||||||
|
}
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
ftruncate(fd, bl->fileSize);
|
ftruncate(fd, bl->fileSize);
|
||||||
lseek(fd, bl->targetAddr, SEEK_SET);
|
lseek(fd, bl->targetAddr, SEEK_SET);
|
||||||
|
Loading…
Reference in New Issue
Block a user