git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git]
/
arch
/
um
/
os-Linux
/
umid.c
diff --git
a/arch/um/os-Linux/umid.c
b/arch/um/os-Linux/umid.c
index
362db05
..
ecf107a
100644
(file)
--- a/
arch/um/os-Linux/umid.c
+++ b/
arch/um/os-Linux/umid.c
@@
-120,8
+120,7
@@
static int not_dead_yet(char *dir)
dead = 0;
fd = open(file, O_RDONLY);
dead = 0;
fd = open(file, O_RDONLY);
- if(fd < 0) {
- fd = -errno;
+ if(fd < 0){
if(fd != -ENOENT){
printk("not_dead_yet : couldn't open pid file '%s', "
"err = %d\n", file, -fd);
if(fd != -ENOENT){
printk("not_dead_yet : couldn't open pid file '%s', "
"err = %d\n", file, -fd);
@@
-131,13
+130,9
@@
static int not_dead_yet(char *dir)
err = 0;
n = read(fd, pid, sizeof(pid));
err = 0;
n = read(fd, pid, sizeof(pid));
- if(n < 0){
- printk("not_dead_yet : couldn't read pid file '%s', "
- "err = %d\n", file, errno);
- goto out_close;
- } else if(n == 0){
+ if(n <= 0){
printk("not_dead_yet : couldn't read pid file '%s', "
printk("not_dead_yet : couldn't read pid file '%s', "
- "
0-byte read\n", file
);
+ "
err = %d\n", file, -n
);
goto out_close;
}
goto out_close;
}
@@
-148,10
+143,8
@@
static int not_dead_yet(char *dir)
goto out_close;
}
goto out_close;
}
- if((kill(p, 0) == 0) || (errno != ESRCH)){
- printk("umid \"%s\" is already in use by pid %d\n", umid, p);
+ if((kill(p, 0) == 0) || (errno != ESRCH))
return 1;
return 1;
- }
err = actually_do_remove(dir);
if(err)
err = actually_do_remove(dir);
if(err)
@@
-160,9
+153,9
@@
static int not_dead_yet(char *dir)
return err;
return err;
-out_close:
+
out_close:
close(fd);
close(fd);
-out:
+
out:
return 0;
}
return 0;
}
@@
-178,14
+171,14
@@
static void __init create_pid_file(void)
fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644);
if(fd < 0){
printk("Open of machine pid file \"%s\" failed: %s\n",
fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644);
if(fd < 0){
printk("Open of machine pid file \"%s\" failed: %s\n",
- file, strerror(
errno
));
+ file, strerror(
-fd
));
return;
}
snprintf(pid, sizeof(pid), "%d\n", getpid());
n = write(fd, pid, strlen(pid));
if(n != strlen(pid))
return;
}
snprintf(pid, sizeof(pid), "%d\n", getpid());
n = write(fd, pid, strlen(pid));
if(n != strlen(pid))
- printk("Write of pid file failed - err = %d\n",
errno
);
+ printk("Write of pid file failed - err = %d\n",
-n
);
close(fd);
}
close(fd);
}
@@
-241,44
+234,33
@@
int __init make_umid(void)
err = mkdir(tmp, 0777);
if(err < 0){
err = -errno;
err = mkdir(tmp, 0777);
if(err < 0){
err = -errno;
- if(err
!= -
EEXIST)
+ if(err
no !=
EEXIST)
goto err;
goto err;
- /* 1 -> this umid is already in use
- * < 0 -> we couldn't remove the umid directory
- * In either case, we can't use this umid, so return -EEXIST.
- */
- if(not_dead_yet(tmp) != 0)
+ if(not_dead_yet(tmp) < 0)
goto err;
err = mkdir(tmp, 0777);
}
goto err;
err = mkdir(tmp, 0777);
}
- if(err){
- err = -errno;
- printk("Failed to create '%s' - err = %d\n", umid, -errno);
- goto err;
+ if(err < 0){
+ printk("Failed to create '%s' - err = %d\n", umid, err);
+ goto err_rmdir;
}
umid_setup = 1;
create_pid_file();
}
umid_setup = 1;
create_pid_file();
- err = 0;
+ return 0;
+
+ err_rmdir:
+ rmdir(tmp);
err:
return err;
}
static int __init make_umid_init(void)
{
err:
return err;
}
static int __init make_umid_init(void)
{
- if(!make_umid())
- return 0;
-
- /* If initializing with the given umid failed, then try again with
- * a random one.
- */
- printk("Failed to initialize umid \"%s\", trying with a random umid\n",
- umid);
- *umid = '\0';
make_umid();
return 0;
make_umid();
return 0;