From: Gewj <geweijin@sinosoft.com.cn>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Bug? setlocale() can't find the right data file while run through rc.d during reboot
Date: Thu, 30 Dec 2004 21:31:52 +0900 [thread overview]
Message-ID: <41D3F538.6000801@sinosoft.com.cn> (raw)
[-- Attachment #1: Type: text/plain, Size: 2763 bytes --]
Package: glibc
Version: 2.3.2-95.20.1AX
Addition information about the setlocale puzzle is listed below
gcc version:gcc-3.2.3-36
kernel version:kernel-2.4.21-9.38AX
I used strace tool to log the run process of my program in both
reboot mode and shell mode, the result of those two logs are attached.
it is quite strange to find out that the setlocale function's strace
information is totally same in those two modes, but the file opened is
differ.
In reboot mode,
open("/home/local/mo/en_US/LC_MESSAGES/test.mo", O_RDONLY) = 3
In shell mode
open("/home/local/mo/ja_JP.eucJP/LC_MESSAGES/test.mo", O_RDONLY) = -1
ENOENT (No such file or directory)
open("/home/local/mo/ja_JP.eucjp/LC_MESSAGES/test.mo", O_RDONLY) = -1
ENOENT (No such file or directory)
open("/home/local/mo/ja_JP/LC_MESSAGES/test.mo", O_RDONLY) = 3
Is it a bug or all thing turn out to be myself's misuse?
Any tips is appriciated
Thanks in advance
Gewj.
Gewj wrote:
> Package: glibc
> Version: 2.3.2-95.20.1AX
>
>
> I am root and using Linux 2.4.21-9.38AX i686(Miracle3.0) with
> glibc-2.3.2-95.20.1AX
>
>
> When I used the following code in a program and start it in rc3.d(such
> as S99abc, the last one in the rc3.d)
>
> #define _(String) gettext(String)
>
> strcpy(moname,"test");
> setlocale(LC_ALL, "ja_JP");
> bindtextdomain(moname, "/home/local/mo");
> textdomain(moname);
>
> memset(uid, 0, MAX_LINE);
> memset(lpBuffer, 0, 1000);;
>
> strcpy(uid, "0xC0040903");
> strcpy(lpBuffer, _(uid));
>
> the dir structure of /usr/local/mo is list below:
> /home/local/mo
> -|en_US
> -|LC_MESSAGES
> -|ja_JP
> -|LC_MESSAGES
>
>
> when I reboot the machine, gettext("0xC0040903") return the string
> defined in en_US .mo file instead of in ja_JP .mo file.
> But when I run the same program after reboot(say, through shell) ,it
> return the right string that define in ja_JP .mo file.
>
>
>
> -----Test program-------
>
> #include <stdarg.h>
> #include <dlfcn.h>
> #include <ctype.h>
> #include <stdio.h>
> #include <syslog.h>
>
> #include <sys/types.h>
> #include <unistd.h>
> #include <libintl.h>
> #include <locale.h>
>
> #define MAX_LINE 64
> #define _(String) gettext(String)
>
> int main(int argc ,char * argv[])
> {
> char moname[MAX_LINE];
> char uid[MAX_LINE];
> char lpBuffer[1000];
>
> memset(moname,0,MAX_LINE);
> strcpy(moname,"test");
>
> setlocale(LC_ALL, "ja_JP");
> bindtextdomain(moname, "/home/local/mo");
> textdomain(moname);
>
> memset(uid, 0, MAX_LINE);
> memset(lpBuffer, 0, 1000);
>
> strcpy(uid, "0xC0040903");
> strcpy(lpBuffer, _(uid));
> printf("lpBuffer = %s\n",lpBuffer);
> syslog(6,"lpBuffer = %s",lpBuffer);
>
> return strlen(lpBuffer);
> }
>
>
>
[-- Attachment #2: ts.log.reboot --]
[-- Type: text/plain, Size: 3430 bytes --]
execve("/home/luy/ts", ["/home/luy/ts"], [/* 16 vars */]) = 0
uname({sys="Linux", node="blues", ...}) = 0
brk(0) = 0x8049850
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75ea000
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=54650, ...}) = 0
old_mmap(NULL, 54650, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb75dc000
close(3) = 0
open("/lib/tls/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0PX\1\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1511553, ...}) = 0
old_mmap(NULL, 1275852, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb74a4000
old_mmap(0xb75d6000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x131000) = 0xb75d6000
old_mmap(0xb75d9000, 10188, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb75d9000
close(3) = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb75eab00, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb75dc000, 54650) = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=32939504, ...}) = 0
mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb72a4000
mmap2(NULL, 897024, PROT_READ, MAP_PRIVATE, 3, 0xe75) = 0xb71c9000
brk(0) = 0x8049850
brk(0x806a850) = 0x806a850
brk(0) = 0x806a850
brk(0x806b000) = 0x806b000
close(3) = 0
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2601, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb71c8000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2601
read(3, "", 4096) = 0
close(3) = 0
munmap(0xb71c8000, 4096) = 0
open("/home/local/mo/en_US/LC_MESSAGES/test.mo", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1277, ...}) = 0
mmap2(NULL, 1277, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb71c8000
close(3) = 0
fstat64(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb71c7000
time([1104379410]) = 1104379410
open("/etc/localtime", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=165, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb71c6000
read(3, "TZif\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\3\0"..., 4096) = 165
close(3) = 0
munmap(0xb71c6000, 4096) = 0
rt_sigaction(SIGPIPE, {0xb757c5e0, [], SA_RESTORER, 0xb74cbde8}, {SIG_DFL}, 8) = 0
socket(PF_UNIX, SOCK_DGRAM, 0) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
connect(3, {sa_family=AF_UNIX, path="/dev/log"}, 16) = 0
send(3, "<14>Dec 30 12:03:30 ts: lpBuffer"..., 163, 0) = 163
rt_sigaction(SIGPIPE, {SIG_DFL}, NULL, 8) = 0
write(1, "lpBuffer = The used capacity of "..., 140) = 140
munmap(0xb71c7000, 4096) = 0
exit_group(128) = ?
[-- Attachment #3: ts.log.shell --]
[-- Type: text/plain, Size: 3673 bytes --]
execve("/home/luy/ts", ["/home/luy/ts"], [/* 29 vars */]) = 0
uname({sys="Linux", node="blues", ...}) = 0
brk(0) = 0x8049850
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb75ea000
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=54650, ...}) = 0
old_mmap(NULL, 54650, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb75dc000
close(3) = 0
open("/lib/tls/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0PX\1\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1511553, ...}) = 0
old_mmap(NULL, 1275852, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xb74a4000
old_mmap(0xb75d6000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x131000) = 0xb75d6000
old_mmap(0xb75d9000, 10188, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb75d9000
close(3) = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb75eab00, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb75dc000, 54650) = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=32939504, ...}) = 0
mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb72a4000
mmap2(NULL, 897024, PROT_READ, MAP_PRIVATE, 3, 0xe75) = 0xb71c9000
brk(0) = 0x8049850
brk(0x806a850) = 0x806a850
brk(0) = 0x806a850
brk(0x806b000) = 0x806b000
close(3) = 0
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2601, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb71c8000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2601
read(3, "", 4096) = 0
close(3) = 0
munmap(0xb71c8000, 4096) = 0
open("/home/local/mo/ja_JP.eucJP/LC_MESSAGES/test.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/local/mo/ja_JP.eucjp/LC_MESSAGES/test.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/local/mo/ja_JP/LC_MESSAGES/test.mo", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=952, ...}) = 0
mmap2(NULL, 952, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb71c8000
close(3) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb71c7000
write(1, "lpBuffer = %1 (%2)\244\316\266\365\244\255\315\306\316"..., 92) = 92
time([1104379832]) = 1104379832
open("/etc/localtime", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=165, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb71c6000
read(3, "TZif\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\3\0"..., 4096) = 165
close(3) = 0
munmap(0xb71c6000, 4096) = 0
rt_sigaction(SIGPIPE, {0xb757c5e0, [], SA_RESTORER, 0xb74cbde8}, {SIG_DFL}, 8) = 0
socket(PF_UNIX, SOCK_DGRAM, 0) = 3
fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
connect(3, {sa_family=AF_UNIX, path="/dev/log"}, 16) = 0
send(3, "<14>Dec 30 12:10:32 ts: lpBuffer"..., 115, 0) = 115
rt_sigaction(SIGPIPE, {SIG_DFL}, NULL, 8) = 0
munmap(0xb71c7000, 4096) = 0
exit_group(80) = ?
reply other threads:[~2004-12-30 12:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41D3F538.6000801@sinosoft.com.cn \
--to=geweijin@sinosoft.com.cn \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox