diff --git a/fs/fs.c b/fs/fs.c index 7c1f18e..8417067 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -605,6 +605,21 @@ } EXPORT_SYMBOL(protect); +int protect_file(const char *file, int prot) +{ + int fd, ret; + + fd = open(file, O_WRONLY); + if (fd < 0) + return fd; + + ret = protect(fd, ~0, 0, prot); + + close(fd); + + return ret; +} + void *memmap(int fd, int flags) { struct device_d *dev; diff --git a/include/fs.h b/include/fs.h index 552c4e9..4c03978 100644 --- a/include/fs.h +++ b/include/fs.h @@ -132,6 +132,7 @@ /* not-so-standard functions */ int erase(int fd, size_t count, unsigned long offset); int protect(int fd, size_t count, unsigned long offset, int prot); +int protect_file(const char *file, int prot); void *memmap(int fd, int flags); #define PROT_READ 1