ECS150 Course Website

last updated
Help / FAQ

Quick Navigation

  1. How do I login remotely?
  2. How do I use man pages?
  3. How do I make a Makefile?
  4. How do I use errno?
  5. Where can I find some decent reference cards?
  6. Why am I getting this compile error?

Remote Access

More information on remote login into the CSIF computers can be found in the CSIF FAQ.

Account Access (SSH)

You may access your CS account via SSH. The hostname you want to connect to is:

pc<#>.cs.ucdavis.edu

where <#> is a number between 1 and 60. The CSIF FAQ has information on SSH clients for Windows. You can also find SSH and SFTP clients for Windows here and here.

Transferring Files (SFTP)

To transfer files to your CS account, you must use SFTP. The hostname is the same as above. For SFTP commands, see the CSIF FAQ. A command-line SFTP client for Windows can be found here.

Using Minix Manual Pages (man)

One of your first resources for finding information on Minix system calls should be the man pages (manual pages). You can find more information on how to use man by typing the following:

man man

There are also a few good man resources on the web. Here are just a couple:

Makefiles

Some program assignments require you to turn in a Makefile. If you have not had experience creating makefiles before, you can find a tutorial at http://www.eng.hawaii.edu/Tutor/Make/. A simple makefile looks similar to:

all:
	cc -g program1.c -o program1

clean:
	rm -f program1

Using the makefile above, we would compile program1.c by the following command:

make all     (or by typing make)

To clean up the object files, we could run the command:

make clean

This illustrates the basic functionality required for all makefiles in this class.

Using errno

One way to debug your programs is to make use of the errno variable in errno.h. Whenever a system call results in an error, the value of errno is set. To use errno in your Minix C programs, do the following:

  1. Add library errno.h to your code.
  2. Check the return value of a system call.
  3. If the return value indicates an error occured, print out errno.
  4. Open /usr/include/errno.h and check what message the value of errno corresponds to.

    -or-

    Type man errno and check what message the value of errno corresponds to.

Take for example the following code snippet:

rval = chdir( path );

if( rval == -1 )
	printf( "chdir( %s ) failed... errno: %i\n", path, errno );

If we got the following output:

chdir( nowhere ) failed... errno: 2

We could then look in /usr/include/errno.h to see that an errno value of 2 corresponds to the message "no such file or directory".

You can always find more information from the man pages. You can also download errno_example.c for another example Minix C code snippet using errno.

Reference Cards

It may be helpful to print off a few reference cards (like vi commands, or basic Unix commands). Here are a few sites you can find some decent reference cards:

Common Compile Errors

There are some common compile errors/warnings with common causes. Here are a few:

Message: int not expected
Cause: This is most commonly caused by not declaring all variables at the start of a block.
Message:/ not expected
Cause: This is most commonly caused by attempting to use // style comments, which are not supported by the C-compiler in Minix. Use /* */ style comments instead.
Message:(warning) comment inside comment ?
Cause: The C-compiler in Minix does not support nested comments.
Message:(warning) 'main' old-fashioned function definition
Cause: The C-compiler in Minix expects to see main defined with parameters - like "int main( int argc, char ** argv )" or like "void main( void )".
Message:(warning) implicit declaration of function printf
Cause: This usually happens when the proper header files are not included. For this example, make sure #include <stdio.h> is at the top of the program file.
Message:(warning) implicit declaration of function wait
Cause: This usually happens when the proper header files are not included. For this example, make sure #include <sys/wait.h> is at the top of the program file.
Message:(warning) implicit declaration of function kill
Cause: Some header files only include function defintions if _POSIX_SOURCE is defined. To fix this, place "#define _POSIX_SOURCE" at the very top of the program file (before the include statements).