status_t CryptContext::Init(encryption_algorithm algorithm, encryption_mode mode, const uint8* key, size_t keyLength) { _Uninit(); ThreadContext threadContext; fAlgorithm = create_algorithm(algorithm); if (fAlgorithm == NULL) return B_NO_MEMORY; status_t status = fAlgorithm->Init(threadContext); if (status != B_OK) return status; fMode = create_mode(mode); if (fMode == NULL) return B_NO_MEMORY; status = fMode->Init(threadContext, fAlgorithm); if (status != B_OK) return status; fThreadContexts = new(std::nothrow) ThreadContext*[sThreadCount]; if (fThreadContexts == NULL) return B_NO_MEMORY; for (int32 i = 0; i < sThreadCount; i++) { fThreadContexts[i] = new ThreadContext(threadContext); } return SetKey(key, keyLength); }
/* * Class: cbccore_low_Create * Method: create_mode * Signature: ()I */ JNIEXPORT jint JNICALL Java_cbccore_low_Create_create_1mode(JNIEnv *env, jobject obj) { #ifdef CBC return create_mode(); #else printf("Java_cbccore_low_Create_create_1mode stub\n"); return -1; #endif }
SYMLINK3res *nfsproc3_symlink_3_svc(SYMLINK3args * argp, struct svc_req * rqstp) { static SYMLINK3res result; char *path; pre_op_attr pre; post_op_attr post; char obj[NFS_MAXPATHLEN]; int res; mode_t new_mode; PREP(path, argp->where.dir); pre = get_pre_cached(); result.status = join3(cat_name(path, argp->where.name, obj), atomic_attr(argp->symlink.symlink_attributes), exports_rw()); cluster_create(obj, rqstp, &result.status); if (argp->symlink.symlink_attributes.mode.set_it == TRUE) new_mode = create_mode(argp->symlink.symlink_attributes); else { /* default rwxrwxrwx */ new_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH; } if (result.status == NFS3_OK) { umask(~new_mode); res = backend_symlink(argp->symlink.symlink_data, obj); umask(0); if (res == -1) result.status = symlink_err(); else { result.SYMLINK3res_u.resok.obj = fh_extend_type(argp->where.dir, obj, S_IFLNK); result.SYMLINK3res_u.resok.obj_attributes = get_post_cached(rqstp); } } post = get_post_attr(path, argp->where.dir, rqstp); /* overlaps with resfail */ result.SYMLINK3res_u.resok.dir_wcc.before = pre; result.SYMLINK3res_u.resok.dir_wcc.after = post; return &result; }
/* * check and process arguments to MKNOD procedure */ static nfsstat3 mknod_args(mknoddata3 what, const char *obj, mode_t * mode, dev_t * dev) { sattr3 attr; /* determine attributes */ switch (what.type) { case NF3REG: case NF3DIR: case NF3LNK: return NFS3ERR_INVAL; case NF3SOCK: if (strlen(obj) + 1 > UNIX_PATH_MAX) return NFS3ERR_NAMETOOLONG; /* fall thru */ case NF3FIFO: attr = what.mknoddata3_u.pipe_attributes; break; case NF3BLK: case NF3CHR: attr = what.mknoddata3_u.device.dev_attributes; *dev = (what.mknoddata3_u.device.spec.specdata1 << 8) + what.mknoddata3_u.device.spec.specdata2; break; } *mode = create_mode(attr); /* adjust mode for creation of device special files */ switch (what.type) { case NF3CHR: *mode |= S_IFCHR; break; case NF3BLK: *mode |= S_IFBLK; break; default: break; } return atomic_attr(attr); }
// Create must be turned on and connected. This routine establishes serial link // Note that this routine should be called once, and must have been called before // any of the other create functions will work. // If Create is connected, power light goes yellow and play led turns on int create_connect() { gc_mode=0; serial_init(); create_start(); create_safe(); //allows create to be commanded and turns LED orange create_mode();//gets mode and sets global gc_mode if (gc_mode!=2) { // if not safe mode, connection not established printf("Create connect failed, mode is %d\n", gc_mode); g_create_connected = 0; msleep(100); beep(); msleep(100); beep(); return(-1);//connection failed } create_advance_led(1); // turn on advance LED g_create_connected = 1; atexit(create_disconnect); return(0);//successful connection }
MKDIR3res *nfsproc3_mkdir_3_svc(MKDIR3args * argp, struct svc_req * rqstp) { static MKDIR3res result; char *path; pre_op_attr pre; post_op_attr post; char obj[NFS_MAXPATHLEN]; int res; PREP(path, argp->where.dir); pre = get_pre_cached(); result.status = join3(cat_name(path, argp->where.name, obj), atomic_attr(argp->attributes), exports_rw()); cluster_create(obj, rqstp, &result.status); if (result.status == NFS3_OK) { res = backend_mkdir(obj, create_mode(argp->attributes)); if (res == -1) result.status = mkdir_err(); else { result.MKDIR3res_u.resok.obj = fh_extend_type(argp->where.dir, obj, S_IFDIR); result.MKDIR3res_u.resok.obj_attributes = get_post_cached(rqstp); } } post = get_post_attr(path, argp->where.dir, rqstp); /* overlaps with resfail */ result.MKDIR3res_u.resok.dir_wcc.before = pre; result.MKDIR3res_u.resok.dir_wcc.after = post; return &result; }
CREATE3res *nfsproc3_create_3_svc(CREATE3args * argp, struct svc_req * rqstp) { static CREATE3res result; char *path; char obj[NFS_MAXPATHLEN]; sattr3 new_attr; int fd = -1, res = -1; backend_statstruct buf; uint32 gen; int flags = O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK; PREP(path, argp->where.dir); result.status = join(cat_name(path, argp->where.name, obj), exports_rw()); cluster_create(obj, rqstp, &result.status); /* GUARDED and EXCLUSIVE maps to Unix exclusive create */ if (argp->how.mode != UNCHECKED) flags = flags | O_EXCL; if (argp->how.mode != EXCLUSIVE) { new_attr = argp->how.createhow3_u.obj_attributes; result.status = join(result.status, atomic_attr(new_attr)); } /* Try to open the file */ if (result.status == NFS3_OK) { if (argp->how.mode != EXCLUSIVE) { fd = backend_open_create(obj, flags, create_mode(new_attr)); } else { fd = backend_open_create(obj, flags, create_mode(new_attr)); } } if (fd != -1) { /* Successful open */ res = backend_fstat(fd, &buf); if (res != -1) { /* Successful stat */ if (argp->how.mode == EXCLUSIVE) { /* Save verifier in atime and mtime */ res = backend_store_create_verifier(obj, argp->how.createhow3_u. verf); } } if (res != -1) { /* So far, so good */ gen = backend_get_gen(buf, fd, obj); fh_cache_add(buf.st_dev, buf.st_ino, obj); backend_close(fd); result.CREATE3res_u.resok.obj = fh_extend_post(argp->where.dir, buf.st_dev, buf.st_ino, gen); result.CREATE3res_u.resok.obj_attributes = get_post_buf(buf, rqstp); } if (res == -1) { /* backend_fstat() or backend_store_create_verifier() failed */ backend_close(fd); result.status = NFS3ERR_IO; } } else if (result.status == NFS3_OK) { /* open() failed */ if (argp->how.mode == EXCLUSIVE && errno == EEXIST) { /* Check if verifier matches */ fd = backend_open(obj, O_NONBLOCK); if (fd != -1) { res = backend_fstat(fd, &buf); } if (res != -1) { if (backend_check_create_verifier (&buf, argp->how.createhow3_u.verf)) { /* The verifier matched. Return success */ gen = backend_get_gen(buf, fd, obj); fh_cache_add(buf.st_dev, buf.st_ino, obj); backend_close(fd); result.CREATE3res_u.resok.obj = fh_extend_post(argp->where.dir, buf.st_dev, buf.st_ino, gen); result.CREATE3res_u.resok.obj_attributes = get_post_buf(buf, rqstp); } else { /* The verifier doesn't match */ result.status = NFS3ERR_EXIST; } } } if (res == -1) { result.status = create_err(); } } /* overlaps with resfail */ result.CREATE3res_u.resok.dir_wcc.before = get_pre_cached(); result.CREATE3res_u.resok.dir_wcc.after = get_post_stat(path, rqstp); return &result; }