int quota_reset_grace(quota_t *myquota, int grace_type) { quota_t temp_quota; memcpy(&temp_quota, myquota, sizeof(quota_t)); if (grace_type == GRACE_BLOCK) temp_quota.block_hard = temp_quota.block_soft = temp_quota.diskspace_used + 1; else temp_quota.inode_hard = temp_quota.inode_soft = temp_quota.inode_used + 1; if (quota_set(&temp_quota) && quota_set(myquota)) return 1; output_error("Cannot reset grace period!"); return 0; // error, on success we return above }
int main (int argc, char *argv[]) { if (argc < 3) usage (); char *command = argv[1]; char *path = argv[2]; char fpath[PATH_MAX]; if (realpath (path, fpath) == NULL) error ("main_realpath"); if (strcmp (command, "set") == 0) { if (argc < 4) usage (); int c = getopt (argc, argv, "u:"); enum units unit = (c < 0) ? BYTES : char_to_units (optarg[0]); unsigned long size = (unsigned long) atol (argv[3]); quota_set (fpath, size, unit); } else if (strcmp (command, "get") == 0) { int c = getopt (argc, argv, "u:"); enum units unit = (c < 0) ? BYTES : char_to_units (optarg[0]); long double size = quota_get (fpath, unit); printf ("%Lf\n", size); } else if (strcmp (command, "get-binding") == 0) { int c = getopt (argc, argv, "u:"); enum units unit = (c < 0) ? BYTES : char_to_units(optarg[0]); char binding_path[PATH_MAX]; long double size = quota_get_binding (fpath, unit, binding_path); printf("%Lf on %s\n", size, binding_path); } else if (strcmp (command, "exceeded") == 0) { if(quota_exceeded (path) == 0) printf("NOT "); printf("EXCEEDED\n"); } else if (strcmp (command, "unset") == 0) quota_unset (fpath); else if (strcmp (command, "mount") == 0) { if (argc < 4) usage (); if (realpath (argv[2], base) == NULL) error ("main_realpath"); int i = 1; for (; i < argc; i++) argv[i] = argv[i + 2]; argc -= 2; int ret = fuse_main (argc, argv, &fuse_ops, base); if (ret < 0) error ("fuse_main"); return ret; } else usage (); return 0; }