[prev in list] [next in list] [prev in thread] [next in thread]
List: klik-devel
Subject: [klik-devel] [klikclient commit] r1399 -
From: codesite-noreply () google ! com
Date: 2008-03-20 15:13:01
Message-ID: 0016367ed66c0448dfce3830e9ac519f () google ! com
[Download RAW message or body]
Author: lionel.tricon
Date: Thu Mar 20 08:12:15 2008
New Revision: 1399
Modified:
trunk/virtualization/unionfuse/trunk/fusioniso/src/fs.c
trunk/virtualization/unionfuse/trunk/fusioniso/src/fusemain.c
Log:
Added an option (-g) to change the loader of ELF binaries on the fly.
That affect ld-linux.so.2 loader (renamed ld-klik2.so.2) as well as
ld-lsb.so.1/3 (ld-lsk.so.1/3). Thus, you need to create links from
these locations (/lib/ld-*) to a new loader
Modified: trunk/virtualization/unionfuse/trunk/fusioniso/src/fs.c
==============================================================================
--- trunk/virtualization/unionfuse/trunk/fusioniso/src/fs.c (original)
+++ trunk/virtualization/unionfuse/trunk/fusioniso/src/fs.c Thu Mar 20
08:12:15 2008
@@ -108,6 +108,7 @@
extern int _exclude_length[];
extern int _list_max;
extern bool _debug;
+extern bool _glibc;
isofs_context context;
@@ -457,12 +458,12 @@
int rc;
// printf("path %s, current_size %d, block %d\n", path,
current_size, block);
- size_t total_size = 0;
+ size_t v_count = 0;
int count = 1;
int block_count = 0;
off_t boff = 0;
- while (total_size <= current_size - sizeof(struct iso_directory_record))
+ while (v_count <= current_size - sizeof(struct iso_directory_record))
{
rc = isofs_read_raw_block(block, buf);
if (rc < 0)
@@ -480,12 +481,12 @@
if (boff > 0)
{
- total_size += (context.data_size - boff);
+ v_count += (context.data_size - boff);
boff = 0;
}
while (boff + sizeof(struct iso_directory_record) <=
context.data_size &&
- total_size <= current_size - sizeof(struct iso_directory_record))
+ v_count <= current_size - sizeof(struct iso_directory_record))
{
struct iso_directory_record *record = (struct
iso_directory_record *) (buf + boff);
@@ -494,12 +495,12 @@
size_t pad_len = ((name_len & 1) ? 0 : 1); //
padding byte if name_len is even
size_t sa_len = record_length - name_len - sizeof(struct
iso_directory_record) - pad_len;
- // printf("block %d, boff %d, total_size %d,
current_size %d, record length %d, name_len %d, pad_len %d, sa_len %d\n",
- // block, (int) boff, total_size, current_size,
record_length, name_len, pad_len, sa_len);
+ // printf("block %d, boff %d, v_count %d, current_size %d,
record length %d, name_len %d, pad_len %d, sa_len %d\n",
+ // block, (int) boff, v_count, current_size,
record_length, name_len, pad_len, sa_len);
if (record_length == 0)
{
// possible end of directory or end of block
- total_size += (context.data_size - boff);
+ v_count += (context.data_size - boff);
boff = 0;
break;
}
@@ -512,7 +513,7 @@
// (this is much possible it was my fault and
misunderstanding -- dmiceman)
// but we need to try next block to be sure
/// TODO this is not clear: what to do if next
block not contain next directory?
- total_size += (context.data_size - boff);
+ v_count += (context.data_size - boff);
boff = 0;
break;
}
@@ -541,8 +542,8 @@
{
// looks like this is normal situation to meet another
directory because
// there is no clear way to find directory end
- // fprintf(stderr, "readdir: next
directory found while processing another directory! boff %d,
total_size %d, current_size %d, block %d, count %d\n",
- // (int) boff, total_size,
current_size, block, count);
+ // fprintf(stderr, "readdir: next
directory found while processing another directory! boff %d,
v_count %d, current_size %d, block %d, count %d\n",
+ // (int) boff, v_count,
current_size, block, count);
goto out;
}
@@ -660,7 +661,7 @@
free(entry);
boff += record_length;
- total_size += record_length;
+ v_count += record_length;
count++;
}
@@ -875,7 +876,25 @@
lseek(v_file, offset, SEEK_SET);
v_count = read(v_file, out_buf, size);
close(v_file);
- return size;
+ if (_glibc && offset==0 && v_count>18 && out_buf[0]==127
&& memcmp(&(out_buf[1]), "ELF",3)==0)
+ {
+ int i;
+ for (i=0; i<v_count-18; i++)
+ {
+ if (out_buf[i] != '/') continue;
+ if (memcmp(&(out_buf[i]), "/lib/ld-linux.so.2",
18) == 0)
+ {
+ memcpy(&(out_buf[i+8]), "klik2", 5);
+ break;
+ }
+ if (memcmp(&(out_buf[i]), "/lib/ld-lsb.so.", 15)
== 0)
+ {
+ memcpy(&(out_buf[i+8]), "lsk", 3);
+ break;
+ }
+ }
+ }
+ return v_count;
}
if (_union_mounting && stat(path,&v_stbuf)==0)
@@ -886,7 +905,25 @@
lseek(v_file, offset, SEEK_SET);
v_count = read(v_file, out_buf, size);
close(v_file);
- return size;
+ if (_glibc && offset==0 && v_count>18 && out_buf[0]==127
&& memcmp(&(out_buf[1]), "ELF",3)==0)
+ {
+ int i;
+ for (i=0; i<v_count-18; i++)
+ {
+ if (out_buf[i] != '/') continue;
+ if (memcmp(&(out_buf[i]), "/lib/ld-linux.so.2",
18) == 0)
+ {
+ memcpy(&(out_buf[i+8]), "klik2", 5);
+ break;
+ }
+ if (memcmp(&(out_buf[i]), "/lib/ld-lsb.so.", 15)
== 0)
+ {
+ memcpy(&(out_buf[i+8]), "lsk", 3);
+ break;
+ }
+ }
+ }
+ return v_count;
}
fprintf(stderr, "read: know nothing about %s\n", path);
@@ -907,7 +944,26 @@
if (inode->ZF) //
this file is compressed, handle it specially
{
- return isofs_real_read_zf(inode, out_buf, size, offset);
+ int v_count = isofs_real_read_zf(inode, out_buf, size, offset);
+ if (_glibc && offset==0 && v_count>18 && out_buf[0]==127 && memcmp(&(out_buf[1]), "ELF",3)==0)
+ {
+ int i;
+ for (i=0; i<v_count-18; i++)
+ {
+ if (out_buf[i] != '/') continue;
+ if (memcmp(&(out_buf[i]), "/lib/ld-linux.so.2", 18) == 0)
+ {
+ memcpy(&(out_buf[i+8]), "klik2", 5);
+ break;
+ }
+ if (memcmp(&(out_buf[i]), "/lib/ld-lsb.so.", 15) == 0)
+ {
+ memcpy(&(out_buf[i+8]), "lsk", 3);
+ break;
+ }
+ }
+ }
+ return v_count;
}
size_t fsize = isonum_733(record->size);
@@ -941,7 +997,7 @@
}
int i;
- size_t total_size = 0;
+ size_t v_count = 0;
size_t size_left = size;
int count = 0;
@@ -960,7 +1016,7 @@
len = size_left;
}
- total_size += len;
+ v_count += len;
memcpy(out_buf + count * context.data_size, buf + shift, len - shift);
@@ -971,7 +1027,25 @@
}
free(buf);
- return total_size;
+ if (_glibc && v_count>18 && offset==0 && out_buf[0]==127 && memcmp(&(out_buf[1]), "ELF",3)==0)
+ {
+ int i;
+ for (i=0; i<v_count-18; i++)
+ {
+ if (out_buf[i] != '/') continue;
+ if (memcmp(&(out_buf[i]), "/lib/ld-linux.so.2", 18) == 0)
+ {
+ memcpy(&(out_buf[i+8]), "klik2", 5);
+ break;
+ }
+ if (memcmp(&(out_buf[i]), "/lib/ld-lsb.so.", 15) == 0)
+ {
+ memcpy(&(out_buf[i+8]), "lsk", 3);
+ break;
+ }
+ }
+ }
+ return v_count;
}
int fs_real_statfs(const char *path, struct statfs *stbuf)
Modified: trunk/virtualization/unionfuse/trunk/fusioniso/src/fusemain.c
==============================================================================
--- trunk/virtualization/unionfuse/trunk/fusioniso/src/fusemain.c (original)
+++ trunk/virtualization/unionfuse/trunk/fusioniso/src/fusemain.c Thu
Mar 20 08:12:15 2008
@@ -89,6 +89,7 @@
int _exclude_length[32];
// Size of each directory to exclude (exclude list)
int _list_max=0;
// Number of directories (exclude list)
bool _debug;
// If true, write debug on the stderr
+bool _glibc;
// If true, change the loader on the fly
char* normalize_name(const char* fname)
{
@@ -488,7 +489,7 @@
void usage(const char* prog)
{
- printf("Version: %s\nUsage: %s [-n] [-p] [-u] [-b|d|B
<sandbox_path>] [-c <iocharset>] [-h] <isofs_image_file> <mount_point>
[<FUSE library options>]\n"
+ printf("Version: %s\nUsage: %s [-nputgh] [-b|d|B <sandbox_path>]
[-c <iocharset>] <isofs_image_file> <mount_point> [<FUSE library options>]\n"
"Where options are:\n"
" -n -- do NOT maintain file $HOME/.mtab.fusioniso\n"
" -p -- maintain mount point; \n"
@@ -496,6 +497,7 @@
" -c <iocharset> -- specify iocharset for Joliet filesystem\n"
" -h -- print this screen\n"
" -t -- debug mode\n"
+ " -g -- change the loader on the fly to
ld-klik2.so.2 [Experimental]\n"
" -u -- union mounting feature for klik2
(forced if -b, -d or -B)\n"
" -b <path> -- sandbox feature for klik2
(redirect all modification from $HOME user to <path>)\n"
" -d <path> -- sandbox feature for klik2
(redirect all modification from $HOME user dot files and folders to <path>)\n"
@@ -524,6 +526,7 @@
_sandbox_mounting = false;
_pw_dir = NULL;
_debug = false;
+ _glibc = false;
// Home directory
passwd = getpwuid(getuid());
@@ -533,10 +536,14 @@
}
char c;
- while ((c = getopt(argc, argv, "+npuhtc:b:B:d:")) > 0)
+ while ((c = getopt(argc, argv, "+npuhtgc:b:B:d:")) > 0)
{
switch (c)
{
+ case 'g':
+ _glibc = true;
+ break;
+
case 't':
_debug = true;
break;
_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic