Professional Documents
Culture Documents
PRCTICA 1
Pgina - 0
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
NDICE
1 OBJETIVOS......................................................................................................................................................2
4 RESUMEN DE CONOCIMIENTOS.............................................................................................................14
6 ANEXOS.........................................................................................................................................................15
6.1 Manual del editor elvis........................................................................................................................15
6.2 Manual del editor mined......................................................................................................................18
Pgina - 1
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
1 OBJETIVOS
El emulador QEMU permite simular una mquina virtual tipo PC con arquitectura IA32 (x86)
y ejecutar cdigo 8086 directamente sobre la CPU del computador. Sobre esta mquina virtual
se pueden arrancar diversos sistemas operativos como: Linux, MINIX, Microsoft Windows,
etc. En este sentido, es similar a otros entornos como VMware Workstations.
Una forma de arrancar un sistema operativo, sea MINIX, sobre una mquina virtual QEMU es
utilizar una imagen de disco un fichero preparado especialmente como si de un disco de
arranque se tratase- de tal forma que si algo va mal, los errores quedan circunscritos al
contenido de dicho fichero sin afectar al resto del sistema.
Pgina - 2
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Para poder utilizar el entorno de prcticas, tenemos que traernos unos archivos a
nuestro PC. Estos archivos, as como una cuenta privada para cada grupo de prcticas,
reside en un servidor del departamento. Para poder traernos archivos desde el servidor
a nuestro PC, utilizaremos el protocolo Samba (una herramienta que permite compartir
archivos e interoperar entre Windows y Linux). Para acceder al servidor necesitaremos
un Nombre de usuario y una Contrasea. Solicitrsela al profesor de prcticas:
Nombre de usuario:
Contrasea:
Pgina - 3
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Pgina - 4
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Esta carpeta tiene derechos de lectura para todos los grupos de prcticas y es donde se
dejar toda la informacin que se considere conveniente para el desarrollo de las
prcticas. De momento est el archivo Minix-qemu.img que es una imagen de disco
con MINIX para poder arrancar sobre el emulador QEMU, as como el archivo
disquete.img que es una imagen de disquete vaco y del que hablaremos ms adelante.
Arrancar un terminal para trabajar en modo comando, para ello, hacer click en el icono
rotulado Terminal.
Pgina - 5
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Ahora ya podemos arrancar una mquina virtual QEMU con una imagen de disco con
MINIX. Para ello, teclear qemu fda disquete.img Minix-qemu.img. Al
principio del arranque, durante unos pocos segundos, tendremos una ventana con un
aspecto como el siguiente:
Pgina - 6
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Las opciones que figuran al final nos permiten seleccionar la imagen del ncleo de
MINIX que deseamos arrancar. En nuestro caso, en tanto en cuanto no modifiquemos
el ncleo, slo tenemos una imagen, la original, que es la que arrancar sin necesidad
de indicar nada. Finalmente, acaba quedando una ventana con el aspecto siguiente:
Pgina - 7
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
El archivo disquete.img es, precisamente, una imagen de disquete vaco que nos permitir
llevarnos ficheros especficos a casa en vez de toda la imagen de disco MINIX.
Para poder manipular esta imagen de disquete desde MINIX, utilizaremos el comando mtools
como veremos ms adelante- que permitir leer ficheros Windows desde el disquete as
como grabar ficheros de MINIX al disquete en formato Windows.
Pgina - 8
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Si nuestro PC tiene Linux, basta con llevarse el fichero con la imagen de disquete
disquete.img y montarla, para poder editar los ficheros que contenga.
Pgina - 9
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Desde el terminal podemos situarnos en /mnt y ver que tenemos el fichero nombres
con el contenido correcto. Tambin podemos abrir la carpeta /mnt desde el entorno
grfico si nos es ms cmodo.
Para desmontar una memoria USB, acceder al Men del sistema y la opcin de
Dispositivos de almacenamiento tal y como se muestra a continuacin:
Pgina - 10
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Pgina - 11
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Lo primero que necesitamos para recompilar MINIX son los ficheros fuente del sistema.
Dichos ficheros fuente se encuentran bajo el directorio /usr/src. En particular, los ficheros
correspondientes al ncleo (kernel), se encuentran en el directorio /usr/src/kernel.
Arrancar QEMU con la imagen MINIX, da igual que sea la original o la modificada en
la parte anterior. Fijarse bien en algn mensaje que se muestre antes de pedir al
usuario su login de entrada al sistema, ya que este mensaje puede servir para
localizar el punto del cdigo donde hay que escribir el nuevo mensaje.
Pgina - 12
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Entrar al sistema como root y situarse en el directorio que contiene el cdigo fuente
del kernel /usr/src/kernel.
Ejecutar el comando ls para ver el contenido del directorio y anotar las extensiones
de todos los ficheros que se vean y explicar qu tipo de ficheros son (basta con indicar
los que se reconozcan).
Editar el fichero main.c para incluir el nuevo mensaje. La sentencia que se utiliza para
mostrar los mensajes del kernel es kprintf.
Una vez modificado el fichero fuente, tenemos que dar la orden de compilacin. Para
ello, situarse en el directorio /usr/src/tools. En este directorio existe un fichero
llamado Makefile que contiene las reglas para compilar, construir nuevas imgenes
del sistema, etc. Gracias al contenido de este fichero, no hay que preocuparse de qu
ficheros hay que recompilar y en qu orden, ni de dnde deben quedar los ficheros
generados, ya que toda esta informacin est previamente especificada en forma de
reglas. Teclear: make install [Nota: La primera vez tarda bastante]
Si la compilacin ha ido bien, el prompt del sistema ser #, en caso contrario ser
*.
Las imgenes del ncleo, tanto la original como la que acabamos de generar, se
guardan en el directorio /boot/image. Listar ls -l /boot/image el contenido de
Pgina - 13
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
dicho directorio para comprobar que tenemos dos imgenes. Recordar que cuando
arrancamos MINIX, la opcin 1 del men de arranque coge la imagen original y la
opcin 3 la ltima imagen generada.
Si la recompilacin ha ido bien, salir del sistema y reiniciar con la nueva imagen
tecleando los comandos:
En principio no hace falta teclear ninguna opcin en el men de arranque ya que por
defecto se toma la opcin 3 que es la que arranca la imagen recin modificada, pero es
mejor indicar la opcin deseada. Si todo se ha hecho bien, deber verse el mensaje
introducido antes de la peticin de login. En caso contrario, arrancar con la imagen
original opcin 1 del men de arranque del monitor- y repetir todo el proceso.
Pgina - 14
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
4 RESUMEN DE CONOCIMIENTOS
5 PARA SABER MS
Pgina - 15
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
6 ANEXOS
NAME
elvis, ex, vi - The editor
SYNOPSIS
elvis [flags] [+cmd] [files...]
DESCRIPTION
Elvis is a text editor which emulates vi/ex.
OPTIONS
-r To the real vi, this flag means that a previous edit
should be recovered. Elvis, though, has a separate
program, called elvrec(1), for recovering files. When
you invoke elvis with -r, elvis will tell you to run
elvrec.
-t tag
This causes elvis to start editing at the given tag.
-m [file]
Elvis will search through file for something that looks
like an error message from a compiler. It will then
begin editing the source file that caused the error,
with the cursor sitting on the line where the error was
detected. If you don't explicitly name a file, then
"errlist" is assumed.
Pgina - 16
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
-w winsize
Sets the "window" option's value to winsize.
+command or -c command
If you use the +command parameter, then after the first
file is loaded command is executed as an EX command. A
typical example would be "elvis +237 foo", which would
cause elvis to start editing foo and then move directly
to line 237. The "-c command" variant was added for
UNIX SysV compatibility.
FILES
/tmp/elv*
During editing, elvis stores text in a temporary file.
For UNIX, this file will usually be stored in the /tmp
directory, and the first three characters will be
"elv". For other systems, the temporary files may be
stored someplace else; see the version-specific section
of the documentation.
tags This is the database used by the :tags command and the
-t option. It is usually created by the ctags(1) pro-
gram.
.exrc or elvis.rc
On UNIX-like systems, a file called ".exrc" in your
home directory is executed as a series of ex commands.
A file by the same name may be executed in the current
directory, too. On non-UNIX systems, ".exrc" is usu-
ally an invalid file name; there, the initialization
file is called "elvis.rc" instead.
SEE ALSO
ctags(1), ref(1), elvrec(1), elvis(9).
BUGS
There is no LISP support. Certain other features are miss-
ing, too.
AUTHOR
Steve Kirkendall
kirkenda@cs.pdx.edu
Many other people have worked to port elvis to various
Pgina - 17
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Pgina - 18
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
The editor maintains one save buffer (not displayed). Commands are
present to move text from the file to the buffer, from the buffer to the
file, and to write the buffer onto a new file. If the edited text
cannot be written out due to a full disk, it may still be possible to
copy the whole text to the save buffer and then write it to a different
file on a different disk with CTRL-Q. It may also be possible to escape
from the editor with CTRL-S and remove some files.
Pgina - 19
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
CURSOR MOTION
arrows Move the cursor in the indicated direction
CTRL-A Move cursor to start of current line
CTRL-Z Move cursor to end of current line
CTRL-^ Move cursor to top of screen
CTRL-_ Move cursor to end of screen
CTRL-F Move cursor forward to start of next word
CTRL-B Move cursor backward to start of previous word
SCREEN MOTION
Home key Move to first character of the file
End key Move to last character of the file
PgUp key Scroll window up 23 lines (closer to start of the file)
PgDn key Scroll window down 23 lines (closer to end of the file)
CTRL-U Scroll window up 1 line
CTRL-D Scroll window down 1 line
MODIFYING TEXT
Del key Delete the character under the cursor
Backspace Delete the character to left of the cursor
CTRL-N Delete the next word
CTRL-P Delete the previous word
CTRL-T Delete tail of line (all characters from cursor to end of
line)
CTRL-O Open up the line (insert line feed and back up)
CTRL-G Get and insert a file at the cursor position
Pgina - 20
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
BUFFER OPERATIONS
CTRL-@ Set mark at current position for use with CTRL-C and
CTRL-K
CTRL-C Copy the text between the mark and the cursor into the
buffer
CTRL-K Delete text between mark and cursor; also copy it to the
buffer
CTRL-Y Yank contents of the buffer out and insert it at the
cursor
CTRL-Q Write the contents of the buffer onto a file
MISCELLANEOUS
numeric + Search forward (prompts for regular expression)
numeric - Search backward (prompts for regular expression)
numeric 5 Display the file status
CTRL-] Go to specific line
CTRL-R Global replace pattern with string (from cursor to end)
CTRL-L Line replace pattern with string
CTRL-W Write the edited file back to the disk
CTRL-X Exit the editor
CTRL-S Fork off a shell (use CTRL-D to get back to the editor)
CTRL-\ Abort whatever the editor was doing and wait for command
CTRL-E Erase screen and redraw it
CTRL-V Visit (edit) a new file
Author
Pgina - 21
E.U. de Informtica-UPM Sistemas Operativos IC Curso 15/16
Pgina - 22