浏览代码

rbcfg: Add missing mode to open call

When open() is called with O_CREAT a 3. parameter has to be given with
the file system permissions of the new file.

Not giving this is an error, which results in a compile error with glibc.

This fixes the following compile error with glibc:
----------------------------------------------------------------------
In file included from /include/fcntl.h:329,
                 from main.c:18:
In function 'open',
    inlined from 'rbcfg_update' at main.c:501:7:
/include/bits/fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
    __open_missing_mode ();
    ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Hauke Mehrtens <[email protected]>
Hauke Mehrtens 5 年之前
父节点
当前提交
14c59a147c
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      package/boot/rbcfg/Makefile
  2. 1 1
      package/boot/rbcfg/src/main.c

+ 1 - 1
package/boot/rbcfg/Makefile

@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 include $(TOPDIR)/rules.mk
 
 
 PKG_NAME:=rbcfg
 PKG_NAME:=rbcfg
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
 

+ 1 - 1
package/boot/rbcfg/src/main.c

@@ -498,7 +498,7 @@ rbcfg_update(int tmp)
 	put_u32(ctx->buf + 4, crc);
 	put_u32(ctx->buf + 4, crc);
 
 
 	name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
 	name = (tmp) ? ctx->tmp_file : ctx->mtd_device;
-	fd = open(name, O_WRONLY | O_CREAT);
+	fd = open(name, O_WRONLY | O_CREAT, 0640);
 	if (fd < 0) {
 	if (fd < 0) {
 		fprintf(stderr, "unable to open %s for writing\n", name);
 		fprintf(stderr, "unable to open %s for writing\n", name);
 		err = RB_ERR_IO;
 		err = RB_ERR_IO;