2005-04-17 02:20:36 +04:00
/ *
* Compatibility m o d e s y s t e m c a l l e n t r y p o i n t f o r x86 - 6 4 .
*
* Copyright 2 0 0 0 - 2 0 0 2 A n d i K l e e n , S u S E L a b s .
* /
# include < a s m / d w a r f2 . h >
# include < a s m / c a l l i n g . h >
2005-09-09 23:28:48 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / c u r r e n t . h >
# include < a s m / e r r n o . h >
# include < a s m / i a32 _ u n i s t d . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / s e g m e n t . h >
2006-07-03 11:24:45 +04:00
# include < a s m / i r q f l a g s . h >
2005-04-17 02:20:36 +04:00
# include < l i n u x / l i n k a g e . h >
2006-04-07 21:50:31 +04:00
# define I A 3 2 _ N R _ s y s c a l l s ( ( i a32 _ s y s c a l l _ e n d - i a32 _ s y s _ c a l l _ t a b l e ) / 8 )
2005-04-17 02:20:36 +04:00
.macro IA32_ARG_FIXUP noebp=0
movl % e d i ,% r8 d
.if \ noebp
.else
movl % e b p ,% r9 d
.endif
xchg % e c x ,% e s i
movl % e b x ,% e d i
movl % e d x ,% e d x / * z e r o e x t e n s i o n * /
.endm
/* clobbers %eax */
.macro CLEAR_RREGS
xorl % e a x ,% e a x
movq % r a x ,R 1 1 ( % r s p )
movq % r a x ,R 1 0 ( % r s p )
movq % r a x ,R 9 ( % r s p )
movq % r a x ,R 8 ( % r s p )
.endm
2007-09-21 18:16:18 +04:00
.macro LOAD_ARGS32 offset
movl \ o f f s e t ( % r s p ) ,% r11 d
movl \ o f f s e t + 8 ( % r s p ) ,% r10 d
movl \ o f f s e t + 1 6 ( % r s p ) ,% r9 d
movl \ o f f s e t + 2 4 ( % r s p ) ,% r8 d
movl \ o f f s e t + 4 0 ( % r s p ) ,% e c x
movl \ o f f s e t + 4 8 ( % r s p ) ,% e d x
movl \ o f f s e t + 5 6 ( % r s p ) ,% e s i
movl \ o f f s e t + 6 4 ( % r s p ) ,% e d i
movl \ o f f s e t + 7 2 ( % r s p ) ,% e a x
.endm
2006-01-12 00:41:59 +03:00
.macro CFI_STARTPROC32 simple
CFI_ S T A R T P R O C \ s i m p l e
CFI_ U N D E F I N E D r8
CFI_ U N D E F I N E D r9
CFI_ U N D E F I N E D r10
CFI_ U N D E F I N E D r11
CFI_ U N D E F I N E D r12
CFI_ U N D E F I N E D r13
CFI_ U N D E F I N E D r14
CFI_ U N D E F I N E D r15
.endm
2005-04-17 02:20:36 +04:00
/ *
* 3 2 bit S Y S E N T E R i n s t r u c t i o n e n t r y .
*
* Arguments :
* % eax S y s t e m c a l l n u m b e r .
* % ebx A r g 1
* % ecx A r g 2
* % edx A r g 3
* % esi A r g 4
* % edi A r g 5
* % ebp u s e r s t a c k
* 0 ( % ebp) A r g 6
*
* Interrupts o f f .
*
* This i s p u r e l y a f a s t p a t h . F o r a n y t h i n g c o m p l i c a t e d w e u s e t h e i n t 0 x80
* path b e l o w . S e t u p a c o m p l e t e h a r d w a r e s t a c k f r a m e t o s h a r e c o d e
* with t h e i n t 0 x80 p a t h .
* /
ENTRY( i a32 _ s y s e n t e r _ t a r g e t )
2006-01-12 00:41:59 +03:00
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2005-09-12 20:49:24 +04:00
CFI_ D E F _ C F A r s p ,0
CFI_ R E G I S T E R r s p ,r b p
2005-04-17 02:20:36 +04:00
swapgs
movq % g s : p d a _ k e r n e l s t a c k , % r s p
addq $ ( P D A _ S T A C K O F F S E T ) ,% r s p
2006-07-03 11:24:45 +04:00
/ *
* No n e e d t o f o l l o w t h i s i r q s o n / o f f s e c t i o n : t h e s y s c a l l
* disabled i r q s , h e r e w e e n a b l e i t s t r a i g h t a f t e r e n t r y :
* /
2005-04-17 02:20:36 +04:00
sti
movl % e b p ,% e b p / * z e r o e x t e n s i o n * /
pushq $ _ _ U S E R 3 2 _ D S
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T 8
/*CFI_REL_OFFSET ss,0*/
2005-04-17 02:20:36 +04:00
pushq % r b p
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T 8
CFI_ R E L _ O F F S E T r s p ,0
2005-04-17 02:20:36 +04:00
pushfq
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T 8
/*CFI_REL_OFFSET rflags,0*/
2008-01-30 15:30:43 +03:00
movl 8 * 3 - T H R E A D _ S I Z E + t h r e a d i n f o _ s y s e n t e r _ r e t u r n ( % r s p ) , % r10 d
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r i p ,r10
2005-04-17 02:20:36 +04:00
pushq $ _ _ U S E R 3 2 _ C S
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T 8
/*CFI_REL_OFFSET cs,0*/
2005-04-17 02:20:36 +04:00
movl % e a x , % e a x
pushq % r10
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T 8
CFI_ R E L _ O F F S E T r i p ,0
2005-04-17 02:20:36 +04:00
pushq % r a x
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T 8
2005-04-17 02:20:36 +04:00
cld
2007-07-21 19:10:20 +04:00
SAVE_ A R G S 0 ,0 ,1
2005-04-17 02:20:36 +04:00
/ * no n e e d t o d o a n a c c e s s _ o k c h e c k h e r e b e c a u s e r b p h a s b e e n
3 2 bit z e r o e x t e n d e d * /
1 : movl ( % r b p ) ,% r9 d
.section _ _ ex_ t a b l e ," a "
.quad 1 b,i a32 _ b a d a r g
.previous
GET_ T H R E A D _ I N F O ( % r10 )
2006-01-12 00:44:06 +03:00
orl $ T S _ C O M P A T ,t h r e a d i n f o _ s t a t u s ( % r10 )
2005-04-17 02:20:36 +04:00
testl $ ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S E C C O M P ) ,t h r e a d i n f o _ f l a g s ( % r10 )
2005-09-12 20:49:24 +04:00
CFI_ R E M E M B E R _ S T A T E
2005-04-17 02:20:36 +04:00
jnz s y s e n t e r _ t r a c e s y s
sysenter_do_call :
2006-04-07 21:50:31 +04:00
cmpl $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% e a x
ja i a32 _ b a d s y s
2005-04-17 02:20:36 +04:00
IA3 2 _ A R G _ F I X U P 1
call * i a32 _ s y s _ c a l l _ t a b l e ( ,% r a x ,8 )
movq % r a x ,R A X - A R G O F F S E T ( % r s p )
GET_ T H R E A D _ I N F O ( % r10 )
cli
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O F F
2005-04-17 02:20:36 +04:00
testl $ _ T I F _ A L L W O R K _ M A S K ,t h r e a d i n f o _ f l a g s ( % r10 )
jnz i n t _ r e t _ f r o m _ s y s _ c a l l
2006-01-12 00:44:06 +03:00
andl $ ~ T S _ C O M P A T ,t h r e a d i n f o _ s t a t u s ( % r10 )
2005-04-17 02:20:36 +04:00
/* clear IF, that popfq doesn't enable interrupts early */
andl $ ~ 0 x20 0 ,E F L A G S - R 1 1 ( % r s p )
2008-01-30 15:30:43 +03:00
movl R I P - R 1 1 ( % r s p ) ,% e d x / * U s e r % e i p * /
CFI_ R E G I S T E R r i p ,r d x
2005-04-17 02:20:36 +04:00
RESTORE_ A R G S 1 ,2 4 ,1 ,1 ,1 ,1
popfq
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T - 8
/*CFI_RESTORE rflags*/
2005-04-17 02:20:36 +04:00
popq % r c x / * U s e r % e s p * /
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T - 8
CFI_ R E G I S T E R r s p ,r c x
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O N
2005-04-17 02:20:36 +04:00
swapgs
sti / * s t i o n l y t a k e s e f f e c t a f t e r t h e n e x t i n s t r u c t i o n * /
/* sysexit */
.byte 0 xf, 0 x35
sysenter_tracesys :
2005-09-12 20:49:24 +04:00
CFI_ R E S T O R E _ S T A T E
2007-11-07 18:48:39 +03:00
xchgl % r9 d ,% e b p
2005-04-17 02:20:36 +04:00
SAVE_ R E S T
CLEAR_ R R E G S
2007-11-07 18:48:39 +03:00
movq % r9 ,R 9 ( % r s p )
2008-03-19 04:23:50 +03:00
movq $ - E N O S Y S ,R A X ( % r s p ) / * p t r a c e c a n c h a n g e t h i s f o r a b a d s y s c a l l * /
2005-04-17 02:20:36 +04:00
movq % r s p ,% r d i / * & p t _ r e g s - > a r g 1 * /
call s y s c a l l _ t r a c e _ e n t e r
2007-09-21 18:16:18 +04:00
LOAD_ A R G S 3 2 A R G O F F S E T / * r e l o a d a r g s f r o m s t a c k i n c a s e p t r a c e c h a n g e d i t * /
2005-04-17 02:20:36 +04:00
RESTORE_ R E S T
2007-11-07 18:48:39 +03:00
xchgl % e b p ,% r9 d
2008-03-19 04:23:50 +03:00
cmpl $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% e a x
ja i n t _ r e t _ f r o m _ s y s _ c a l l / * s y s e n t e r _ t r a c e s y s h a s s e t R A X ( % r s p ) * /
2005-04-17 02:20:36 +04:00
jmp s y s e n t e r _ d o _ c a l l
CFI_ E N D P R O C
2006-06-26 15:56:55 +04:00
ENDPROC( i a32 _ s y s e n t e r _ t a r g e t )
2005-04-17 02:20:36 +04:00
/ *
* 3 2 bit S Y S C A L L i n s t r u c t i o n e n t r y .
*
* Arguments :
* % eax S y s t e m c a l l n u m b e r .
* % ebx A r g 1
* % ecx r e t u r n E I P
* % edx A r g 3
* % esi A r g 4
* % edi A r g 5
* % ebp A r g 2 [ n o t e : n o t s a v e d i n t h e s t a c k f r a m e , s h o u l d n o t b e t o u c h e d ]
* % esp u s e r s t a c k
* 0 ( % esp) A r g 6
*
* Interrupts o f f .
*
* This i s p u r e l y a f a s t p a t h . F o r a n y t h i n g c o m p l i c a t e d w e u s e t h e i n t 0 x80
* path b e l o w . S e t u p a c o m p l e t e h a r d w a r e s t a c k f r a m e t o s h a r e c o d e
* with t h e i n t 0 x80 p a t h .
* /
ENTRY( i a32 _ c s t a r _ t a r g e t )
2006-01-12 00:41:59 +03:00
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2006-06-26 15:57:38 +04:00
CFI_ D E F _ C F A r s p ,P D A _ S T A C K O F F S E T
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r i p ,r c x
/*CFI_REGISTER rflags,r11*/
2005-04-17 02:20:36 +04:00
swapgs
movl % e s p ,% r8 d
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r s p ,r8
2005-04-17 02:20:36 +04:00
movq % g s : p d a _ k e r n e l s t a c k ,% r s p
2006-07-03 11:24:45 +04:00
/ *
* No n e e d t o f o l l o w t h i s i r q s o n / o f f s e c t i o n : t h e s y s c a l l
* disabled i r q s a n d h e r e w e e n a b l e i t s t r a i g h t a f t e r e n t r y :
* /
2005-04-17 02:20:36 +04:00
sti
SAVE_ A R G S 8 ,1 ,1
movl % e a x ,% e a x / * z e r o e x t e n s i o n * /
movq % r a x ,O R I G _ R A X - A R G O F F S E T ( % r s p )
movq % r c x ,R I P - A R G O F F S E T ( % r s p )
2005-09-12 20:49:24 +04:00
CFI_ R E L _ O F F S E T r i p ,R I P - A R G O F F S E T
2005-04-17 02:20:36 +04:00
movq % r b p ,R C X - A R G O F F S E T ( % r s p ) / * t h i s l i e s s l i g h t l y t o p t r a c e * /
movl % e b p ,% e c x
movq $ _ _ U S E R 3 2 _ C S ,C S - A R G O F F S E T ( % r s p )
movq $ _ _ U S E R 3 2 _ D S ,S S - A R G O F F S E T ( % r s p )
movq % r11 ,E F L A G S - A R G O F F S E T ( % r s p )
2005-09-12 20:49:24 +04:00
/*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
2005-04-17 02:20:36 +04:00
movq % r8 ,R S P - A R G O F F S E T ( % r s p )
2005-09-12 20:49:24 +04:00
CFI_ R E L _ O F F S E T r s p ,R S P - A R G O F F S E T
2005-04-17 02:20:36 +04:00
/ * no n e e d t o d o a n a c c e s s _ o k c h e c k h e r e b e c a u s e r8 h a s b e e n
3 2 bit z e r o e x t e n d e d * /
/* hardware stack frame is complete now */
1 : movl ( % r8 ) ,% r9 d
.section _ _ ex_ t a b l e ," a "
.quad 1 b,i a32 _ b a d a r g
.previous
GET_ T H R E A D _ I N F O ( % r10 )
2006-01-12 00:44:06 +03:00
orl $ T S _ C O M P A T ,t h r e a d i n f o _ s t a t u s ( % r10 )
2005-04-17 02:20:36 +04:00
testl $ ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S E C C O M P ) ,t h r e a d i n f o _ f l a g s ( % r10 )
2005-09-12 20:49:24 +04:00
CFI_ R E M E M B E R _ S T A T E
2005-04-17 02:20:36 +04:00
jnz c s t a r _ t r a c e s y s
cstar_do_call :
2006-04-07 21:50:31 +04:00
cmpl $ I A 3 2 _ N R _ s y s c a l l s - 1 ,% e a x
ja i a32 _ b a d s y s
2005-04-17 02:20:36 +04:00
IA3 2 _ A R G _ F I X U P 1
call * i a32 _ s y s _ c a l l _ t a b l e ( ,% r a x ,8 )
movq % r a x ,R A X - A R G O F F S E T ( % r s p )
GET_ T H R E A D _ I N F O ( % r10 )
cli
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O F F
2005-04-17 02:20:36 +04:00
testl $ _ T I F _ A L L W O R K _ M A S K ,t h r e a d i n f o _ f l a g s ( % r10 )
jnz i n t _ r e t _ f r o m _ s y s _ c a l l
2006-01-12 00:44:06 +03:00
andl $ ~ T S _ C O M P A T ,t h r e a d i n f o _ s t a t u s ( % r10 )
2005-04-17 02:20:36 +04:00
RESTORE_ A R G S 1 ,- A R G _ S K I P ,1 ,1 ,1
movl R I P - A R G O F F S E T ( % r s p ) ,% e c x
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r i p ,r c x
2005-04-17 02:20:36 +04:00
movl E F L A G S - A R G O F F S E T ( % r s p ) ,% r11 d
2005-09-12 20:49:24 +04:00
/*CFI_REGISTER rflags,r11*/
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O N
2005-04-17 02:20:36 +04:00
movl R S P - A R G O F F S E T ( % r s p ) ,% e s p
2005-09-12 20:49:24 +04:00
CFI_ R E S T O R E r s p
2005-04-17 02:20:36 +04:00
swapgs
sysretl
cstar_tracesys :
2005-09-12 20:49:24 +04:00
CFI_ R E S T O R E _ S T A T E
2007-11-07 18:48:39 +03:00
xchgl % r9 d ,% e b p
2005-04-17 02:20:36 +04:00
SAVE_ R E S T
CLEAR_ R R E G S
2007-11-07 18:48:39 +03:00
movq % r9 ,R 9 ( % r s p )
2008-03-19 04:23:50 +03:00
movq $ - E N O S Y S ,R A X ( % r s p ) / * p t r a c e c a n c h a n g e t h i s f o r a b a d s y s c a l l * /
2005-04-17 02:20:36 +04:00
movq % r s p ,% r d i / * & p t _ r e g s - > a r g 1 * /
call s y s c a l l _ t r a c e _ e n t e r
2007-09-21 18:16:18 +04:00
LOAD_ A R G S 3 2 A R G O F F S E T / * r e l o a d a r g s f r o m s t a c k i n c a s e p t r a c e c h a n g e d i t * /
2005-04-17 02:20:36 +04:00
RESTORE_ R E S T
2007-11-07 18:48:39 +03:00
xchgl % e b p ,% r9 d
2005-04-17 02:20:36 +04:00
movl R S P - A R G O F F S E T ( % r s p ) , % r8 d
2008-03-19 04:23:50 +03:00
cmpl $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% e a x
ja i n t _ r e t _ f r o m _ s y s _ c a l l / * c s t a r _ t r a c e s y s h a s s e t R A X ( % r s p ) * /
2005-04-17 02:20:36 +04:00
jmp c s t a r _ d o _ c a l l
2006-06-26 15:56:55 +04:00
END( i a32 _ c s t a r _ t a r g e t )
2005-04-17 02:20:36 +04:00
ia32_badarg :
movq $ - E F A U L T ,% r a x
jmp i a32 _ s y s r e t
CFI_ E N D P R O C
/ *
* Emulated I A 3 2 s y s t e m c a l l s v i a i n t 0 x80 .
*
* Arguments :
* % eax S y s t e m c a l l n u m b e r .
* % ebx A r g 1
* % ecx A r g 2
* % edx A r g 3
* % esi A r g 4
* % edi A r g 5
* % ebp A r g 6 [ n o t e : n o t s a v e d i n t h e s t a c k f r a m e , s h o u l d n o t b e t o u c h e d ]
*
* Notes :
* Uses t h e s a m e s t a c k f r a m e a s t h e x86 - 6 4 v e r s i o n .
* All r e g i s t e r s e x c e p t % e a x m u s t b e s a v e d ( b u t p t r a c e m a y v i o l a t e t h a t )
* Arguments a r e z e r o e x t e n d e d . F o r s y s t e m c a l l s t h a t w a n t s i g n e x t e n s i o n a n d
* take l o n g a r g u m e n t s a w r a p p e r i s n e e d e d . M o s t c a l l s c a n j u s t b e c a l l e d
* directly.
* Assumes i t i s o n l y c a l l e d f r o m u s e r s p a c e a n d e n t e r e d w i t h i n t e r r u p t s o f f .
* /
ENTRY( i a32 _ s y s c a l l )
2007-07-21 19:10:20 +04:00
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2005-09-12 20:49:24 +04:00
CFI_ D E F _ C F A r s p ,S S + 8 - R I P
/*CFI_REL_OFFSET ss,SS-RIP*/
CFI_ R E L _ O F F S E T r s p ,R S P - R I P
/*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
/*CFI_REL_OFFSET cs,CS-RIP*/
CFI_ R E L _ O F F S E T r i p ,R I P - R I P
2006-07-03 11:24:45 +04:00
swapgs
/ *
* No n e e d t o f o l l o w t h i s i r q s o n / o f f s e c t i o n : t h e s y s c a l l
* disabled i r q s a n d h e r e w e e n a b l e i t s t r a i g h t a f t e r e n t r y :
* /
2005-04-17 02:20:36 +04:00
sti
movl % e a x ,% e a x
pushq % r a x
2005-09-12 20:49:24 +04:00
CFI_ A D J U S T _ C F A _ O F F S E T 8
2005-04-17 02:20:36 +04:00
cld
/ * note t h e r e g i s t e r s a r e n o t z e r o e x t e n d e d t o t h e s f .
this c o u l d b e a p r o b l e m . * /
SAVE_ A R G S 0 ,0 ,1
GET_ T H R E A D _ I N F O ( % r10 )
2006-01-12 00:44:06 +03:00
orl $ T S _ C O M P A T ,t h r e a d i n f o _ s t a t u s ( % r10 )
2005-04-17 02:20:36 +04:00
testl $ ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S E C C O M P ) ,t h r e a d i n f o _ f l a g s ( % r10 )
jnz i a32 _ t r a c e s y s
ia32_do_syscall :
2006-04-07 21:50:31 +04:00
cmpl $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% e a x
2008-03-17 07:57:41 +03:00
ja i n t _ r e t _ f r o m _ s y s _ c a l l / * i a32 _ t r a c e s y s h a s s e t R A X ( % r s p ) * /
2005-04-17 02:20:36 +04:00
IA3 2 _ A R G _ F I X U P
call * i a32 _ s y s _ c a l l _ t a b l e ( ,% r a x ,8 ) # x x x : r i p r e l a t i v e
ia32_sysret :
movq % r a x ,R A X - A R G O F F S E T ( % r s p )
jmp i n t _ r e t _ f r o m _ s y s _ c a l l
ia32_tracesys :
SAVE_ R E S T
2007-07-21 19:10:20 +04:00
CLEAR_ R R E G S
2008-03-17 07:57:41 +03:00
movq $ - E N O S Y S ,R A X ( % r s p ) / * p t r a c e c a n c h a n g e t h i s f o r a b a d s y s c a l l * /
2005-04-17 02:20:36 +04:00
movq % r s p ,% r d i / * & p t _ r e g s - > a r g 1 * /
call s y s c a l l _ t r a c e _ e n t e r
2007-09-21 18:16:18 +04:00
LOAD_ A R G S 3 2 A R G O F F S E T / * r e l o a d a r g s f r o m s t a c k i n c a s e p t r a c e c h a n g e d i t * /
2005-04-17 02:20:36 +04:00
RESTORE_ R E S T
jmp i a32 _ d o _ s y s c a l l
2006-06-26 15:56:55 +04:00
END( i a32 _ s y s c a l l )
2005-04-17 02:20:36 +04:00
ia32_badsys :
movq $ 0 ,O R I G _ R A X - A R G O F F S E T ( % r s p )
movq $ - E N O S Y S ,R A X - A R G O F F S E T ( % r s p )
jmp i n t _ r e t _ f r o m _ s y s _ c a l l
quiet_ni_syscall :
movq $ - E N O S Y S ,% r a x
ret
CFI_ E N D P R O C
.macro PTREGSCALL label, f u n c , a r g
.globl \ label
\ label :
leaq \ f u n c ( % r i p ) ,% r a x
leaq - A R G O F F S E T + 8 ( % r s p ) ,\ a r g / * 8 f o r r e t u r n a d d r e s s * /
jmp i a32 _ p t r e g s _ c o m m o n
.endm
2006-01-12 00:41:59 +03:00
CFI_ S T A R T P R O C 3 2
2005-09-12 20:49:24 +04:00
2005-04-17 02:20:36 +04:00
PTREGSCALL s t u b32 _ r t _ s i g r e t u r n , s y s32 _ r t _ s i g r e t u r n , % r d i
PTREGSCALL s t u b32 _ s i g r e t u r n , s y s32 _ s i g r e t u r n , % r d i
PTREGSCALL s t u b32 _ s i g a l t s t a c k , s y s32 _ s i g a l t s t a c k , % r d x
PTREGSCALL s t u b32 _ s i g s u s p e n d , s y s32 _ s i g s u s p e n d , % r c x
PTREGSCALL s t u b32 _ e x e c v e , s y s32 _ e x e c v e , % r c x
PTREGSCALL s t u b32 _ f o r k , s y s _ f o r k , % r d i
PTREGSCALL s t u b32 _ c l o n e , s y s32 _ c l o n e , % r d x
PTREGSCALL s t u b32 _ v f o r k , s y s _ v f o r k , % r d i
PTREGSCALL s t u b32 _ i o p l , s y s _ i o p l , % r s i
PTREGSCALL s t u b32 _ r t _ s i g s u s p e n d , s y s _ r t _ s i g s u s p e n d , % r d x
ENTRY( i a32 _ p t r e g s _ c o m m o n )
popq % r11
2006-01-12 00:41:59 +03:00
CFI_ E N D P R O C
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2006-01-12 00:41:59 +03:00
CFI_ D E F _ C F A r s p ,S S + 8 - A R G O F F S E T
CFI_ R E L _ O F F S E T r a x ,R A X - A R G O F F S E T
CFI_ R E L _ O F F S E T r c x ,R C X - A R G O F F S E T
CFI_ R E L _ O F F S E T r d x ,R D X - A R G O F F S E T
CFI_ R E L _ O F F S E T r s i ,R S I - A R G O F F S E T
CFI_ R E L _ O F F S E T r d i ,R D I - A R G O F F S E T
CFI_ R E L _ O F F S E T r i p ,R I P - A R G O F F S E T
/* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
/* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
CFI_ R E L _ O F F S E T r s p ,R S P - A R G O F F S E T
/* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
2005-04-17 02:20:36 +04:00
SAVE_ R E S T
call * % r a x
RESTORE_ R E S T
jmp i a32 _ s y s r e t / * m i s b a l a n c e s t h e r e t u r n c a c h e * /
CFI_ E N D P R O C
2006-06-26 15:56:55 +04:00
END( i a32 _ p t r e g s _ c o m m o n )
2005-04-17 02:20:36 +04:00
2006-01-06 11:12:05 +03:00
.section .rodata , " a"
2005-04-17 02:20:36 +04:00
.align 8
ia32_sys_call_table :
.quad sys_restart_syscall
.quad sys_exit
.quad stub32_fork
.quad sys_read
.quad sys_write
2005-09-07 02:18:25 +04:00
.quad compat_sys_open /* 5 */
2005-04-17 02:20:36 +04:00
.quad sys_close
.quad sys32_waitpid
.quad sys_creat
.quad sys_link
.quad sys_unlink /* 10 */
.quad stub32_execve
.quad sys_chdir
.quad compat_sys_time
.quad sys_mknod
.quad sys_chmod /* 15 */
.quad sys_lchown16
.quad quiet_ni_syscall /* old break syscall holder */
.quad sys_stat
.quad sys32_lseek
.quad sys_getpid /* 20 */
.quad compat_sys_mount /* mount */
.quad sys_oldumount /* old_umount */
.quad sys_setuid16
.quad sys_getuid16
.quad compat_sys_stime /* stime */ /* 25 */
.quad sys32_ptrace /* ptrace */
.quad sys_alarm
.quad sys_fstat /* (old)fstat */
.quad sys_pause
.quad compat_sys_utime /* 30 */
.quad quiet_ni_syscall /* old stty syscall holder */
.quad quiet_ni_syscall /* old gtty syscall holder */
.quad sys_access
.quad sys_nice
.quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
.quad sys_sync
.quad sys32_kill
.quad sys_rename
.quad sys_mkdir
.quad sys_rmdir /* 40 */
.quad sys_dup
.quad sys32_pipe
.quad compat_sys_times
.quad quiet_ni_syscall /* old prof syscall holder */
.quad sys_brk /* 45 */
.quad sys_setgid16
.quad sys_getgid16
.quad sys_signal
.quad sys_geteuid16
.quad sys_getegid16 /* 50 */
.quad sys_acct
.quad sys_umount /* new_umount */
.quad quiet_ni_syscall /* old lock syscall holder */
.quad compat_sys_ioctl
.quad compat_sys_fcntl64 /* 55 */
.quad quiet_ni_syscall /* old mpx syscall holder */
.quad sys_setpgid
.quad quiet_ni_syscall /* old ulimit syscall holder */
.quad sys32_olduname
.quad sys_umask /* 60 */
.quad sys_chroot
.quad sys32_ustat
.quad sys_dup2
.quad sys_getppid
.quad sys_getpgrp /* 65 */
.quad sys_setsid
.quad sys32_sigaction
.quad sys_sgetmask
.quad sys_ssetmask
.quad sys_setreuid16 /* 70 */
.quad sys_setregid16
.quad stub32_sigsuspend
.quad compat_sys_sigpending
.quad sys_sethostname
.quad compat_sys_setrlimit /* 75 */
.quad compat_sys_old_getrlimit /* old_getrlimit */
.quad compat_sys_getrusage
.quad sys32_gettimeofday
.quad sys32_settimeofday
.quad sys_getgroups16 /* 80 */
.quad sys_setgroups16
.quad sys32_old_select
.quad sys_symlink
.quad sys_lstat
.quad sys_readlink /* 85 */
.quad sys_uselib
.quad sys_swapon
.quad sys_reboot
.quad compat_sys_old_readdir
.quad sys32_mmap /* 90 */
.quad sys_munmap
.quad sys_truncate
.quad sys_ftruncate
.quad sys_fchmod
.quad sys_fchown16 /* 95 */
.quad sys_getpriority
.quad sys_setpriority
.quad quiet_ni_syscall /* old profil syscall holder */
.quad compat_sys_statfs
.quad compat_sys_fstatfs /* 100 */
.quad sys_ioperm
.quad compat_sys_socketcall
.quad sys_syslog
.quad compat_sys_setitimer
.quad compat_sys_getitimer /* 105 */
.quad compat_sys_newstat
.quad compat_sys_newlstat
.quad compat_sys_newfstat
.quad sys32_uname
.quad stub32_iopl /* 110 */
.quad sys_vhangup
.quad quiet_ni_syscall /* old "idle" system call */
.quad sys32_vm86_warning /* vm86old */
.quad compat_sys_wait4
.quad sys_swapoff /* 115 */
2007-02-10 12:46:00 +03:00
.quad compat_sys_sysinfo
2005-04-17 02:20:36 +04:00
.quad sys32_ipc
.quad sys_fsync
.quad stub32_sigreturn
.quad stub32_clone /* 120 */
.quad sys_setdomainname
.quad sys_uname
.quad sys_modify_ldt
2006-03-26 13:37:29 +04:00
.quad compat_sys_adjtimex
2005-04-17 02:20:36 +04:00
.quad sys32_mprotect /* 125 */
.quad compat_sys_sigprocmask
.quad quiet_ni_syscall /* create_module */
.quad sys_init_module
.quad sys_delete_module
.quad quiet_ni_syscall /* 130 get_kernel_syms */
2007-07-16 10:41:12 +04:00
.quad sys32_quotactl
2005-04-17 02:20:36 +04:00
.quad sys_getpgid
.quad sys_fchdir
.quad quiet_ni_syscall /* bdflush */
.quad sys_sysfs /* 135 */
.quad sys_personality
.quad quiet_ni_syscall /* for afs_syscall */
.quad sys_setfsuid16
.quad sys_setfsgid16
.quad sys_llseek /* 140 */
.quad compat_sys_getdents
.quad compat_sys_select
.quad sys_flock
.quad sys_msync
.quad compat_sys_readv /* 145 */
.quad compat_sys_writev
.quad sys_getsid
.quad sys_fdatasync
.quad sys32_sysctl /* sysctl */
.quad sys_mlock /* 150 */
.quad sys_munlock
.quad sys_mlockall
.quad sys_munlockall
.quad sys_sched_setparam
.quad sys_sched_getparam /* 155 */
.quad sys_sched_setscheduler
.quad sys_sched_getscheduler
.quad sys_sched_yield
.quad sys_sched_get_priority_max
.quad sys_sched_get_priority_min /* 160 */
2007-03-16 23:07:36 +03:00
.quad sys32_sched_rr_get_interval
2005-04-17 02:20:36 +04:00
.quad compat_sys_nanosleep
.quad sys_mremap
.quad sys_setresuid16
.quad sys_getresuid16 /* 165 */
.quad sys32_vm86_warning /* vm86 */
.quad quiet_ni_syscall /* query_module */
.quad sys_poll
.quad compat_sys_nfsservctl
.quad sys_setresgid16 /* 170 */
.quad sys_getresgid16
.quad sys_prctl
.quad stub32_rt_sigreturn
.quad sys32_rt_sigaction
.quad sys32_rt_sigprocmask /* 175 */
.quad sys32_rt_sigpending
.quad compat_sys_rt_sigtimedwait
.quad sys32_rt_sigqueueinfo
.quad stub32_rt_sigsuspend
.quad sys32_pread /* 180 */
.quad sys32_pwrite
.quad sys_chown16
.quad sys_getcwd
.quad sys_capget
.quad sys_capset
.quad stub32_sigaltstack
.quad sys32_sendfile
.quad quiet_ni_syscall /* streams1 */
.quad quiet_ni_syscall /* streams2 */
.quad stub32_vfork /* 190 */
.quad compat_sys_getrlimit
.quad sys32_mmap2
.quad sys32_truncate64
.quad sys32_ftruncate64
.quad sys32_stat64 /* 195 */
.quad sys32_lstat64
.quad sys32_fstat64
.quad sys_lchown
.quad sys_getuid
.quad sys_getgid /* 200 */
.quad sys_geteuid
.quad sys_getegid
.quad sys_setreuid
.quad sys_setregid
.quad sys_getgroups /* 205 */
.quad sys_setgroups
.quad sys_fchown
.quad sys_setresuid
.quad sys_getresuid
.quad sys_setresgid /* 210 */
.quad sys_getresgid
.quad sys_chown
.quad sys_setuid
.quad sys_setgid
.quad sys_setfsuid /* 215 */
.quad sys_setfsgid
.quad sys_pivot_root
.quad sys_mincore
.quad sys_madvise
.quad compat_sys_getdents64 /* 220 getdents64 */
.quad compat_sys_fcntl64
.quad quiet_ni_syscall /* tux */
.quad quiet_ni_syscall /* security */
.quad sys_gettid
2007-06-20 14:23:30 +04:00
.quad sys32_readahead /* 225 */
2005-04-17 02:20:36 +04:00
.quad sys_setxattr
.quad sys_lsetxattr
.quad sys_fsetxattr
.quad sys_getxattr
.quad sys_lgetxattr /* 230 */
.quad sys_fgetxattr
.quad sys_listxattr
.quad sys_llistxattr
.quad sys_flistxattr
.quad sys_removexattr /* 235 */
.quad sys_lremovexattr
.quad sys_fremovexattr
.quad sys_tkill
.quad sys_sendfile64
.quad compat_sys_futex /* 240 */
.quad compat_sys_sched_setaffinity
.quad compat_sys_sched_getaffinity
2008-01-30 15:30:46 +03:00
.quad sys_set_thread_area
.quad sys_get_thread_area
2005-04-17 02:20:36 +04:00
.quad compat_sys_io_setup /* 245 */
.quad sys_io_destroy
.quad compat_sys_io_getevents
.quad compat_sys_io_submit
.quad sys_io_cancel
2007-06-20 14:23:30 +04:00
.quad sys32_fadvise64 /* 250 */
2005-04-17 02:20:36 +04:00
.quad quiet_ni_syscall /* free_huge_pages */
.quad sys_exit_group
.quad sys32_lookup_dcookie
.quad sys_epoll_create
.quad sys_epoll_ctl /* 255 */
.quad sys_epoll_wait
.quad sys_remap_file_pages
.quad sys_set_tid_address
2006-01-10 07:52:08 +03:00
.quad compat_sys_timer_create
2005-04-17 02:20:36 +04:00
.quad compat_sys_timer_settime /* 260 */
.quad compat_sys_timer_gettime
.quad sys_timer_getoverrun
.quad sys_timer_delete
.quad compat_sys_clock_settime
.quad compat_sys_clock_gettime /* 265 */
.quad compat_sys_clock_getres
.quad compat_sys_clock_nanosleep
.quad compat_sys_statfs64
.quad compat_sys_fstatfs64
.quad sys_tgkill /* 270 */
.quad compat_sys_utimes
.quad sys32_fadvise64_64
.quad quiet_ni_syscall /* sys_vserver */
.quad sys_mbind
.quad compat_sys_get_mempolicy /* 275 */
.quad sys_set_mempolicy
.quad compat_sys_mq_open
.quad sys_mq_unlink
.quad compat_sys_mq_timedsend
.quad compat_sys_mq_timedreceive /* 280 */
.quad compat_sys_mq_notify
.quad compat_sys_mq_getsetattr
2005-06-26 01:58:02 +04:00
.quad compat_sys_kexec_load /* reserved for kexec */
2005-04-17 02:20:36 +04:00
.quad compat_sys_waitid
2005-07-25 23:19:29 +04:00
.quad quiet_ni_syscall /* 285: sys_altroot */
2005-04-17 02:20:36 +04:00
.quad sys_add_key
.quad sys_request_key
.quad sys_keyctl
2005-07-25 23:19:29 +04:00
.quad sys_ioprio_set
.quad sys_ioprio_get /* 290 */
.quad sys_inotify_init
.quad sys_inotify_add_watch
.quad sys_inotify_rm_watch
2006-01-08 12:00:51 +03:00
.quad sys_migrate_pages
2006-01-19 04:43:56 +03:00
.quad compat_sys_openat /* 295 */
.quad sys_mkdirat
.quad sys_mknodat
.quad sys_fchownat
2006-02-01 14:04:32 +03:00
.quad compat_sys_futimesat
2006-02-12 04:55:47 +03:00
.quad sys32_fstatat /* 300 */
2006-01-19 04:43:56 +03:00
.quad sys_unlinkat
.quad sys_renameat
.quad sys_linkat
.quad sys_symlinkat
.quad sys_readlinkat /* 305 */
.quad sys_fchmodat
.quad sys_faccessat
2006-09-26 12:52:27 +04:00
.quad compat_sys_pselect6
.quad compat_sys_ppoll
2006-02-09 02:35:50 +03:00
.quad sys_unshare /* 310 */
2006-03-27 13:16:26 +04:00
.quad compat_sys_set_robust_list
.quad compat_sys_get_robust_list
2006-04-07 21:50:34 +04:00
.quad sys_splice
2007-06-20 14:23:30 +04:00
.quad sys32_sync_file_range
utimensat implementation
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines
of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to
accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime
which already use do_utimes instead of duplicating the work.
Also, the completely missing futimensat() functionality is added. We have
such a function in glibc but we have to resort to using /proc/self/fd/* which
not everybody likes (chroot etc).
Test application (the syscall number will need per-arch editing):
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <stddef.h>
#include <syscall.h>
#define __NR_utimensat 280
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
int
main(void)
{
int status = 0;
int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
error (1, errno, "failed to create test file \"ttt\"");
struct stat64 st1;
if (fstat64 (fd, &st1) != 0)
error (1, errno, "fstat failed");
struct timespec t[2];
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
struct stat64 st2;
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0] = st1.st_atim;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_OMIT;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("atim not set");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim changed from zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_OMIT;
t[1] = st1.st_mtim;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("mtim changed from original time");
status = 1;
}
if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
|| st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
{
puts ("mtim not set");
status = 1;
}
if (status != 0)
goto out;
sleep (2);
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_NOW;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_NOW;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
struct timeval tv;
gettimeofday(&tv,NULL);
if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
|| st2.st_atim.tv_sec > tv.tv_sec)
{
puts ("atim not set to NOW");
status = 1;
}
if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
|| st2.st_mtim.tv_sec > tv.tv_sec)
{
puts ("mtim not set to NOW");
status = 1;
}
if (symlink ("ttt", "tttsym") != 0)
error (1, errno, "cannot create symlink");
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
error (1, errno, "utimensat failed");
if (lstat64 ("tttsym", &st2) != 0)
error (1, errno, "lstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("symlink atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("symlink mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 1;
t[0].tv_nsec = 0;
t[1].tv_sec = 1;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to one");
status = 1;
}
if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to one");
status = 1;
}
if (status == 0)
puts ("all OK");
out:
close (fd);
unlink ("ttt");
unlink ("tttsym");
return status;
}
[akpm@linux-foundation.org: add missing i386 syscall table entry]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 11:33:25 +04:00
.quad sys_tee /* 315 */
2006-05-01 23:15:48 +04:00
.quad compat_sys_vmsplice
2006-06-23 13:03:56 +04:00
.quad compat_sys_move_pages
2006-09-26 12:52:28 +04:00
.quad sys_getcpu
2007-02-13 15:26:26 +03:00
.quad sys_epoll_pwait
utimensat implementation
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines
of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to
accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime
which already use do_utimes instead of duplicating the work.
Also, the completely missing futimensat() functionality is added. We have
such a function in glibc but we have to resort to using /proc/self/fd/* which
not everybody likes (chroot etc).
Test application (the syscall number will need per-arch editing):
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <stddef.h>
#include <syscall.h>
#define __NR_utimensat 280
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
int
main(void)
{
int status = 0;
int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
error (1, errno, "failed to create test file \"ttt\"");
struct stat64 st1;
if (fstat64 (fd, &st1) != 0)
error (1, errno, "fstat failed");
struct timespec t[2];
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
struct stat64 st2;
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0] = st1.st_atim;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_OMIT;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("atim not set");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim changed from zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_OMIT;
t[1] = st1.st_mtim;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("mtim changed from original time");
status = 1;
}
if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
|| st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
{
puts ("mtim not set");
status = 1;
}
if (status != 0)
goto out;
sleep (2);
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_NOW;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_NOW;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
struct timeval tv;
gettimeofday(&tv,NULL);
if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
|| st2.st_atim.tv_sec > tv.tv_sec)
{
puts ("atim not set to NOW");
status = 1;
}
if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
|| st2.st_mtim.tv_sec > tv.tv_sec)
{
puts ("mtim not set to NOW");
status = 1;
}
if (symlink ("ttt", "tttsym") != 0)
error (1, errno, "cannot create symlink");
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
error (1, errno, "utimensat failed");
if (lstat64 ("tttsym", &st2) != 0)
error (1, errno, "lstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("symlink atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("symlink mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 1;
t[0].tv_nsec = 0;
t[1].tv_sec = 1;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to one");
status = 1;
}
if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to one");
status = 1;
}
if (status == 0)
puts ("all OK");
out:
close (fd);
unlink ("ttt");
unlink ("tttsym");
return status;
}
[akpm@linux-foundation.org: add missing i386 syscall table entry]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 11:33:25 +04:00
.quad compat_sys_utimensat /* 320 */
2007-05-12 19:27:41 +04:00
.quad compat_sys_signalfd
2008-02-05 09:27:28 +03:00
.quad sys_timerfd_create
2007-05-11 09:23:20 +04:00
.quad sys_eventfd
sys_fallocate() implementation on i386, x86_64 and powerpc
fallocate() is a new system call being proposed here which will allow
applications to preallocate space to any file(s) in a file system.
Each file system implementation that wants to use this feature will need
to support an inode operation called ->fallocate().
Applications can use this feature to avoid fragmentation to certain
level and thus get faster access speed. With preallocation, applications
also get a guarantee of space for particular file(s) - even if later the
the system becomes full.
Currently, glibc provides an interface called posix_fallocate() which
can be used for similar cause. Though this has the advantage of working
on all file systems, but it is quite slow (since it writes zeroes to
each block that has to be preallocated). Without a doubt, file systems
can do this more efficiently within the kernel, by implementing
the proposed fallocate() system call. It is expected that
posix_fallocate() will be modified to call this new system call first
and incase the kernel/filesystem does not implement it, it should fall
back to the current implementation of writing zeroes to the new blocks.
ToDos:
1. Implementation on other architectures (other than i386, x86_64,
and ppc). Patches for s390(x) and ia64 are already available from
previous posts, but it was decided that they should be added later
once fallocate is in the mainline. Hence not including those patches
in this take.
2. Changes to glibc,
a) to support fallocate() system call
b) to make posix_fallocate() and posix_fallocate64() call fallocate()
Signed-off-by: Amit Arora <aarora@in.ibm.com>
2007-07-18 05:42:44 +04:00
.quad sys32_fallocate
2008-02-05 09:27:28 +03:00
.quad compat_sys_timerfd_settime /* 325 */
.quad compat_sys_timerfd_gettime
2007-05-12 19:27:41 +04:00
ia32_syscall_end :