Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 1.2 KB

README.md

File metadata and controls

65 lines (43 loc) · 1.2 KB

/dev/tictactoe

A Linux driver for a character device which can be used to play Tic-tac-toe.

Usage

Disclaimer: I make no guarantees about the soundness of the driver code. Use with caution (i.e. only in a virtual machine).

Building

Clone this repository, cd to it, then run make.

Loading

After building the module, run insmod tictactoe.ko as root to load it.

Using the device

After loading the module, player X can write grid coordinates (ranging from 1 to 3, format XY) to /dev/tictactoe to make their first move:

# echo 12 > /dev/tictactoe

After player X has made their move, player O can do the same:

# echo 22 > /dev/tictactoe

To inspect the current state of the game, simply read from /dev/tictactoe:

# cat /dev/tictactoe
#####
# X #
# O #
#   #
#####

It's X's turn!

Alternatively, you can watch the file in a separate terminal for automatic updating:

# watch -n 0.5 cat /dev/tictactoe

To start a new game, write reset to /dev/tictactoe:

# echo reset > /dev/tictactoe

Unloading

Run rmmod tictactoe as root to unload the module.