►
From YouTube: RustConf 2019 - Syscalls for Rustaceans by Gargi Sharma
Description
RustConf 2019 - Syscalls for Rustaceans by Gargi Sharma
Even if you haven't used Rust's nix package, and have just written println!("Hello, World!"), you have most certainly used syscalls. Syscalls are an interface between the operating system and a user program.
strace can be used to debug git performance issues, examining internals of closed source programs, sandboxing programs and is a powerful debugging tool under your arsenal. This talk explains what syscalls are, how they work, how you can track them using strace and how you can write your own syscall tracer (strace) in Rust!
A
Hi
everyone,
my
name,
is
Carly
and
I'm
going
to
be
talking
about
just
cause
fire
stations.
Oh
sorry,
I
forgot
that
now
I
don't
need
to
speak
up
in
war,
yeah
yeah,
and
if
you
want
to
follow
the
slides
alone,
here's
the
link
and
yeah.
Let's
get
started
so
before
I,
even
begin
to
talk
about
system.
Cuz
I
want
to
talk
about
what
it
means
to
be
a
systems,
programming
language.
So
it's
a
term
you
hear
a
lot
in
contacts
with
traffic.
A
Trust
is
a
new
systems,
programming
language
and
but
what
makes
a
programming
language,
a
systems,
programming
language
and
what
makes
C
and
C++
and
Rus
good
candidates
first
essential
gaming
languages
where
it
says
Python
and
Perl,
and
not
so
good
candidates
for
assistance
programming
languages
so
only
take
us
to
take
us
to
a
tray
of
history
and
talk
about
evolution,
assistance
regarding
languages,
so
the
two
things
that
I
will
be
sticking
to
in
this
talk
will
be.
What
does
it
mean
to
be
assistance
regarding
language?
A
What
makes
trust
a
good
candidate
for
systems
programming,
language
and
third
is
learning
about
system
calls
and
writing
your
first
programming.
Our
first
system
for
a
German
trust,
if
you
haven't
written
it
already
and
to
empower
people
to
write
more
systems
programs
in
rust.
So
my
research
tells
me
that
the
first
time
systems
the
systems
program
term
was
coined
was
in
1970s.
A
So
this
was
the
era
where
we,
where
we
were
improving
on
assembly
and
the
author
of
this
paper,
consistent
programming,
language
defined
assistant
program
as
an
integrated
set
of
sub
programs
in
exceeding
some
threshold
of
size
of
complexity.
So
some
examples
of
such
systems
would
be
like
simulator
or
time-sharing
systems,
information
management
systems,
and
then
the
author
goes
on
to
define
what
system
program
is
so
assistant
program
is
defeated,
likely
to
be
used
to
support
other
software
programs,
so
I'm
system.
A
A
A
It
makes
sure
you
have
programs
to
access
permissions
to
handle
multiple
files
of
accessing
files
and
loading
blocks
into
memory
and
so
on,
so
it
is
likely
to
be
continuously
evolving,
so
it
is,
in
contrast
with
the
systems
of
nineteen
seventies,
where
you
had
one
shot:
one
shot
solution
using
an
application
rather
than
continously
evolving,
o
canonist
e
evolving
systems.
So,
oh
sorry,
the
key
idea
in
this
paper
is
descriptive,
so
defining
a
system
but
the.
But
the
key
idea
in
this
paper
is
prescriptive.
A
So
a
language
which
can
be
used
without
undue
concern
for
bit
twiddling,
which
can
be
used
to
design
and
write
more
systems
without
unnecessary
overhead
on
resources
and
the
last
paper
from
1970s
was
this
program
was
the
paper
consistent
programming
but
Donovan.
So
the
first
time
we
had
computers,
we
dealt
with
them
using
on
and
off
switches,
and
then
we
wanted
to
do
more
complicated
things
like
if
I
have
Y,
which
is
50
and
I,
want
to
calculate
X,
which
is
30
into
R.
How
do
I
do
that?
A
A
Most
researchers
saw
systems
systems,
programming
languages,
in
contrast
with
assembly
programming.
There
was
something
no
good
tools
to
build,
but
both
systems.
However,
in
the
mid
90s
it
was
the
rise
of
scripting
like
there's
a
dynamically
typed
scripting
languages,
so
bash
languages
like
Perl
Python
Adobe
you
gain
steam
and
make
make
made
their
way
to
the
works
through
the
mainstream
and
systems
programming
languages
who
are
designed
to
been
more
primitive
computer
elements
versus
cryptic
languages
were
designed
for
gluing.
So
you
can
separate
scripting
languages
and
systems
languages
on
technically.
A
Languages
like
go
and
go
etc,
say:
go
etcetera
put
in
resources
so
that
garbage
collector
languages
also
performed
well
so,
which
are
leads.
All
of
this
leads
us
to.
What
does
it
mean
to
be
a
system
for
learning
language
today,
so
languages
in
the
category
of
C
and
C++
and
rust
in
D
are
distinguished
in
the
terms
of
the
level
of
abstraction
they
provide
you
from
the
machine,
so
the
languages
expose
the
videos
of
underlying
hardware
like
memory
allocation,
layout,
etc.
A
So
when
you
have
a
efficiency
problem,
is
it
in
your
part
to
eliminate
the
bottleneck?
So
the
wonderful
part
about
these
languages
is
that
they
provide
you
confidence.
So
if
you
have
a
statically,
typed
language-
and
you
say
this
language-
gives
me
the
confidence
that,
if
I'm
adding
these
two
integers
I'm
going
to
get
a
result,
which
is
an
integer
the
same
way,
these
languages
give
you
the
confidence
that,
if
I'm
executing
this
instruction
and
a
machine,
then
it
will
work
exactly
as
I
wanted
to
so
lower
level.
A
Programmers
should
seek
you
understand
how
the
system
design
could
be
adapted
to
the
reality
of
modern-day
hardware
and
something-something.
Rust
does
really
well
is
that
it
takes
the
ideas
of
the
functional
programming
and
and
lower-level
problems
like
futures
and
type
safety
of
course,
and
uses
them.
A
I
uses
them
to
make
the
language
better,
and
we
should
also
consider
the
added
benefits
of
using
our
switches
it
provide,
which
are
enabled
for
us
types,
establishes
static
information
for
control
and
safe
showers
of
pointillist
data
structures
and
software
fault
isolation,
and
with
that
with
with
the
history
of
the
sensor
having
languages
and
where
we
stand
today,
I
want
to
jump
into
the
next
part
of
this
talk,
which
is
oh
sorry
before
that
you
can
throw
everything.
I've
said
out
of
the
windows
and
systems.
A
So
with
that
I
want
to
jump
on
to
the
next
part
of
my
talk,
which
is
writing
our
own
s.
Tres.
So,
for
this
I
hope
to
empower
you
to
like
your
own
s.
Tres
are
even
more
complicated
systems
Perkins.
A
A
Not
so
if,
though,
I
write
esoteric
and
some
of
them
are
very
common,
so
some
of
the
common
ones
for
like
file
access,
a
create,
read,
write,
open
and
close,
so
I
included
create
here,
because
one
can
Thompson
was
asked
if
he
had
any
regrets
about
Unix.
He
said
I
wish
I
had
named,
let's
see,
Rea
te
and
not
G,
and
which
is
also
this
system.
Guy
is
obsolete
now,
because,
if
open,
but
I
included
it
for
that
Chuck
so
and
the
net
more
system
cause
so
for
the
process
control.
A
A
So
what
happens
when
assistant
occur?
Is
that
say
we
want
to
read
from
a
file,
so
the
user
program
would
push
the
number
of
bytes.
It
wants
to
read
push
the
buffer,
which
is
the
address
of
where
it
wants
the
result
of
the
reader
to
be
stored
and
the
file
descriptor
into
registers,
and
it
will
call
feed,
and
then
it
gives
you
a
library
procedure
which
will
put
the
code
for
the
system
call
in
a
register,
so
each
system
called
has
a
number
associated
with
it,
for
example,
either
0
openness,
2
and
so
on.
A
A
So
that
number
is
the
number
of
the
system
call
and
in
the
operating
system
there's
an
array
where,
like
the
colonel
goes,
are
you
sent
zero
and
zero
Main
Street,
so
it
go
and
look
into
the
registers
of
like
what
file
I
have
to
read
and
where
I
have
to
store
the
result
of
the
read
and
once
the
colonel
does
that
it's
written
there's
another
context,
switch
back
to
the
library
procedure
and
finally
to
the
user
program.
So
one
thing
to
note
is
that
system
calls
are
fairly
expensive.
A
You
have
two
context:
switches
involved,
yeah,
so
making
a
system
cut.
Is
you
have
a
register
where
you
would
have
the
file
descriptor
stored
at
register
where
you
have
the
buffer
stored
and
the
register
with
the
count
of
bytes?
That
are
that
are
to
be
that
Oh
dad,
for
example,
so
you
set
up
a
register
with
the
system
card
number
and
parametres.
You
send
a
trap
to
the
kernel
and
you
get
the
result
stone
in
the
register.
A
A
It
has
our
King
types,
so
it
gives
you
white
pointers,
a
lot
of
white
pointers
that
you'd
have
to
use.
Oh,
but
it's
the
only
API,
so
that's
cool,
so
we
so
now
that
we
have
an
idea
of
what
happens
when
assist
occurs,
and
how
do
you
make
assess
color
I
want
to
jump
on.
What's
what
is
as
trace
so
X
traces
are
the
nasty
buggin
you
which
allows
you
to
debug
the
source
programs,
for
example?
If
you
have
and
it
allows
you
to
identify
it-
allows
you
to
identify
bottlenecks
in
the
program.
A
So
we
already
know
that
system
calls
are
expensive.
So
if
you
have
a
program
and
what
you
have
optimize
it
for
its
performance,
then
you
see
that
it's
making
more
open
calls
than
you
thought
it
would.
You
can
go
and
optimize
trace
or
tell
you
how
many
open
system
costs
that
your
program
is
making
and
I
can
go
and
up
demonstrate
that
and
it's
also
invaluable.
A
When
you
have
closed
source
program,
you
can't
just
go
and
attach
gdb
and
say:
oh,
please
stop
at
like
12,
because
you
don't
know,
what's
it
like
12.
So
in
that
case,
if
you
have
a
cursors
program
which
has
which
you
thought
was
oh
it's
not
working
like
you
wished,
it
would
and
you
you
go
and
see
the
s
trace
for
it
and
it's
opening
X
instead
of
opening.
Why
he
cast
race
will
tell
you
that.
A
A
It
first
has
an
exact
system
code
which
is
executing
my
script,
and
then
it
has
a
break
and
access
and
M
map
and
so
on,
and
it
lists
all
the
system
cards
that
are
made
in
that
order
and
if
I
have
our
s,
trees,
C,
which
will
tell
me
the
count
of
all
the
system,
calls
that
were
made
so
I
have
eleven
system
comes
to
read
a
nine
to
open,
and
so
on
twelve
tell
me:
oh
this
isn't
cars
that
were
made,
which
is
pretty
honey.
So
that's
the
laughs.
A
Now
it's
the
last
part
of
myself
wishes.
We
will
write
our
own
s
trace,
so
we
need
three
things
to
write
our
own
s
trace.
One
is
we
need
to
know
how
to
observe
another
process,
which
is
an
important
part,
because
we
want
to
find
out
how
many
some
colace
other
process
is.
Making.
Second,
is
how
to
trap
assistant
go
once
we
know
that
we
have
a
process.
A
So
the
first
line
of
this
code
is
the
process
giving
me
explicit
permission
to
trace
it,
and
the
second
is
me
spawning
this
process
so
that
I
can
be
in
the
parent
name,
space
of
the
process,
and
the
next
is
the
next
thing
we
care
about
is
how
to
chop
the
system
code,
so
P
traits
do
the
rescue
again
so
every
time
the
process
that
we
are
tracing
makes
a
system
call.
A
sig
shop
is
sent
to
the
tracer
and
then
execution
stops.
A
So
you
can
go
and
check
the
register
if
you
want
to-
and
you
wait
on
this
process,
so
you
will
stop
every
time.
I
said
a
cig
trap
is
send
so
few
choice
to
the
rescue.
Again,
it
has
a
flag
called
P
trade
system
car,
which
means
that
every
time
a
system,
cars
called
a
sec
traffic,
miss
path
would
be
would
be
a
cig
trap
would
be
sent
and
you
can
stop
and
inspect
the
registers
or
arguments
to
the
system
call
if
you
wish
to,
and
then
you
can
start
race.
A
A
You
know,
Sophie
trace,
has
a
flag
called
P
trace,
underscore
cash
registers
which
will
get
you
all
the
registers,
but
once
you
get
all
the
registers,
you
know
you
have
to
know
which
register
stores,
which
value
so
I
found
out
through
googling
that
the
other
extra
gesture
stores
the
value
of
this
stores,
the
number
of
the
system
car.
So
you
can
use
that
to
find
out
what
system
code
was
made
and
you
know
I
have
a
demo.
A
A
And
if
I
want
to
run
s
trace
on
hello,
oops,
sorry
yeah,
then
it
says
the
Raskin
and
telling
me
that
Oh
sounds
was
gone
nine
times
and
F
start
with
seven
times,
and
readers
cut
seven
times,
which
is
pretty
neat
yeah.
So
in
conclusion,
I
want
to
say
say
in
conclusion:
I
want
to
say
that
trust
is
very
empowering
and
it's
so
much
cooler
than
C
or
C++,
because
because
it
follows
the
ax
that
like
if
it
compiles
it
will
work
which
is
which
is
not
true
for
C
or
C++
at
R.
A
And
if
you
were
doing
this,
you
would
have
to
do
memory,
allocation
and
other
things
which
are
hard
and
scary
for
new
people.
Yeah
so
and
I
would
like
to
give
it
a
minor
that
systems
things
are
not
hard
at
all
if
they
are
explained
well
and
I
made
more
accessible
to
more
people.
It's
like,
if
you
think
about
networking.
It
seems
very
hard
because
it
has
all
these
intimidating
concepts.
But
then
it's
like
the
core
concepts
are
like
IP
addresses
and
first
cetera,
and
once
you
understand,
though,
you
can
do
that.
Thank
you.