fs: Adds file system API to grow or shrink a file

Adds fs_truncate() function which can be used to change the size
of a file. The name is counter intuitive but that is how the POSIX
version is named. It shrinks as well as grows a file.

Jira: ZEP-635 ZEP-622
Change-Id: If7b8cad17e1b80479a529c60a32c12fb134cd456
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
diff --git a/include/fs.h b/include/fs.h
index 4cd8ba3..d321227 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -196,6 +196,26 @@
 off_t fs_tell(ZFILE *zfp);
 
 /**
+ * @brief Change the size of an open file
+ *
+ * Truncates the file to the new length if it is shorter than the current
+ * size of the file. Expands the file if the new length is greater than the
+ * current size of the file. The expanded region would be filled with zeroes.
+ *
+ * @note In the case of expansion, if the volume got full during the
+ * expansion process, the function will expand to the maximum possible length
+ * and returns success. Caller should check if the expanded size matches the
+ * requested length.
+ *
+ * @param zfp Pointer to the file object
+ * @param length New size of the file in bytes
+ *
+ * @retval 0 Success
+ * @retval -ERRNO errno code if error
+ */
+int fs_truncate(ZFILE *zfp, off_t length);
+
+/**
  * @brief Directory create
  *
  * Creates a new directory using specified path.