#include #include typedef struct{ struct modhcom _mh; /* Standard module header */ int data[1]; } mod_data; main() { mod_data *module; int i; if((module = _mkdata_module("arturo", 1024, 0xc001, 0x0033)) == -1){ printf(" errore %d ricevuto da _makdata_mod \n",errno); exit (0); } /* riempi il data module di numeri consecutivi da 1 a 1023 */ for(i = 0; i < 10; i++) module->data[i] = i; /* ridetermina il CRC */ if(_setcrc(module) == -1) printf(" errore %d ricevuto da _setcrc \n",errno); printf(" prima del printf \n"); for(i = 0; i < 20; i++) printf(" data nr %d %d\n", i, module->data[i]); /* salva il data module */ mod_save("arturo"); /* unlink */ munlink(module); printf(" data written . go to sleep \n"); /* eterno riposo */ tsleep(0x80000000 + 100000); } extern int os9forkc(); extern char **environ; char *argblk[] = { "save", "", /* il nome viene passato come argomento */ "-f=/h0/cmds/hwc", /* module directory */ "-r", /* il file esistente viene riscritto */ 0, }; mod_save(name) char *name; { char file[128]; unsigned long pid; int i, m; argblk[1] = name; /* forma il nome completo a partire dal directory */ m = 0; for (i = 0; i < 128 && *(argblk[2] + i) != '\0' ; i++) file[m++] = *(argblk[2] + i) ; file[m++] = '/'; for (i = 0; i< 32 && *(name + i) != '\0'; i++) file[m++] = *(name + i); argblk[2] = file; printf(" data module will be saved into %s \n",argblk[2]); if((pid = os9exec(os9forkc, argblk[0], argblk, environ, 0, 0, 3)) == -1){ printf(" error returned from os9exec(save) \n"); return -1; } return pid; }