extlinux: Also install ldlinux.c32 file on XFS
authorPaulo Alcantara <pcacjr@zytor.com>
Tue, 22 Jan 2013 19:12:51 +0000 (17:12 -0200)
committerPaulo Alcantara <pcacjr@zytor.com>
Tue, 22 Jan 2013 19:26:41 +0000 (17:26 -0200)
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
extlinux/main.c

index 01bfc9c..aa20e1b 100644 (file)
@@ -644,12 +644,16 @@ int btrfs_install_file(const char *path, int devfd, struct stat *rst)
  */
 static int xfs_install_file(const char *path, int devfd, struct stat *rst)
 {
-    static char file[PATH_MAX];
+    static char file[PATH_MAX + 1];
+    static char c32file[PATH_MAX + 1];
     int dirfd = -1;
     int fd = -1;
+    int retval;
 
-    snprintf(file, PATH_MAX, "%s%sldlinux.sys",
-            path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
+    snprintf(file, PATH_MAX + 1, "%s%sldlinux.sys", path,
+            path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
+    snprintf(c32file, PATH_MAX + 1, "%s%sldlinux.c32", path,
+            path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
 
     dirfd = open(path, O_RDONLY | O_DIRECTORY);
     if (dirfd < 0) {
@@ -683,10 +687,28 @@ static int xfs_install_file(const char *path, int devfd, struct stat *rst)
     }
 
     close(dirfd);
+    close(fd);
+
+    dirfd = -1;
+    fd = -1;
+
+    fd = open(c32file, O_WRONLY | O_TRUNC | O_CREAT | O_SYNC,
+             S_IRUSR | S_IRGRP | S_IROTH);
+    if (fd < 0) {
+       perror(c32file);
+       goto bail;
+    }
+
+    retval = xpwrite(fd, syslinux_ldlinuxc32, syslinux_ldlinuxc32_len, 0);
+    if (retval != (int)syslinux_ldlinuxc32_len) {
+       fprintf(stderr, "%s: write failure on %s\n", program, file);
+       goto bail;
+    }
 
-    sync();
     close(fd);
 
+    sync();
+
     return 0;
 
 bail: