home *** CD-ROM | disk | FTP | other *** search
/ ftp.parl.clemson.edu / 2015-02-07.ftp.parl.clemson.edu.tar / ftp.parl.clemson.edu / pub / pvfs2 / orangefs-2.8.3-20110323.tar.gz / orangefs-2.8.3-20110323.tar / orangefs / src / server / truncate.sm < prev    next >
Text File  |  2008-11-19  |  2KB  |  104 lines

  1. /* 
  2.  * (C) 2003 Clemson University and The University of Chicago 
  3.  *
  4.  * See COPYING in top-level directory.
  5.  */
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <assert.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <unistd.h>
  12. #include <fcntl.h>
  13.  
  14. #include "server-config.h"
  15. #include "pvfs2-server.h"
  16.  
  17. %%
  18.  
  19. machine pvfs2_truncate_sm
  20. {
  21.     state prelude
  22.     {
  23.         jump pvfs2_prelude_sm;
  24.         success => resize;
  25.         default => final_response;
  26.     }
  27.     
  28.     state resize
  29.     {
  30.         run truncate_resize;
  31.         default => check_error;
  32.     }
  33.  
  34.     state check_error
  35.     {
  36.         run truncate_check_error;
  37.         default => final_response;
  38.     }
  39.         
  40.     state final_response
  41.     {
  42.         jump pvfs2_final_response_sm;
  43.         default => cleanup;
  44.     }
  45.     
  46.     state cleanup
  47.     {
  48.         run truncate_cleanup;
  49.         default => terminate;
  50.     }
  51. }
  52.  
  53. %%
  54.  
  55. static PINT_sm_action truncate_resize(
  56.         struct PINT_smcb *smcb, job_status_s *js_p)
  57. {
  58.     struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
  59.     int ret = -PVFS_EINVAL;
  60.     job_id_t i;
  61.  
  62.     ret = job_trove_bstream_resize(
  63.         s_op->req->u.truncate.fs_id, s_op->req->u.truncate.handle,
  64.         s_op->req->u.truncate.size, s_op->req->u.truncate.flags,
  65.         NULL, smcb, 0, js_p, &i, server_job_context,
  66.         s_op->req->hints);
  67.  
  68.     return ret;
  69. }
  70.  
  71. static PINT_sm_action truncate_check_error(
  72.         struct PINT_smcb *smcb, job_status_s *js_p)
  73. {
  74.     return SM_ACTION_COMPLETE;
  75. }
  76.  
  77. static PINT_sm_action truncate_cleanup(
  78.         struct PINT_smcb *smcb, job_status_s *js_p)
  79. {
  80.     return (server_state_machine_complete(smcb));
  81. }
  82.  
  83. PINT_GET_OBJECT_REF_DEFINE(truncate);
  84.  
  85. struct PINT_server_req_params pvfs2_truncate_params =
  86. {
  87.     .string_name = "truncate",
  88.     .perm = PINT_SERVER_CHECK_NONE,
  89.     .access_type = PINT_server_req_modify,
  90.     .sched_policy = PINT_SERVER_REQ_SCHEDULE,
  91.     .get_object_ref = PINT_get_object_ref_truncate,
  92.     .state_machine = &pvfs2_truncate_sm
  93. };
  94.  
  95. /*
  96.  * Local variables:
  97.  *  mode: c
  98.  *  c-indent-level: 4
  99.  *  c-basic-offset: 4
  100.  * End:
  101.  *
  102.  * vim: ft=c ts=8 sts=4 sw=4 expandtab
  103.  */
  104.