Wednesday, 21 December 2011

Ubuntu on a Stick

Ubuntu on a Stick

I'd like to load Ubuntu and it's core apps on a 32GB USB drive so that I could, from a cold boot, boot up in Ubuntu without ever touching my hard disk drive.

Also, I'd like to be able to do this on a big RAID machine (two RAID-1 arrays) without touching their drives: I've tried this in the past (it has been several years) and it had the tendency to break the RAID array for the system drive.

BOTTOM LINE: I want everything to be done on the USB stick.

Is this possible? Is Ubuntu the best choice? For what it is worth, I want a Graphic User Interface.

error while compilation of user device driver

error while compilation of user device driver

Hi,
Im a newbie to linux and im trying to do a homework of adding a device to the kernel.
Please point out my mistakes in the forum

I am trying the sample driver memory.c which i net to load into my kernel
my memory.c looks like this
Code:

#include <linux/init.h>


#include <linux/config.h>


#include <linux/module.h>


#include <linux/kernel.h> /* printk() */


#include <linux/slab.h> /* kmalloc() */


#include <linux/fs.h> /* everything... */


#include <linux/errno.h> /* error codes */


#include <linux/types.h> /* size_t */


#include <linux/proc_fs.h>


#include <linux/fcntl.h> /* O_ACCMODE */


#include <asm/system.h> /* cli(), *_flags */


#include <asm/uaccess.h> /* copy_from/to_user */





/* Declaration of memory.c functions */
int memory_open(struct inode *inode, struct file *filp);
int memory_release(struct inode *inode, struct file *filp);
ssize_t memory_read(struct file *filp, char *buf, size_t count, loff_t *f_pos);
ssize_t memory_write(struct file *filp, char *buf, size_t count, loff_t *f_pos); void memory_exit(void);
int memory_init(void);


/* Structure that declares the usual file / / access functions */
struct file_operations memory_fops =
{ read: memory_read,
 write: memory_write,
open: memory_open,
release: memory_release };


/* Declaration of the init and exit functions */
module_init(memory_init);
module_exit(memory_exit);


/* Global variables of the driver / / Major number */
int memory_major = 60;
/* Buffer to store data */
char *memory_buffer;

/*------------------------------------------------------*/
int memory_init(void)
{
  int result;


/* Registering device */
result = register_chrdev(memory_major, "memory", &memory_fops);
 if (result < 0)
{
printk( "<1>memory: cannot obtain major number %d\n", memory_major); return result;
 }


/* Allocating memory for the buffer */
memory_buffer = kmalloc(1, GFP_KERNEL);
if (!memory_buffer)
 {
result = -ENOMEM; goto fail;
}
memset(memory_buffer, 0, 1);


printk("<1>Inserting memory module\n");
return 0;


fail: memory_exit(); return result;
 }


/*---------------------------------------------*/
void memory_exit(void)
 {
  /* Freeing the major number */
  unregister_chrdev(memory_major, "memory");


/* Freeing buffer memory */
if (memory_buffer)
 {
kfree(memory_buffer);
 }


printk("<1>Removing memory module\n");


}
/*-------------------------------*/
int memory_open(struct inode *inode, struct file *filp)
{


/* Success */
 return 0;
}
/*-------------------------------*/

int memory_release(struct inode *inode, struct file *filp)
{


/* Success */
return 0;
 }

/*-------------------------------*/


ssize_t memory_read(struct file *filp, char *buf,
                    size_t count, loff_t *f_pos)
{


/* Transfering data to user space */
copy_to_user(buf,memory_buffer,1);


/* Changing reading position as best suits */
if (f_pos == 0)
 {
 *f_pos+=1; return 1;
}
 else
 {
 return 0;
 }
}

/*-------------------------------*/

ssize_t memory_write( struct file *filp, char *buf,
                      size_t count, loff_t *f_pos)
{


char *tmp;


tmp=buf+count-1; copy_from_user(memory_buffer,tmp,1); return 1;
}

Makefile used is
Code:

obj-m        += memory.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

the error im getting is


sathish/sathish-desktop:~$ make memory
cc memory.c -o memory
memory.c:1:24: error: linux/init.h: No such file or directory
memory.c:4:26: error: linux/config.h: No such file or directory
memory.c:7:26: error: linux/module.h: No such file or directory
memory.c:13:40: error: linux/slab.h: No such file or directory
memory.c:25:27: error: linux/proc_fs.h: No such file or directory
In file included from /usr/include/asm/fcntl.h:1,
from /usr/include/linux/fcntl.h:4,
from memory.c:28:
/usr/include/asm-generic/fcntl.h:96: error: expected specifier-qualifier-list before 'pid_t'
memory.c:31:45: error: asm/system.h: No such file or directory
memory.c:34:49: error: asm/uaccess.h: No such file or directory
memory.c:37: error: expected declaration specifiers or '...' before string constant
memory.c:37: warning: data definition has no type or storage class
memory.c:41: warning: 'struct file' declared inside parameter list
memory.c:41: warning: its scope is only this definition or declaration, which is probably not what you want
memory.c:41: warning: 'struct inode' declared inside parameter list
memory.c:42: warning: 'struct file' declared inside parameter list
memory.c:42: warning: 'struct inode' declared inside parameter list
memory.c:43: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'memory_read'
memory.c:44: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'memory_write'
memory.c:49: error: variable 'memory_fops' has initializer but incomplete type
memory.c:50: error: unknown field 'read' specified in initializer
memory.c:50: error: 'memory_read' undeclared here (not in a function)
memory.c:50: warning: excess elements in struct initializer
memory.c:50: warning: (near initialization for 'memory_fops')
memory.c:51: error: unknown field 'write' specified in initializer
memory.c:51: error: 'memory_write' undeclared here (not in a function)
memory.c:51: warning: excess elements in struct initializer
memory.c:51: warning: (near initialization for 'memory_fops')
memory.c:52: error: unknown field 'open' specified in initializer
memory.c:52: warning: excess elements in struct initializer
memory.c:52: warning: (near initialization for 'memory_fops')
memory.c:53: error: unknown field 'release' specified in initializer
memory.c:53: warning: excess elements in struct initializer
memory.c:53: warning: (near initialization for 'memory_fops')
memory.c:57: warning: data definition has no type or storage class
memory.c:57: warning: parameter names (without types) in function declaration
memory.c:58: warning: data definition has no type or storage class
memory.c:58: warning: parameter names (without types) in function declaration
memory.c: In function 'memory_init':
memory.c:81: error: 'GFP_KERNEL' undeclared (first use in this function)
memory.c:81: error: (Each undeclared identifier is reported only once
memory.c:81: error: for each function it appears in.)
memory.c:86: warning: incompatible implicit declaration of built-in function 'memset'
memory.c: At top level:
memory.c:116: warning: 'struct file' declared inside parameter list
memory.c:116: warning: 'struct inode' declared inside parameter list
memory.c:116: error: conflicting types for 'memory_open'
memory.c:41: note: previous declaration of 'memory_open' was here
memory.c:125: warning: 'struct file' declared inside parameter list
memory.c:125: warning: 'struct inode' declared inside parameter list
memory.c:125: error: conflicting types for 'memory_release'
memory.c:42: note: previous declaration of 'memory_release' was here
memory.c:136: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'memory_read'
memory.c:158: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'memory_write'
make: *** [memory] Error 1
sathish/sathish-desktop:~$
Please let me know the reason for this error , i tried
sudo apt-get update
but in vain.
Thanks in advance.

Dynamic File Editing

Dynamic File Editing

I have a directory for every area code 200-999, and inside each directory is a directory for each prefix that we have added, and one file name 'prefixes' that contains one prefix per line like this '200,0,0,0,0,0,0,0,0'.

Right now every 'prefixes' file contains prefixes 200-999, but if we try to enter a phone number without the prefix directory it crashes the system.

So, I need a script to check each area code directory and remove all the prefix lines from the 'prefixes' file that don't have a corresponding prefix directory.

I hope this makes sense, I am completely lost and desperate for help.

Help for a windows refugee

Help for a windows refugee

I'm a long term Windows developer and I have a project underway now which is modifying a linux embedded system to my own needs. The host system is Ubuntu 10.04 and target is arm using CodeSourcery tools. The code is pure C (no c++)/

The embedded sofware is complex and 'open source' so has source code rather than documentation. The system was written with vi and make over some years. The makefile pulls together a few dozen projects and tools in a pretty complex way - but it works.

So far I've been struggling along (more or less succesfully) with gvim or gedit and make. However, it's not particularly productive. The main virtue of gvim is the integration with ctags which lets me navigate the source in a helpful fashion, but I'm finding it struggle to adapt to the (for me) unusual keyboard commands.

What I want is a development environment which can

use an editor in a which which is more or less familiar to a Windows drone (gedit works here).
Run the makefile (which uses an arm compiler) and ideally navigate to any error line.
Find definitions of functions and variables (across all the libraries which are part of the project).
Ideally, find references to functions and variables and other such advanced things.
Syntax and method completion and auto prompt would be nice too, but not essential.

I've tried to use eclipse but failed to make sense of it in this context (I should be able to make a project from a makefile, but it doesn't work). I have to say I've never had much luck with eclipse, though if it worked in this context it would be good.

Any suggestions or help would be very gratefully received!

Iain

Issue creating SSL socket with Perl -- IO::Socket::SSL

Issue creating SSL socket with Perl -- IO::Socket::SSL

Hello,

I am new to Perl and I'm attempting to interface with Virtuozzo's XML API and seem to be encountering issues establishing a SSL socket -- the SSL handshake is failing.

Error:

Code:

[root@srv perl]# perl wind0ze_api.pl
Connecting to Agent...

DEBUG: .../IO/Socket/SSL.pm:1545: new ctx 41090720
DEBUG: .../IO/Socket/SSL.pm:334: socket not yet connected
DEBUG: .../IO/Socket/SSL.pm:336: socket connected
DEBUG: .../IO/Socket/SSL.pm:349: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:392: Net::SSLeay::connect -> 0
DEBUG: .../IO/Socket/SSL.pm:440: connection failed - connect returned 0
DEBUG: .../IO/Socket/SSL.pm:1276: SSL connect attempt failed because of handshake problemserror:00000000:lib(0):func(0):reason(0)

DEBUG: .../IO/Socket/SSL.pm:1276: IO::Socket::INET configuration failederror:00000000:lib(0):func(0):reason(0)

DEBUG: .../IO/Socket/SSL.pm:1582: free ctx 41090720 open=41090720
DEBUG: .../IO/Socket/SSL.pm:1590: OK free ctx 41090720
Error establishing SSL socket at wind0ze_api.pl line 21.
[root@srv perl]#

When I attempt to establish a non-SSL socket it works without an issue.

I have also tested the connection via openssl CLI and it works, so I'm certain it's not related to any packet filtering.

Code:

openssl s_client -debug -connect $IP:4434 -cipher ADH-AES256-SHA
^ WORKS

However, if I omit the '-cipher' option then openssl also will yield a handshake error:

Code:

[root@srv perl]# openssl s_client -debug -connect $IP:4434
CONNECTED(00000003)
write to 0xbcea350 [0xbcead90] (121 bytes => 121 (0x79))
0000 - 80 77 01 03 01 00 4e 00-00 00 20 00 00 39 00 00  .w....N... ..9..
0010 - 38 00 00 35 00 00 16 00-00 13 00 00 0a 07 00 c0  8..5............
0020 - 00 00 33 00 00 32 00 00-2f 03 00 80 00 00 05 00  ..3..2../.......
0030 - 00 04 01 00 80 00 00 15-00 00 12 00 00 09 06 00  ................
0040 - 40 00 00 14 00 00 11 00-00 08 00 00 06 04 00 80  @...............
0050 - 00 00 03 02 00 80 00 00-ff 0b ca 9e 3e e5 69 5f  ............>.i_
0060 - 38 f5 ad 54 98 29 45 21-78 40 07 20 34 d8 39 fc  8..T.)E!x@. 4.9.
0070 - b0 85 99 a3 d6 b4 64 42-1d                        ......dB.
read from 0xbcea350 [0xbcf02f0] (7 bytes => 0 (0x0))
26080:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:
[root@srv perl]#

Code:

#!/usr/bin/perl -w
use strict;
use IO::Socket::INET;
use IO::Socket::SSL qw(debug3);
use Net::SSLeay;
use Socket;

use constant CONF_CONNECTION => {
      ip => '$IP',
      port => '4434',
      class => 'IO::Socket::SSL'
};

# Null-terminating character (packet separator).

use constant MSG_TERMINATOR => "\0";
local $/ = &MSG_TERMINATOR;


print "Connecting to Agent...\n\n";
our $socket = new IO::Socket::SSL(
PeerAddr => &CONF_CONNECTION->{ip},
PeerPort=> &CONF_CONNECTION->{port},
Proto => 'tcp',
Reuse => 1) || die "Error establishing SSL socket";

my $ssl_sock = IO::Socket::SSL->start_SSL(
SSL_verify_mode => 0,
$socket);

my $hello = $ssl_sock->getline;
chomp($hello);
print $hello;

P.S. numeric value of $IP omitted for security reasons. :)

I have also read the IO::Socket:: CPAN pages but it's a lot of information to take in and isn't written in the most user-friendly format. I would appreciate any pointers.

problem with DHCP connection

problem with DHCP connection

Hi All,

3 years ago I installed SuSE Linux on my laptop. At the beginning I used DHCP internet connection without any problem. 1 year ago I moved to another working place, where I needed to install a VPN client to connect to the internet. In addition, a new version of the kernel was installed to be compatible with the client. Now, I need to use DHCP again, but my system can not access to the network with the DHCP connection. Please help to solve the problem. Which files I need to look into? Thank you in advance.

Is open source a subset of proprietary software?

Is open source a subset of proprietary software?

First of this is not a out-lash at open source, or Linux but an honest question.
I am still relatively new to the unique world of Linux. Started off with Ubuntu when Unity came out, but am now currently using Linux Mint 11. So far I have loved many things about Linux and have learned alot but I am still full of questions. I have been for the past month and a half trying to avoid windows and making Linux my primary desktop but I keep on asking my self certain questions. If all the programs on Linux are open source and available for all then that means an operating system like windows has complete access to those same programs as well. But the other way around doesn't seem to be true. Linux does not have access to native programs for windows. For example I use code-blocks IDE when I am in Linux but I could also use this in windows. But I could not use Visual Studio in Linux which is what I prefer while I am in windows. I know that wine exists but I trying to speak about plain old Linux and plain old windows. So since the above from my experiences seems to ! be true, is open source considered a subset of proprietary software? If it is, then is it logical to continue to use Linux, from a software perspective? Now I agree that it is best to run applications on a more stable operating system period. But to be honest I have not run into any major problems in windows(7). So to me it is just as stable for my personal use. I also know and agree that its awsome to be a linux user and know I would never have to inevetst hundereds of dollars into a new operating system again! But I am not planning on buying a new operating sytem any time soon anyway. So back to my original question, Is open source a subset of proprietary software?