}
#ifdef HAVE_SYS_QUOTA_H
+static int quota_is_2_0_server(const char *mnt)
+{
+ __u64 flags;
+ int rc;
+
+ rc = llapi_get_connect_flags(mnt, &flags);
+ if (rc < 0)
+ return rc;
+
+ if (flags & OBD_CONNECT_FID)
+ return 1;
+ else
+ return 0;
+}
+
static int lfs_quotachown(int argc, char **argv)
{
struct if_quotactl qctl;
char *obd_type = (char *)qchk.obd_type;
int rc;
- int version;
+ int v2;
optind = 0;
while ((c = getopt(argc, argv, "ug")) != -1) {
return CMD_HELP;
mnt = argv[optind];
- version = llapi_server_major_version(mnt);
- if (version < 0)
- return version;
+ v2 = quota_is_2_0_server(mnt);
+ if (v2 < 0)
+ return v2;
/* For b1_8 server */
- if (version < SERVER_MAJOR_VERSION_V2) {
+ if (v2 == 0) {
memset(&qctl, 0, sizeof(qctl));
qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
qctl.qc_type = check_type;
memset(&qctl, 0, sizeof(qctl));
qctl.qc_cmd = LUSTRE_Q_QUOTAON;
qctl.qc_type = check_type;
- if (version < SERVER_MAJOR_VERSION_V2)
+ if (v2 == 0)
qctl.qc_id = QFMT_LDISKFS; /* compatibility: 1.6.5 and earliers
* take this parameter into account */
rc = llapi_quotactl(mnt, &qctl);
if (rc) {
- if (version >= SERVER_MAJOR_VERSION_V2 && errno == EALREADY) {
+ if (v2 > 0 && errno == EALREADY) {
/* This is for 2.0 server. */
rc = 0;
} else {
struct if_quotactl qctl;
char *obd_type = (char *)qctl.obd_type;
int rc;
- int version;
+ int v2;
memset(&qctl, 0, sizeof(qctl));
qctl.qc_cmd = LUSTRE_Q_QUOTAON;
return CMD_HELP;
mnt = argv[optind];
- version = llapi_server_major_version(mnt);
- if (version < 0)
- return version;
+ v2 = quota_is_2_0_server(mnt);
+ if (v2 < 0)
+ return v2;
- if (version < SERVER_MAJOR_VERSION_V2)
+ if (v2 == 0)
qctl.qc_id = QFMT_LDISKFS; /* compatibility: 1.6.5 and earliers
* take this parameter into account */
rc = llapi_quotactl(mnt, &qctl);
if (rc) {
- if (version >= SERVER_MAJOR_VERSION_V2 && errno == EALREADY) {
+ if (v2 > 0 && errno == EALREADY) {
/* This is for 2.0 server. */
- fprintf(stderr, "\n%s quotas are enabled already.\n",
- qctl.qc_type == 0x00 ? "user" : "group");
rc = 0;
} else if (errno == ENOENT) {
fprintf(stderr, "error: cannot find quota database, "
struct if_quotactl qctl;
char *obd_type = (char *)qctl.obd_type;
int rc;
- int version;
+ int v2;
memset(&qctl, 0, sizeof(qctl));
qctl.qc_cmd = LUSTRE_Q_QUOTAOFF;
return CMD_HELP;
mnt = argv[optind];
- version = llapi_server_major_version(mnt);
- if (version < 0)
- return version;
+ v2 = quota_is_2_0_server(mnt);
+ if (v2 < 0)
+ return v2;
rc = llapi_quotactl(mnt, &qctl);
if (rc) {
- if ((version >= SERVER_MAJOR_VERSION_V2 && errno == EALREADY) ||
- (version < SERVER_MAJOR_VERSION_V2 && errno == ESRCH)) {
- fprintf(stderr, "\n%s quotas are not enabled.\n",
- qctl.qc_type == 0x00 ? "user" : "group");
+ if ((v2 > 0 && errno == EALREADY) ||
+ (v2 == 0 && errno == ESRCH)) {
rc = 0;
} else {
if (*obd_type)
int rc, rc1 = 0, rc2 = 0, rc3 = 0, verbose = 0, inacc, quiet = 0;
int pass = 0;
char *endptr;
- int version;
optind = 0;
while ((c = getopt(argc, argv, "ugto:qv")) != -1) {
}
mnt = argv[optind];
- version = llapi_server_major_version(mnt);
- if (version < 0)
- goto out;
rc1 = llapi_quotactl(mnt, &qctl);
if (rc1 == -1) {
case ENOENT:
/* We already got a "No such file..." message. */
goto out;
- case EALREADY:
- case ESRCH:
- if ((version >= SERVER_MAJOR_VERSION_V2 &&
- errno == EALREADY) ||
- (version < SERVER_MAJOR_VERSION_V2 &&
- errno == ESRCH)) {
- fprintf(stderr, "%s quotas are not enabled.\n",
- qctl.qc_type == USRQUOTA?"user":"group");
- goto out;
- }
+ case ESRCH: {
+ fprintf(stderr, "%s quotas are not enabled.\n",
+ qctl.qc_type == USRQUOTA?"user":"group");
+ goto out;
+ }
default:
fprintf(stderr, "Unexpected quotactl error: %s\n",
strerror(errno));