diff options
| -rw-r--r-- | scripts/kconfig/confdata.c | 121 | ||||
| -rw-r--r-- | scripts/kconfig/gconf.c | 2 | ||||
| -rw-r--r-- | scripts/kconfig/lexer.l | 3 | ||||
| -rw-r--r-- | scripts/kconfig/lkc.h | 1 | ||||
| -rw-r--r-- | scripts/kconfig/lxdialog/BIG.FAT.WARNING | 2 | ||||
| -rw-r--r-- | scripts/kconfig/mconf.c | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | scripts/kconfig/nconf-cfg.sh | 0 | ||||
| -rw-r--r-- | scripts/kconfig/nconf.c | 3 |
8 files changed, 89 insertions, 45 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 08ba146a83c5..492ac3410147 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 3 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include <sys/mman.h> | ||
| 6 | #include <sys/stat.h> | 7 | #include <sys/stat.h> |
| 7 | #include <ctype.h> | 8 | #include <ctype.h> |
| 8 | #include <errno.h> | 9 | #include <errno.h> |
| @@ -36,6 +37,52 @@ static bool is_dir(const char *path) | |||
| 36 | return S_ISDIR(st.st_mode); | 37 | return S_ISDIR(st.st_mode); |
| 37 | } | 38 | } |
| 38 | 39 | ||
| 40 | /* return true if the given two files are the same, false otherwise */ | ||
| 41 | static bool is_same(const char *file1, const char *file2) | ||
| 42 | { | ||
| 43 | int fd1, fd2; | ||
| 44 | struct stat st1, st2; | ||
| 45 | void *map1, *map2; | ||
| 46 | bool ret = false; | ||
| 47 | |||
| 48 | fd1 = open(file1, O_RDONLY); | ||
| 49 | if (fd1 < 0) | ||
| 50 | return ret; | ||
| 51 | |||
| 52 | fd2 = open(file2, O_RDONLY); | ||
| 53 | if (fd2 < 0) | ||
| 54 | goto close1; | ||
| 55 | |||
| 56 | ret = fstat(fd1, &st1); | ||
| 57 | if (ret) | ||
| 58 | goto close2; | ||
| 59 | ret = fstat(fd2, &st2); | ||
| 60 | if (ret) | ||
| 61 | goto close2; | ||
| 62 | |||
| 63 | if (st1.st_size != st2.st_size) | ||
| 64 | goto close2; | ||
| 65 | |||
| 66 | map1 = mmap(NULL, st1.st_size, PROT_READ, MAP_PRIVATE, fd1, 0); | ||
| 67 | if (map1 == MAP_FAILED) | ||
| 68 | goto close2; | ||
| 69 | |||
| 70 | map2 = mmap(NULL, st2.st_size, PROT_READ, MAP_PRIVATE, fd2, 0); | ||
| 71 | if (map2 == MAP_FAILED) | ||
| 72 | goto close2; | ||
| 73 | |||
| 74 | if (bcmp(map1, map2, st1.st_size)) | ||
| 75 | goto close2; | ||
| 76 | |||
| 77 | ret = true; | ||
| 78 | close2: | ||
| 79 | close(fd2); | ||
| 80 | close1: | ||
| 81 | close(fd1); | ||
| 82 | |||
| 83 | return ret; | ||
| 84 | } | ||
| 85 | |||
| 39 | /* | 86 | /* |
| 40 | * Create the parent directory of the given path. | 87 | * Create the parent directory of the given path. |
| 41 | * | 88 | * |
| @@ -179,7 +226,7 @@ const char *conf_get_configname(void) | |||
| 179 | return name ? name : ".config"; | 226 | return name ? name : ".config"; |
| 180 | } | 227 | } |
| 181 | 228 | ||
| 182 | const char *conf_get_autoconfig_name(void) | 229 | static const char *conf_get_autoconfig_name(void) |
| 183 | { | 230 | { |
| 184 | char *name = getenv("KCONFIG_AUTOCONFIG"); | 231 | char *name = getenv("KCONFIG_AUTOCONFIG"); |
| 185 | 232 | ||
| @@ -194,7 +241,7 @@ char *conf_get_default_confname(void) | |||
| 194 | name = expand_string(conf_defname); | 241 | name = expand_string(conf_defname); |
| 195 | env = getenv(SRCTREE); | 242 | env = getenv(SRCTREE); |
| 196 | if (env) { | 243 | if (env) { |
| 197 | sprintf(fullname, "%s/%s", env, name); | 244 | snprintf(fullname, sizeof(fullname), "%s/%s", env, name); |
| 198 | if (is_present(fullname)) | 245 | if (is_present(fullname)) |
| 199 | return fullname; | 246 | return fullname; |
| 200 | } | 247 | } |
| @@ -817,40 +864,34 @@ int conf_write(const char *name) | |||
| 817 | FILE *out; | 864 | FILE *out; |
| 818 | struct symbol *sym; | 865 | struct symbol *sym; |
| 819 | struct menu *menu; | 866 | struct menu *menu; |
| 820 | const char *basename; | ||
| 821 | const char *str; | 867 | const char *str; |
| 822 | char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8]; | 868 | char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1]; |
| 823 | char *env; | 869 | char *env; |
| 824 | 870 | ||
| 825 | dirname[0] = 0; | 871 | if (!name) |
| 826 | if (name && name[0]) { | 872 | name = conf_get_configname(); |
| 827 | char *slash; | 873 | |
| 828 | 874 | if (!*name) { | |
| 829 | if (is_dir(name)) { | 875 | fprintf(stderr, "config name is empty\n"); |
| 830 | strcpy(dirname, name); | 876 | return -1; |
| 831 | strcat(dirname, "/"); | 877 | } |
| 832 | basename = conf_get_configname(); | 878 | |
| 833 | } else if ((slash = strrchr(name, '/'))) { | 879 | if (is_dir(name)) { |
| 834 | int size = slash - name + 1; | 880 | fprintf(stderr, "%s: Is a directory\n", name); |
| 835 | memcpy(dirname, name, size); | 881 | return -1; |
| 836 | dirname[size] = 0; | 882 | } |
| 837 | if (slash[1]) | 883 | |
| 838 | basename = slash + 1; | 884 | if (make_parent_dir(name)) |
| 839 | else | 885 | return -1; |
| 840 | basename = conf_get_configname(); | 886 | |
| 841 | } else | ||
| 842 | basename = name; | ||
| 843 | } else | ||
| 844 | basename = conf_get_configname(); | ||
| 845 | |||
| 846 | sprintf(newname, "%s%s", dirname, basename); | ||
| 847 | env = getenv("KCONFIG_OVERWRITECONFIG"); | 887 | env = getenv("KCONFIG_OVERWRITECONFIG"); |
| 848 | if (!env || !*env) { | 888 | if (env && *env) { |
| 849 | sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); | ||
| 850 | out = fopen(tmpname, "w"); | ||
| 851 | } else { | ||
| 852 | *tmpname = 0; | 889 | *tmpname = 0; |
| 853 | out = fopen(newname, "w"); | 890 | out = fopen(name, "w"); |
| 891 | } else { | ||
| 892 | snprintf(tmpname, sizeof(tmpname), "%s.%d.tmp", | ||
| 893 | name, (int)getpid()); | ||
| 894 | out = fopen(tmpname, "w"); | ||
| 854 | } | 895 | } |
| 855 | if (!out) | 896 | if (!out) |
| 856 | return 1; | 897 | return 1; |
| @@ -897,14 +938,20 @@ next: | |||
| 897 | fclose(out); | 938 | fclose(out); |
| 898 | 939 | ||
| 899 | if (*tmpname) { | 940 | if (*tmpname) { |
| 900 | strcat(dirname, basename); | 941 | if (is_same(name, tmpname)) { |
| 901 | strcat(dirname, ".old"); | 942 | conf_message("No change to %s", name); |
| 902 | rename(newname, dirname); | 943 | unlink(tmpname); |
| 903 | if (rename(tmpname, newname)) | 944 | sym_set_change_count(0); |
| 945 | return 0; | ||
| 946 | } | ||
| 947 | |||
| 948 | snprintf(oldname, sizeof(oldname), "%s.old", name); | ||
| 949 | rename(name, oldname); | ||
| 950 | if (rename(tmpname, name)) | ||
| 904 | return 1; | 951 | return 1; |
| 905 | } | 952 | } |
| 906 | 953 | ||
| 907 | conf_message("configuration written to %s", newname); | 954 | conf_message("configuration written to %s", name); |
| 908 | 955 | ||
| 909 | sym_set_change_count(0); | 956 | sym_set_change_count(0); |
| 910 | 957 | ||
| @@ -917,8 +964,6 @@ static int conf_write_dep(const char *name) | |||
| 917 | struct file *file; | 964 | struct file *file; |
| 918 | FILE *out; | 965 | FILE *out; |
| 919 | 966 | ||
| 920 | if (!name) | ||
| 921 | name = ".kconfig.d"; | ||
| 922 | out = fopen("..config.tmp", "w"); | 967 | out = fopen("..config.tmp", "w"); |
| 923 | if (!out) | 968 | if (!out) |
| 924 | return 1; | 969 | return 1; |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 5d4ecf309ee4..e36b342f1065 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
| @@ -638,7 +638,7 @@ on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data) | |||
| 638 | void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) | 638 | void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) |
| 639 | { | 639 | { |
| 640 | GtkWidget *dialog; | 640 | GtkWidget *dialog; |
| 641 | const gchar *intro_text = | 641 | const gchar *intro_text = |
| 642 | "Welcome to gkc, the GTK+ graphical configuration tool\n" | 642 | "Welcome to gkc, the GTK+ graphical configuration tool\n" |
| 643 | "For each option, a blank box indicates the feature is disabled, a\n" | 643 | "For each option, a blank box indicates the feature is disabled, a\n" |
| 644 | "check indicates it is enabled, and a dot indicates that it is to\n" | 644 | "check indicates it is enabled, and a dot indicates that it is to\n" |
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index c9df1c8b9824..6354c905b006 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l | |||
| @@ -378,7 +378,8 @@ FILE *zconf_fopen(const char *name) | |||
| 378 | if (!f && name != NULL && name[0] != '/') { | 378 | if (!f && name != NULL && name[0] != '/') { |
| 379 | env = getenv(SRCTREE); | 379 | env = getenv(SRCTREE); |
| 380 | if (env) { | 380 | if (env) { |
| 381 | sprintf(fullname, "%s/%s", env, name); | 381 | snprintf(fullname, sizeof(fullname), |
| 382 | "%s/%s", env, name); | ||
| 382 | f = fopen(fullname, "r"); | 383 | f = fopen(fullname, "r"); |
| 383 | } | 384 | } |
| 384 | } | 385 | } |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d871539e4b45..cbc7658ee27d 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
| @@ -49,7 +49,6 @@ const char *zconf_curname(void); | |||
| 49 | 49 | ||
| 50 | /* confdata.c */ | 50 | /* confdata.c */ |
| 51 | const char *conf_get_configname(void); | 51 | const char *conf_get_configname(void); |
| 52 | const char *conf_get_autoconfig_name(void); | ||
| 53 | char *conf_get_default_confname(void); | 52 | char *conf_get_default_confname(void); |
| 54 | void sym_set_change_count(int count); | 53 | void sym_set_change_count(int count); |
| 55 | void sym_add_change_count(int count); | 54 | void sym_add_change_count(int count); |
diff --git a/scripts/kconfig/lxdialog/BIG.FAT.WARNING b/scripts/kconfig/lxdialog/BIG.FAT.WARNING index a8999d82bdb3..7cb5a7ec93d2 100644 --- a/scripts/kconfig/lxdialog/BIG.FAT.WARNING +++ b/scripts/kconfig/lxdialog/BIG.FAT.WARNING | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | This is NOT the official version of dialog. This version has been | 1 | This is NOT the official version of dialog. This version has been |
| 2 | significantly modified from the original. It is for use by the Linux | 2 | significantly modified from the original. It is for use by the Linux |
| 3 | kernel configuration script. Please do not bother Savio Lam with | 3 | kernel configuration script. Please do not bother Savio Lam with |
| 4 | questions about this program. | 4 | questions about this program. |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 5f8c82a4cb08..694091f3ef9d 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
| @@ -936,7 +936,7 @@ static void conf_save(void) | |||
| 936 | set_config_filename(dialog_input_result); | 936 | set_config_filename(dialog_input_result); |
| 937 | return; | 937 | return; |
| 938 | } | 938 | } |
| 939 | show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); | 939 | show_textbox(NULL, "Can't create file!", 5, 60); |
| 940 | break; | 940 | break; |
| 941 | case 1: | 941 | case 1: |
| 942 | show_helptext("Save Alternate Configuration", save_config_help); | 942 | show_helptext("Save Alternate Configuration", save_config_help); |
diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh index 001559ef0a60..001559ef0a60 100644..100755 --- a/scripts/kconfig/nconf-cfg.sh +++ b/scripts/kconfig/nconf-cfg.sh | |||
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index ac92c0ded6c5..cbafe3bf082e 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
| @@ -1438,8 +1438,7 @@ static void conf_save(void) | |||
| 1438 | set_config_filename(dialog_input_result); | 1438 | set_config_filename(dialog_input_result); |
| 1439 | return; | 1439 | return; |
| 1440 | } | 1440 | } |
| 1441 | btn_dialog(main_window, "Can't create file! " | 1441 | btn_dialog(main_window, "Can't create file!", |
| 1442 | "Probably a nonexistent directory.", | ||
| 1443 | 1, "<OK>"); | 1442 | 1, "<OK>"); |
| 1444 | break; | 1443 | break; |
| 1445 | case 1: | 1444 | case 1: |
