firmware-utils: honor env SOURCE_DATE_EPOCH
[openwrt/openwrt.git] / tools / firmware-utils / src / imagetag.c
index f04f98d560ab88b5a9d814b205ee022de886b506..bc70399ccaa390be3ecedaed98e67e66d49a4e0f 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <stdint.h>
-#include <time.h>
 #include <unistd.h>
 #include <sys/stat.h>
 #include <netinet/in.h>
+#include <inttypes.h>
 
 #include "bcm_tag.h"
 #include "imagetag_cmdline.h"
@@ -163,6 +163,8 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
          /* align the start if requested */
          if (args->align_rootfs_flag)
                rootfsoff = (rootfsoff % block_size) > 0 ? (((rootfsoff / block_size) + 1) * block_size) : rootfsoff;
+          else
+               rootfsoff = (rootfsoff % 4) > 0 ? (((rootfsoff / 4) + 1) * 4) : rootfsoff;
 
          /* align the end */
          rootfsend = rootfsoff + getlen(rootfsfile);
@@ -304,7 +306,7 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
        sprintf(tag.totalLength, "%lu", imagelen);
 
        if (args->cfe_given) {
-         sprintf(tag.cfeAddress, "%lu", flash_start);
+         sprintf(tag.cfeAddress, "%" PRIu32, flash_start);
          sprintf(tag.cfeLength, "%lu", cfelen);
        } else {
          /* We don't include CFE */
@@ -345,7 +347,7 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
        }
 
        if (args->altinfo_given) {
-         strncpy(&tag.information1[0], args->altinfo_arg, ALTTAGINFO_LEN);
+         strncpy(tag.information1, args->altinfo_arg, TAGINFO1_LEN);
        }
 
        if (args->second_image_flag_given) {