Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 22 Jul 2012 01:10:59 +0200
From: John Spencer <maillist-musl@...fooze.de>
To: musl@...ts.openwall.com
Subject: Re: sabotage linux X86_64 image with LXDE desktop released

On 07/21/2012 10:50 PM, Rich Felker wrote:
> On Sat, Jul 21, 2012 at 10:59:11PM +0200, John Spencer wrote:
>> the desktop works, but is not polished at all - there's no
>> background image and the icon paths seem to be misconfigured.
>> this can be considered a technoloy preview.
>> here is a screenshot: http://i.imgur.com/Lz7Ov.png
> Something seems very wrong with those task manager vm sizes...
> Is this indicative of a bug on musl's side?
>
> Rich
>

here's what it's doing (note that PAGE_SIZE was originally an external 
variable which got once filled with sc_sysconf values,
i needed to patch it away because of the conflict with the macro of the 
same name)

lxtask-0.1.4/src/xfce-taskmanager-linux.c:
reading the values ...

void get_task_details(gint pid,struct task *task)
{
         task->size=0;

         sprintf(line,"/proc/%d/statm",pid);
         fd=open(line,O_RDONLY);
         if(fd==-1) return;
         read(fd,line,256);
         sscanf(line,"%d %d",&task->size,&task->rss);
         close(fd);
         if(!task->size) return;
         task->size*=PAGE_SIZE;
         task->rss*=PAGE_SIZE;

struct task
{
// ...
     gint size;
     gint rss;
};

displayed using
gtk_tree_store_set(GTK_TREE_STORE(list_store), iter, COLUMN_RSS, 
size_to_string(buf, task->rss*1024), -1);

where
char* size_to_string( char* buf, guint64 size )
{
     char * unit;
     /* guint point; */
     gfloat val;

     /*
        FIXME: Is floating point calculation slower than integer division?
               Some profiling is needed here.
     */
     if ( size > ( ( guint64 ) 1 ) << 30 )
     {
         if ( size > ( ( guint64 ) 1 ) << 40 )
         {
             /*
             size /= ( ( ( guint64 ) 1 << 40 ) / 10 );
             point = ( guint ) ( size % 10 );
             size /= 10;
             */
             val = ((gfloat)size) / ( ( guint64 ) 1 << 40 );
             unit = "TB";
         }
         else
         {
             /*
             size /= ( ( 1 << 30 ) / 10 );
             point = ( guint ) ( size % 10 );
             size /= 10;
             */
             val = ((gfloat)size) / ( ( guint64 ) 1 << 30 );
             unit = "GB";
         }
     }
     else if ( size > ( 1 << 20 ) )
     {
         /*
         size /= ( ( 1 << 20 ) / 10 );
         point = ( guint ) ( size % 10 );
         size /= 10;
         */
         val = ((gfloat)size) / ( ( guint64 ) 1 << 20 );
         unit = "MB";
     }
     else if ( size > ( 1 << 10 ) )
     {
         /*
         size /= ( ( 1 << 10 ) / 10 );
         point = size % 10;
         size /= 10;
         */
         val = ((gfloat)size) / ( ( guint64 ) 1 << 10 );
         unit = "KB";

     }
     else
     {
         unit = size > 1 ? "Bytes" : "Byte";
         sprintf( buf, "%u %s", ( guint ) size, unit );
         return buf;
     }
     /* sprintf( buf, "%llu.%u %s", size, point, unit ); */
     sprintf( buf, "%.1f %s", val, unit );

     return buf;
}

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.