2011-03-24 09:47:11 +00:00
|
|
|
diff -urpN microcode_ctl-1.17.orig/Makefile microcode_ctl-1.17/Makefile
|
|
|
|
--- microcode_ctl-1.17.orig/Makefile 2011-03-24 10:28:12.553269014 +0100
|
|
|
|
+++ microcode_ctl-1.17/Makefile 2011-03-24 10:28:26.644387088 +0100
|
2008-02-08 02:36:06 +00:00
|
|
|
@@ -20,8 +20,8 @@ DESTDIR =
|
2005-01-08 08:23:02 +00:00
|
|
|
PREFIX = /usr/local
|
|
|
|
|
|
|
|
INSDIR = $(PREFIX)/sbin
|
|
|
|
-MANDIR = $(PREFIX)/man/man8
|
2008-02-08 02:36:06 +00:00
|
|
|
-MICDIR = /etc
|
2005-01-08 08:23:02 +00:00
|
|
|
+MANDIR = $(PREFIX)/share/man/man8
|
2008-02-22 20:01:12 +00:00
|
|
|
+MICDIR = /lib/firmware
|
2005-01-08 08:23:02 +00:00
|
|
|
|
|
|
|
RCFILE = microcode_ctl.start
|
2008-02-08 02:36:06 +00:00
|
|
|
RCFILEFINAL = microcode_ctl
|
|
|
|
@@ -44,7 +44,7 @@ install:
|
|
|
|
$(DESTDIR)$(MANDIR) $(DESTDIR)$(RCFILETO) \
|
2005-01-08 08:23:02 +00:00
|
|
|
$(DESTDIR)$(RCLINKTO)
|
|
|
|
|
|
|
|
- $(INS) -s -m 755 $(PROGRAM) $(DESTDIR)$(INSDIR)
|
|
|
|
+ $(INS) -m 755 $(PROGRAM) $(DESTDIR)$(INSDIR)
|
2008-02-08 02:36:06 +00:00
|
|
|
$(INS) -m 644 $(MICROCODE) $(DESTDIR)$(MICDIR)/microcode.dat
|
2005-01-08 08:23:02 +00:00
|
|
|
|
|
|
|
$(INS) -m 644 $(MANPAGE) $(DESTDIR)$(MANDIR)
|
2011-03-24 09:47:11 +00:00
|
|
|
diff -urpN microcode_ctl-1.17.orig/microcode_ctl.c microcode_ctl-1.17/microcode_ctl.c
|
|
|
|
--- microcode_ctl-1.17.orig/microcode_ctl.c 2011-03-24 10:28:12.553269014 +0100
|
|
|
|
+++ microcode_ctl-1.17/microcode_ctl.c 2011-03-24 10:28:29.244262053 +0100
|
2008-02-08 02:36:06 +00:00
|
|
|
@@ -25,7 +25,7 @@ int print_error_messages=1;
|
|
|
|
#define MAX_MICROCODE 2000000
|
|
|
|
|
|
|
|
#define MICROCODE_DEVICE_DEFAULT "/dev/cpu/microcode"
|
|
|
|
-#define MICROCODE_FILE_DEFAULT "/etc/microcode.dat"
|
2008-02-22 20:01:12 +00:00
|
|
|
+#define MICROCODE_FILE_DEFAULT "/lib/firmware/microcode.dat"
|
2008-02-08 02:36:06 +00:00
|
|
|
|
|
|
|
static void usage(void)
|
|
|
|
{
|
2011-03-24 09:47:11 +00:00
|
|
|
@@ -52,17 +52,19 @@ static int do_update(char *device, char
|
2005-01-08 08:23:02 +00:00
|
|
|
{
|
2008-02-08 02:36:06 +00:00
|
|
|
FILE *fp;
|
2005-01-08 08:23:02 +00:00
|
|
|
char line_buffer[BUFFER_SIZE];
|
|
|
|
- int microcode[MAX_MICROCODE];
|
|
|
|
+ int *microcode;
|
|
|
|
int *pos;
|
|
|
|
int outfd;
|
|
|
|
int wrote, length;
|
|
|
|
|
|
|
|
+ microcode=malloc(sizeof(int)* MAX_MICROCODE);
|
|
|
|
+ if (!microcode) return ENOMEM;
|
|
|
|
|
2008-02-08 02:36:06 +00:00
|
|
|
if( (fp=fopen(filename, "r")) == NULL){
|
2005-01-08 08:23:02 +00:00
|
|
|
if(print_error_messages)
|
2011-03-24 09:47:11 +00:00
|
|
|
fprintf(stderr, "%s: cannot open source file '%s' errno=%d (%s)\n",
|
|
|
|
progname, filename, errno, strerror(errno));
|
|
|
|
- return errno;
|
|
|
|
+ goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = microcode;
|
|
|
|
@@ -84,7 +86,7 @@ static int do_update(char *device, char
|
|
|
|
fprintf(stderr, "%s: file too large for utility microcode buffer\n"
|
|
|
|
"%s: change MAX_MICROCODE yourself :)\n", progname, progname);
|
|
|
|
fclose(fp);
|
|
|
|
- return errno;
|
|
|
|
+ goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
@@ -98,16 +100,16 @@ static int do_update(char *device, char
|
|
|
|
if(print_error_messages)
|
|
|
|
fprintf(stderr, "%s: cannot open %s for writing errno=%d (%s)\n",
|
|
|
|
progname, device, errno, strerror(errno));
|
|
|
|
- return errno;
|
|
|
|
+ goto end;
|
2005-01-08 08:23:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- if( (wrote = write(outfd, µcode, length)) < 0){
|
|
|
|
+ if( (wrote = write(outfd, microcode, length)) < 0){
|
|
|
|
if(print_error_messages)
|
|
|
|
fprintf(stderr, "%s: error writing to '%s' errno=%d (%s)\n"
|
|
|
|
"%s: there may be messages from the driver in your system log.\n",
|
2011-03-24 09:47:11 +00:00
|
|
|
progname, device, errno, strerror(errno), progname);
|
|
|
|
close(outfd);
|
|
|
|
- return errno;
|
|
|
|
+ goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((wrote == length) && print_normal_messages)
|
|
|
|
@@ -116,6 +118,8 @@ static int do_update(char *device, char
|
|
|
|
|
|
|
|
close(outfd);
|
|
|
|
|
|
|
|
+end:
|
|
|
|
+ free(microcode);
|
|
|
|
return errno;
|
|
|
|
}
|
|
|
|
|